Changeset 89 for trunk


Ignore:
Timestamp:
Sep 22, 2022, 9:37:46 PM (2 years ago)
Author:
chronos
Message:
  • Modified: Move TMetroPassenger unit into separate unit.
Location:
trunk
Files:
1 added
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/BigMetro.lpi

    r86 r89  
    8989      </Item2>
    9090    </RequiredPackages>
    91     <Units Count="7">
     91    <Units Count="8">
    9292      <Unit0>
    9393        <Filename Value="BigMetro.lpr"/>
     
    124124        <IsPartOfProject Value="True"/>
    125125      </Unit6>
     126      <Unit7>
     127        <Filename Value="UMetroPassenger.pas"/>
     128        <IsPartOfProject Value="True"/>
     129      </Unit7>
    126130    </Units>
    127131  </ProjectOptions>
  • trunk/BigMetro.lpr

    r64 r89  
    88  {$ENDIF}
    99  Interfaces, // this includes the LCL widgetset
    10   Forms, SysUtils, UFormMain, UFormImages, Common, UMenu, UControls;
     10  Forms, SysUtils, UFormMain, UFormImages, Common, UMenu, UControls,
     11UMetroPassenger;
    1112
    1213{$R *.res}
  • trunk/UEngine.pas

    r86 r89  
    88  {$IFDEF DARWIN}MacOSAll, CocoaAll, CocoaUtils,{$ENDIF}
    99  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;
    1112
    1213type
    13   TStationShape = (ssCircle, ssSquare, ssTriangle, ssStar, ssPlus, ssPentagon,
    14     ssDiamond, ssQuarterCircle, ssHexagon, ssCross, ssHalfCircle, ssHeptagon);
    1514  TStationShapeSet = set of TStationShape;
    1615  TEngine = class;
    17   TMetroPassengers = class;
    1816  TMetroLines = class;
    1917  TMetroLine = class;
     
    228226    function GetUnusedCount: Integer;
    229227    function AddNew: TMetroTrain;
    230   end;
    231 
    232   TMetroPassenger = class
    233     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;
    244228  end;
    245229
     
    775759end;
    776760
    777 { TMetroPassengers }
    778 
    779 function TMetroPassengers.AddNew: TMetroPassenger;
    780 begin
    781   Result := TMetroPassenger.Create;
    782   Result.Engine := Engine;
    783   Result.Shape := TStationShape(Random(Integer(Engine.ShapeCount)));
    784   Add(Result);
    785 end;
    786 
    787761{ TMetroTrains }
    788762
     
    17561730  // Move trains
    17571731  for I := 0 to Trains.Count - 1 do
    1758   with Trains[I] do begin
     1732  with TMetroTrain(Trains[I]) do begin
    17591733    if not Assigned(TargetStation) and Assigned(BaseTrackPoint) then begin
    17601734      if (Direction <> 1) and (Direction <> -1) then Direction := 1
     
    18141788              Passengers.Delete(P);
    18151789              CurrentStation.MapStation.Passengers.Add(Passenger);
    1816               Passenger.Station := CurrentStation.MapStation;
    18171790            end;
    18181791          end;
     
    18261799              Passenger := CurrentStation.MapStation.Passengers[P];
    18271800              if CurrentStation.MapStation.IsBestStationForShape(Passenger.Shape,
    1828             TargetStation, CurrentStation) then begin
    1829                 Passenger.Station := nil;
     1801              TargetStation, CurrentStation) then begin
    18301802                CurrentStation.MapStation.Passengers.Delete(P);
    18311803                Passengers.Add(Passenger);
    1832                 Passenger.Train := Trains[I];
    18331804              end;
    18341805            end else Break; // No more space
     
    25852556    if Random < NewPassengerProbability then begin
    25862557      Passenger := Self.Passengers.AddNew;
    2587       Passenger.Station := MapStation;
     2558      Passenger.Shape := TStationShape(Random(Integer(ShapeCount)));
    25882559      Passengers.Add(Passenger);
    25892560
    25902561      // Passenger is not allowed to have same shape
    2591       while (Passenger.Shape = Passenger.Station.Shape) or
     2562      while (Passenger.Shape = Shape) or
    25922563      not (Passenger.Shape in GetExistStationShapes) do
    25932564        Passenger.Shape := TStationShape((Integer(Passenger.Shape) + 1) mod Integer(ShapeCount));
     
    29372908  Lines.Engine := Self;
    29382909  Passengers := TMetroPassengers.Create;
    2939   Passengers.Engine := Self;
    29402910  Map := TMap.Create;
    29412911  View := TView.Create;
Note: See TracChangeset for help on using the changeset viewer.