Changeset 271 for trunk/UGame.pas
- Timestamp:
- Jan 28, 2019, 10:53:09 PM (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/UGame.pas
r270 r271 54 54 procedure BuildTerrain; 55 55 procedure PlaceCities; 56 procedure InitPlayers; 56 57 procedure SelectPlayerStartCell(Player: TPlayer); 57 58 procedure CalculatePlayersDistance; … … 84 85 MaxPower: Integer; 85 86 StoredRandSeed: Cardinal; 87 GeneratePlayers: Boolean; 86 88 procedure PostConfig; 87 89 procedure Assign(Source: TGame); … … 308 310 if (Terrain = ttNormal) and CityEnabled and (Random < CityPercentage / 100) then 309 311 Terrain := ttCity; 312 end; 313 end; 314 315 procedure TGame.InitPlayers; 316 var 317 I: Integer; 318 Player: TPlayer; 319 begin 320 if not GeneratePlayers then Exit; 321 322 for Player in Players do begin 323 Player.Reset; 324 Player.StartCell := nil; 325 end; 326 I := 0; 327 for Player in Players do 328 with Player do begin 329 PlayerMap.Update; 330 if (Map.Size.X > 0) and (Map.Size.Y > 0) then begin 331 SelectPlayerStartCell(Player); 332 if Assigned(Player.StartCell) then begin 333 if SymetricMap and (I = 1) then 334 StartCell := Map.Cells[Map.Cells.Count - 1 - Map.Cells.IndexOf(Players[0].StartCell)]; 335 336 if CityEnabled then StartCell.Terrain := ttCity; 337 StartCell.Player := Player; 338 if not Assigned(StartCell.OneUnit) then 339 StartCell.OneUnit := Units.AddNew(GameSystem.UnitKinds[0], Player.StartUnits); 340 StartCell.OneUnit.Power := Player.StartUnits; 341 StartCell.OneUnit.Kind := GameSystem.UnitKinds[0]; 342 end; 343 end; 344 PlayerMap.CheckVisibility; 345 Inc(I); 310 346 end; 311 347 end; … … 806 842 Players.Game := Self; 807 843 844 GeneratePlayers := True; 808 845 MapImageFileName := 'Images/Maps/WorldMap.png'; 809 846 Randomize; 847 StoredRandSeed := RandSeed; 810 848 InitDefaultPlayers; 811 849 … … 835 873 836 874 procedure TGame.New; 837 var838 I: Integer;839 Player: TPlayer;840 875 begin 841 876 Clear; … … 859 894 end; 860 895 861 for Player in Players do begin 862 Player.Reset; 863 Player.StartCell := nil; 864 end; 865 I := 0; 866 for Player in Players do 867 with Player do begin 868 PlayerMap.Update; 869 if (Map.Size.X > 0) and (Map.Size.Y > 0) then begin 870 SelectPlayerStartCell(Player); 871 if Assigned(Player.StartCell) then begin 872 if SymetricMap and (I = 1) then 873 StartCell := Map.Cells[Map.Cells.Count - 1 - Map.Cells.IndexOf(Players[0].StartCell)]; 874 875 StartCell.Terrain := ttCity; 876 StartCell.Player := Player; 877 if not Assigned(StartCell.OneUnit) then 878 StartCell.OneUnit := Units.AddNew(GameSystem.UnitKinds[0], Player.StartUnits); 879 StartCell.OneUnit.Power := Player.StartUnits; 880 StartCell.OneUnit.Kind := GameSystem.UnitKinds[0]; 881 end; 882 end; 883 PlayerMap.CheckVisibility; 884 Inc(I); 885 end; 896 InitPlayers; 886 897 if Players.Count > 0 then CurrentPlayer := Players[0] 887 898 else CurrentPlayer := nil;
Note:
See TracChangeset
for help on using the changeset viewer.