Changeset 89
- Timestamp:
- Sep 22, 2022, 9:37:46 PM (2 years ago)
- Location:
- trunk
- Files:
-
- 1 added
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/BigMetro.lpi
r86 r89 89 89 </Item2> 90 90 </RequiredPackages> 91 <Units Count=" 7">91 <Units Count="8"> 92 92 <Unit0> 93 93 <Filename Value="BigMetro.lpr"/> … … 124 124 <IsPartOfProject Value="True"/> 125 125 </Unit6> 126 <Unit7> 127 <Filename Value="UMetroPassenger.pas"/> 128 <IsPartOfProject Value="True"/> 129 </Unit7> 126 130 </Units> 127 131 </ProjectOptions> -
trunk/BigMetro.lpr
r64 r89 8 8 {$ENDIF} 9 9 Interfaces, // this includes the LCL widgetset 10 Forms, SysUtils, UFormMain, UFormImages, Common, UMenu, UControls; 10 Forms, SysUtils, UFormMain, UFormImages, Common, UMenu, UControls, 11 UMetroPassenger; 11 12 12 13 {$R *.res} -
trunk/UEngine.pas
r86 r89 8 8 {$IFDEF DARWIN}MacOSAll, CocoaAll, CocoaUtils,{$ENDIF} 9 9 Classes, SysUtils, Graphics, Controls, ExtCtrls, Math, DateUtils, 10 UMetaCanvas, Generics.Collections, Generics.Defaults, UMenu, UControls; 10 UMetaCanvas, Generics.Collections, Generics.Defaults, UMenu, UControls, 11 UMetroPassenger; 11 12 12 13 type 13 TStationShape = (ssCircle, ssSquare, ssTriangle, ssStar, ssPlus, ssPentagon,14 ssDiamond, ssQuarterCircle, ssHexagon, ssCross, ssHalfCircle, ssHeptagon);15 14 TStationShapeSet = set of TStationShape; 16 15 TEngine = class; 17 TMetroPassengers = class;18 16 TMetroLines = class; 19 17 TMetroLine = class; … … 228 226 function GetUnusedCount: Integer; 229 227 function AddNew: TMetroTrain; 230 end;231 232 TMetroPassenger = class233 Engine: TEngine;234 Shape: TStationShape;235 Station: TMapStation;236 Train: TMetroTrain;237 end;238 239 { TMetroPassengers }240 241 TMetroPassengers = class(TObjectList<TMetroPassenger>)242 Engine: TEngine;243 function AddNew: TMetroPassenger;244 228 end; 245 229 … … 775 759 end; 776 760 777 { TMetroPassengers }778 779 function TMetroPassengers.AddNew: TMetroPassenger;780 begin781 Result := TMetroPassenger.Create;782 Result.Engine := Engine;783 Result.Shape := TStationShape(Random(Integer(Engine.ShapeCount)));784 Add(Result);785 end;786 787 761 { TMetroTrains } 788 762 … … 1756 1730 // Move trains 1757 1731 for I := 0 to Trains.Count - 1 do 1758 with T rains[I]do begin1732 with TMetroTrain(Trains[I]) do begin 1759 1733 if not Assigned(TargetStation) and Assigned(BaseTrackPoint) then begin 1760 1734 if (Direction <> 1) and (Direction <> -1) then Direction := 1 … … 1814 1788 Passengers.Delete(P); 1815 1789 CurrentStation.MapStation.Passengers.Add(Passenger); 1816 Passenger.Station := CurrentStation.MapStation;1817 1790 end; 1818 1791 end; … … 1826 1799 Passenger := CurrentStation.MapStation.Passengers[P]; 1827 1800 if CurrentStation.MapStation.IsBestStationForShape(Passenger.Shape, 1828 TargetStation, CurrentStation) then begin 1829 Passenger.Station := nil; 1801 TargetStation, CurrentStation) then begin 1830 1802 CurrentStation.MapStation.Passengers.Delete(P); 1831 1803 Passengers.Add(Passenger); 1832 Passenger.Train := Trains[I];1833 1804 end; 1834 1805 end else Break; // No more space … … 2585 2556 if Random < NewPassengerProbability then begin 2586 2557 Passenger := Self.Passengers.AddNew; 2587 Passenger.S tation := MapStation;2558 Passenger.Shape := TStationShape(Random(Integer(ShapeCount))); 2588 2559 Passengers.Add(Passenger); 2589 2560 2590 2561 // Passenger is not allowed to have same shape 2591 while (Passenger.Shape = Passenger.Station.Shape) or2562 while (Passenger.Shape = Shape) or 2592 2563 not (Passenger.Shape in GetExistStationShapes) do 2593 2564 Passenger.Shape := TStationShape((Integer(Passenger.Shape) + 1) mod Integer(ShapeCount)); … … 2937 2908 Lines.Engine := Self; 2938 2909 Passengers := TMetroPassengers.Create; 2939 Passengers.Engine := Self;2940 2910 Map := TMap.Create; 2941 2911 View := TView.Create;
Note:
See TracChangeset
for help on using the changeset viewer.