Changeset 62 for trunk/UGame.pas
- Timestamp:
- Sep 26, 2014, 1:58:41 PM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/UGame.pas
r60 r62 237 237 procedure SetRunning(AValue: Boolean); 238 238 procedure UpdateRepeatMoves(Player: TPlayer); 239 procedure CheckCounterMove(Move: TUnitMove); 239 240 public 240 241 Players: TPlayers; … … 524 525 SetLength(Points, 8); 525 526 SetLength(FPoints, 8); 526 ArrowSize := Point(Trunc(DefaultCellSize.X / 4* View.Zoom),527 Trunc(DefaultCellSize.Y / 4* View.Zoom));527 ArrowSize := Point(Trunc(DefaultCellSize.X / 3 * View.Zoom), 528 Trunc(DefaultCellSize.Y / 3 * View.Zoom)); 528 529 FPoints[0] := FloatPoint(+0.5 * ArrowSize.X, +0 * ArrowSize.Y); 529 530 FPoints[1] := FloatPoint(+0 * ArrowSize.X, +0.5 * ArrowSize.Y); … … 546 547 Brush.Style := bsClear; 547 548 Font.Color := clBlack; 548 Font.Size := Trunc( 16 * View.Zoom);549 Font.Size := Trunc(26 * View.Zoom); 549 550 TextOut(Pos.X - TextWidth(Text) div 2, 550 551 Pos.Y - TextHeight(Text) div 2, Text); … … 1288 1289 end; 1289 1290 if Confirm then begin 1290 if Assigned(OldMove) then begin 1291 // Already have such move 1292 if (CountOnce = 0) and (CountRepeat = 0) then Moves.Delete(I) 1293 else begin 1294 TUnitMove(Moves[I]).CountOnce := CountOnce; 1295 TUnitMove(Moves[I]).CountRepeat := CountRepeat; 1291 if Assigned(OldMove) then begin 1292 // Already have such move 1293 if (CountOnce = 0) and (CountRepeat = 0) then Moves.Delete(I) 1294 else begin 1295 OldMove.CountOnce := CountOnce; 1296 OldMove.CountRepeat := CountRepeat; 1297 CheckCounterMove(OldMove); 1298 end; 1299 end else begin 1300 // Add new move 1301 if (CountOnce > 0) or (CountRepeat > 0) then begin 1302 NewMove := TUnitMove(Moves[Moves.Add(TUnitMove.Create)]); 1303 NewMove.List := Moves; 1304 NewMove.CellFrom := CellFrom; 1305 NewMove.CellTo := CellTo; 1306 NewMove.CountOnce := CountOnce; 1307 NewMove.CountRepeat := CountRepeat; 1308 CheckCounterMove(NewMove); 1296 1309 end; 1297 end else begin 1298 // Add new move 1299 if (CountOnce > 0) or (CountRepeat > 0) then begin 1300 NewMove := TUnitMove(Moves[Moves.Add(TUnitMove.Create)]); 1301 NewMove.List := Moves; 1302 NewMove.CellFrom := CellFrom; 1303 NewMove.CellTo := CellTo; 1304 NewMove.CountOnce := CountOnce; 1305 NewMove.CountRepeat := CountRepeat; 1306 end; 1307 end; 1310 end; 1311 1308 1312 end; 1309 1313 end; … … 1336 1340 CountOnce := CountRepeat 1337 1341 else CountOnce := CellFrom.GetAvialPower; 1342 end; 1343 end; 1344 1345 procedure TGame.CheckCounterMove(Move: TUnitMove); 1346 var 1347 I: Integer; 1348 CounterMove: TUnitMove; 1349 begin 1350 I := 0; 1351 while (I < Moves.Count) and ((TUnitMove(Moves[I]).CellTo <> Move.CellFrom) and 1352 (TUnitMove(Moves[I]).CellFrom <> Move.CellTo)) do Inc(I); 1353 if I < Moves.Count then CounterMove := TUnitMove(Moves[I]) 1354 else CounterMove := nil; 1355 if Assigned(CounterMove) then begin 1356 // For now, just remove counter move 1357 Moves.Remove(CounterMove); 1338 1358 end; 1339 1359 end; … … 1644 1664 Angle: Double; 1645 1665 ArrowCenter: TPoint; 1666 Move: TUnitMove; 1646 1667 begin 1647 1668 with Canvas, View do … … 1658 1679 Pen.Color := clBlack; 1659 1680 PaintCell(Canvas, Cell.PosPx, IntToStr(Cell.GetAvialPower), View, Cell); 1660 1661 // Draw arrows1662 Pen.Color := clCream;1663 for I := 0 to Cell.MovesFrom.Count - 1 do begin1664 PosFrom := CellToPos(Cell);1665 PosTo := CellToPos(TUnitMove(Cell.MovesFrom[I]).CellTo);1666 if TUnitMove(Cell.MovesFrom[I]).CountRepeat > 0 then Pen.Width := 21667 else Pen.Width := 1;1668 Angle := ArcTan((PosTo.Y - PosFrom.Y) / (PosTo.X - PosFrom.X));1669 if Sign(PosTo.X - PosFrom.X) = -1 then Angle := Angle + Pi;1670 ArrowCenter := View.CellToCanvasPos(Point(Trunc(PosFrom.X + (PosTo.X - PosFrom.X) / 3),1671 Trunc(PosFrom.Y + (PosTo.Y - PosFrom.Y) / 3)));1672 DrawArrow(Canvas, View, ArrowCenter,1673 Angle, IntToStr(TUnitMove(Cell.MovesFrom[I]).CountOnce));1674 end;1675 1681 end; 1682 1683 end; 1684 1685 // Draw arrows 1686 Pen.Color := clCream; 1687 for I := 0 to Game.Moves.Count - 1 do begin 1688 Move := TUnitMove(Game.Moves[I]); 1689 PosFrom := CellToPos(Move.CellFrom); 1690 PosTo := CellToPos(Move.CellTo); 1691 if Move.CountRepeat > 0 then Pen.Width := 2 1692 else Pen.Width := 1; 1693 Angle := ArcTan((PosTo.Y - PosFrom.Y) / (PosTo.X - PosFrom.X)); 1694 if Sign(PosTo.X - PosFrom.X) = -1 then Angle := Angle + Pi; 1695 ArrowCenter := View.CellToCanvasPos(Point(Trunc(PosFrom.X + (PosTo.X - PosFrom.X) / 2), 1696 Trunc(PosFrom.Y + (PosTo.Y - PosFrom.Y) / 2))); 1697 DrawArrow(Canvas, View, ArrowCenter, 1698 Angle, IntToStr(Move.CountOnce)); 1676 1699 end; 1677 1700 finally
Note:
See TracChangeset
for help on using the changeset viewer.