Changeset 81 for trunk


Ignore:
Timestamp:
Nov 4, 2014, 11:17:35 PM (10 years ago)
Author:
chronos
Message:
  • Added: Prepared related class for "Fog of war" game mode and per player map handling.
  • Added: Computer alternate direction of processing inner moves each turn to not cumulate units to top left corner of map.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/UGame.pas

    r80 r81  
    200200  end;
    201201
     202  { TPlayerCell }
     203
     204  TPlayerCell = class
     205    Explored: Boolean;
     206    InVisibleRange: Boolean;
     207    MapCell: TCell;
     208  end;
     209
     210  { TPlayerCells }
     211
     212  TPlayerCells = class(TObjectList)
     213
     214  end;
     215
     216  { TPlayerMap }
     217
     218  TPlayerMap = class
     219    Cells: TPlayerCells;
     220    constructor Create;
     221    destructor Destroy; override;
     222  end;
     223
    202224  TPlayerMode = (pmHuman, pmComputer);
    203225
     
    219241    StartUnits: Integer;
    220242    StartCell: TCell;
     243    PlayerMap: TPlayerMap;
    221244    procedure LoadFromNode(Node: TDOMNode);
    222245    procedure SaveToNode(Node: TDOMNode);
     
    234257    Game: TGame;
    235258    Targets: TObjectList;
     259    CellProcessDirection: Boolean;
    236260    procedure AttackNeutral;
    237261    procedure AttackPlayers;
     
    441465end;
    442466
     467{ TPlayerMap }
     468
     469constructor TPlayerMap.Create;
     470begin
     471  Cells := TPlayerCells.Create;
     472end;
     473
     474destructor TPlayerMap.Destroy;
     475begin
     476  Cells.Free;
     477  inherited Destroy;
     478end;
     479
    443480{ TCanvasEx }
    444481
     
    15801617  end;
    15811618
     1619  if CellProcessDirection then begin
     1620    // Reverse array
     1621    for I := 0 to (TargetCells.Count div 2) - 1 do
     1622      TargetCells.Exchange(I, TargetCells.Count - 1 - I);
     1623  end;
     1624
    15821625  // Unset mark for all cells
    15831626  for C := 0 to AllCells.Count - 1 do
     
    16431686  InnerMoves;
    16441687  IncreaseMoves;
     1688  CellProcessDirection := not CellProcessDirection;
    16451689end;
    16461690
     
    16841728  StartUnits := DefaultPlayerStartUnits;
    16851729  StartCell := nil;
     1730  PlayerMap := TPlayerMap.Create;
    16861731end;
    16871732
    16881733destructor TPlayer.Destroy;
    16891734begin
     1735  FreeAndNil(PlayerMap);
    16901736  FreeAndNil(View);
    16911737  inherited Destroy;
Note: See TracChangeset for help on using the changeset viewer.