Changeset 85
- Timestamp:
- Nov 5, 2014, 10:38:34 PM (10 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Forms/UFormMain.pas
r82 r85 378 378 if (Abs(StartMousePoint.X - X) < MouseMinDiff) and (Abs(StartMousePoint.Y - Y) < MouseMinDiff) then begin 379 379 if Core.Game.Running and (Core.Game.CurrentPlayer.Mode = pmHuman) then begin 380 Core.Game.CurrentPlayer.View.SelectCell(Point(X, Y), Core.Game.CurrentPlayer );380 Core.Game.CurrentPlayer.View.SelectCell(Point(X, Y), Core.Game.CurrentPlayer, Shift); 381 381 Redraw; 382 382 end; -
trunk/UGame.pas
r84 r85 96 96 constructor Create; 97 97 destructor Destroy; override; 98 procedure SelectCell(Pos: TPoint; Player: TPlayer );98 procedure SelectCell(Pos: TPoint; Player: TPlayer; ShiftState: TShiftState); 99 99 procedure CenterMap; 100 100 function CanvasToCellPos(Pos: TPoint): TPoint; … … 347 347 procedure ClearMovesFromCell(Cell: TCell); 348 348 procedure SetMapType(AValue: TMapType); 349 procedure SetMove(CellFrom, CellTo: TCell; Power: Integer);349 function SetMove(CellFrom, CellTo: TCell; Power: Integer; Confirmation: Boolean = True): TUnitMove; 350 350 procedure SetRunning(AValue: Boolean); 351 351 procedure UpdateRepeatMoves(Player: TPlayer); … … 1748 1748 if TCell(Neighbors[I]).GetAvialPower < AttackPower then 1749 1749 AttackPower := TCell(Neighbors[I]).GetAvialPower; 1750 Game.SetMove(Tcell(Neighbors[I]), TCell(TargetCells[C]), AttackPower );1750 Game.SetMove(Tcell(Neighbors[I]), TCell(TargetCells[C]), AttackPower, False); 1751 1751 TotalAttackPower := TotalAttackPower + AttackPower; 1752 1752 end; … … 1810 1810 if TCell(Neighbors[I]).GetAvialPower < AttackPower then 1811 1811 AttackPower := TCell(Neighbors[I]).GetAvialPower; 1812 Game.SetMove(TCell(Neighbors[I]), TCell(TargetCells[C]), AttackPower );1812 Game.SetMove(TCell(Neighbors[I]), TCell(TargetCells[C]), AttackPower, False); 1813 1813 TotalAttackPower := TotalAttackPower + AttackPower; 1814 1814 end; … … 1883 1883 end; 1884 1884 if CanAttack = 0 then 1885 Game.SetMove(TCell(Neighbors[I]), TCell(TargetCells[C]), TCell(Neighbors[I]).GetAvialPower );1885 Game.SetMove(TCell(Neighbors[I]), TCell(TargetCells[C]), TCell(Neighbors[I]).GetAvialPower, False); 1886 1886 end; 1887 1887 TCell(Neighbors[I]).Mark := True; … … 1923 1923 end; 1924 1924 1925 procedure TView.SelectCell(Pos: TPoint; Player: TPlayer );1925 procedure TView.SelectCell(Pos: TPoint; Player: TPlayer; ShiftState: TShiftState); 1926 1926 var 1927 1927 NewSelectedCell: TCell; 1928 UnitMove: TUnitMove; 1929 I: Integer; 1928 1930 begin 1929 1931 NewSelectedCell := Game.Map.PosToCell(CanvasToCellPos(Pos), Self); 1930 1932 if Assigned(NewSelectedCell) then begin 1931 1933 if Assigned(SelectedCell) and Game.Map.IsCellsNeighbor(NewSelectedCell, SelectedCell) then begin 1932 Game.SetMove(SelectedCell, NewSelectedCell, SelectedCell.Power); 1933 SelectedCell := nil; 1934 if ssCtrl in ShiftState then begin 1935 // If CTRL key pressed then storno all moved from selected cell and 1936 // move all power to new selected cell 1937 for I := SelectedCell.MovesFrom.Count - 1 downto 0 do 1938 TUnitMove(SelectedCell.MovesFrom[I]).Free; 1939 UnitMove := Game.SetMove(SelectedCell, NewSelectedCell, SelectedCell.Power, False); 1940 if Assigned(UnitMove) then 1941 UnitMove.CountRepeat := Player.Game.Map.MaxPower; 1942 if NewSelectedCell.Player = Player then SelectedCell := NewSelectedCell 1943 else SelectedCell := nil; 1944 end else begin 1945 Game.SetMove(SelectedCell, NewSelectedCell, SelectedCell.Power); 1946 SelectedCell := nil; 1947 end; 1934 1948 end else 1935 1949 if (NewSelectedCell <> SelectedCell) and (NewSelectedCell.Player = Player) then … … 2155 2169 end; 2156 2170 2157 procedure TGame.SetMove(CellFrom, CellTo: TCell; Power: Integer);2171 function TGame.SetMove(CellFrom, CellTo: TCell; Power: Integer; Confirmation: Boolean = True): TUnitMove; 2158 2172 var 2159 2173 NewMove: TUnitMove; … … 2170 2184 if I < Moves.Count then OldMove := TUnitMove(Moves[I]) 2171 2185 else OldMove := nil; 2186 Result := OldMove; 2172 2187 if Assigned(OldMove) then begin 2173 2188 CountOnce := OldMove.CountOnce; 2174 2189 CountRepeat := OldMove.CountRepeat; 2175 if Assigned(CurrentPlayer) and (CurrentPlayer.Mode = pmHuman)and2190 if Assigned(CurrentPlayer) and Confirmation and 2176 2191 Assigned(FOnMove) then FOnMove(CellFrom, CellTo, CountOnce, CountRepeat, True, Confirm); 2177 2192 end else begin 2178 2193 CountOnce := Power; 2179 2194 CountRepeat := 0; 2180 if Assigned(CurrentPlayer) and (CurrentPlayer.Mode = pmHuman)and2195 if Assigned(CurrentPlayer) and Confirmation and 2181 2196 Assigned(FOnMove) then FOnMove(CellFrom, CellTo, CountOnce, CountRepeat, False, Confirm); 2182 2197 end; … … 2199 2214 NewMove.CountOnce := CountOnce; 2200 2215 NewMove.CountRepeat := CountRepeat; 2216 Result := NewMove; 2201 2217 CheckCounterMove(NewMove); 2202 2218 end; 2203 2219 end; 2204 2205 2220 end; 2206 2221 end;
Note:
See TracChangeset
for help on using the changeset viewer.