Changeset 229 for trunk/UGame.pas


Ignore:
Timestamp:
Sep 18, 2018, 6:11:18 PM (6 years ago)
Author:
chronos
Message:
  • Added: Support for cyclic map. Movement across map borders will take player units to opposite map border.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/UGame.pas

    r224 r229  
    456456    VoidPercentage: Integer;
    457457    SymetricMap: Boolean;
     458    CyclicMap: Boolean;
    458459    GrowCells: TGrowCells;
    459460    GrowAmount: TGrowAmount;
     
    16131614function TMap.IsValidIndex(Index: TPoint): Boolean;
    16141615begin
    1615   Result := False;
     1616  Result := (Index.X >= 0) and (Index.X < Size.X) and
     1617    (Index.Y >= 0) and (Index.Y < Size.Y);
    16161618end;
    16171619
     
    20852087procedure TCell.ConnectTo(Cell: TCell);
    20862088begin
    2087   Cell.Neighbors.Add(Self);
    2088   Neighbors.Add(Cell);
     2089  // Connect only if already not connected
     2090  if Neighbors.IndexOf(Cell) < 0 then begin
     2091    Cell.Neighbors.Add(Self);
     2092    Neighbors.Add(Cell);
     2093  end;
    20892094end;
    20902095
     
    31363141  VoidPercentage := Source.VoidPercentage;
    31373142  SymetricMap := Source.SymetricMap;
     3143  CyclicMap := Source.CyclicMap;
    31383144  GrowCells := Source.GrowCells;
    31393145  GrowAmount := Source.GrowAmount;
     
    31573163    SetValue(DOMString(Path + '/MapImage'), DOMString(MapImageFileName));
    31583164    SetValue(DOMString(Path + '/SymetricMap'), SymetricMap);
     3165    SetValue(DOMString(Path + '/CyclicMap'), CyclicMap);
    31593166    SetValue(DOMString(Path + '/FogOfWar'), FogOfWar);
    31603167    SetValue(DOMString(Path + '/VoidEnabled'), VoidEnabled);
     
    31853192    MapImageFileName := string(GetValue(DOMString(Path + '/MapImage'), DOMString(MapImageFileName)));
    31863193    SymetricMap := GetValue(DOMString(Path + '/SymetricMap'), False);
     3194    CyclicMap := GetValue(DOMString(Path + '/CyclicMap'), False);
    31873195    FogOfWar := GetValue(DOMString(Path + '/FogOfWar'), False);
    31883196    VoidEnabled := GetValue(DOMString(Path + '/VoidEnabled'), True);
     
    32253233    with RootNode do begin
    32263234      SymetricMap := ReadBoolean(RootNode, 'SymetricMap', False);
     3235      CyclicMap := ReadBoolean(RootNode, 'CyclicMap', False);
    32273236      FogOfWar := ReadBoolean(RootNode, 'FogOfWar', False);
    32283237      VoidEnabled := ReadBoolean(RootNode, 'VoidEnabled', False);
     
    32763285    with RootNode do begin
    32773286      WriteBoolean(RootNode, 'SymetricMap', SymetricMap);
     3287      WriteBoolean(RootNode, 'CyclicMap', CyclicMap);
    32783288      WriteBoolean(RootNode, 'FogOfWar', FogOfWar);
    32793289      WriteBoolean(RootNode, 'VoidEnabled', VoidEnabled);
     
    34783488  TurnCounter := 1;
    34793489
     3490  Map.Cyclic := CyclicMap;
    34803491  Map.Generate;
    34813492  Map.MaxPower := MaxPower;
Note: See TracChangeset for help on using the changeset viewer.