Changeset 24


Ignore:
Timestamp:
Apr 9, 2015, 11:58:38 PM (10 years ago)
Author:
chronos
Message:
  • Added: Passenger max count at map station overload signalization using pie graphic. If overload last too long then game over is set.
Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/BigMetro.lpi

    r23 r24  
    9090        <Filename Value="UGeometric.pas"/>
    9191        <IsPartOfProject Value="True"/>
     92        <UnitName Value="UGeometric"/>
    9293      </Unit3>
    9394    </Units>
     
    118119        <StackChecks Value="True"/>
    119120      </Checks>
     121      <VerifyObjMethodCallValidity Value="True"/>
    120122    </CodeGeneration>
    121123    <Linking>
  • trunk/UEngine.pas

    r23 r24  
    3131    Lines: TMetroLines;
    3232    ShapeDistance: array[TStationShape] of Integer;
     33    OverloadDuration: TDateTime;
    3334    function IsBestStationForShape(Shape: TStationShape; Check, Current: TLineStation): Boolean;
    3435    constructor Create;
     
    174175    ImageLocomotive: TImage;
    175176    FTime: TDateTime;
     177    FLastTime: TDateTime;
    176178    function GetExistStationShapes: TStationShapeSet;
    177179    function GetStationOnPos(Pos: TPoint): TMapStation;
     
    218220    clPurple, clGray, clOrange, clBrown);
    219221  StationSize = 30;
     222  StationOverloadSize = 60;
    220223  PassengerSize = 15;
    221224  TrainSize = 40;
     
    228231  StationMaxDistance = 300;
    229232  MaxWaitingPassengers = 10;
     233  MaxPassengersOveloadTime = 1;
    230234  MetroLineThickness = 13;
    231235  TrackClickDistance = 20;
     
    11711175      while (Passenger.Shape = Passenger.Station.Shape) or not (Passenger.Shape in GetExistStationShapes) do
    11721176        Passenger.Shape := TStationShape((Integer(Passenger.Shape) + 1) mod Integer(ShapeCount));
     1177
     1178    end;
     1179  end;
     1180
     1181  for I := 0 to Stations.Count - 1 do
     1182  with TMapStation(Stations[I]) do begin
     1183    if Passengers.Count > MaxWaitingPassengers then begin
     1184      OverloadDuration := OverloadDuration + (FTime - FLastTime);
     1185      if OverloadDuration > MaxPassengersOveloadTime then
     1186        OverloadDuration := MaxPassengersOveloadTime;
     1187    end;
     1188    if Passengers.Count <= MaxWaitingPassengers then begin
     1189      OverloadDuration := OverloadDuration - (FTime - FLastTime);
     1190      if OverloadDuration < 0 then begin
     1191        OverloadDuration := 0;
     1192      end;
    11731193    end;
    11741194  end;
     
    11791199  for I := 0 to Stations.Count - 1 do
    11801200  with TMapStation(Stations[I]) do begin
    1181     if Passengers.Count > MaxWaitingPassengers then State := gsGameOver;
     1201    if OverloadDuration >= MaxPassengersOveloadTime then State := gsGameOver;
    11821202  end;
    11831203
    11841204  end;
    11851205  LastTickTime := Now;
     1206  FLastTime := FTime;
    11861207end;
    11871208
     
    13461367  SelectedLine := nil;
    13471368  FTime := 0;
     1369  FLastTime := 0;
    13481370  LastNewStationTime := Time;
    13491371  LastNewPassengerTime := Time;
     
    14041426  Canvas.Brush.Style := bsSolid;
    14051427  Canvas.Clear;
     1428
     1429  // Draw station passenger overload
     1430  for I := 0 to Stations.Count - 1 do
     1431  with TMapStation(Stations[I]) do begin
     1432    if OverloadDuration > 0 then begin
     1433      Canvas.Brush.Color := clSilver;
     1434      Canvas.Brush.Style := bsSolid;
     1435      Canvas.Pen.Color := clSilver;
     1436      Canvas.Pen.Style := psSolid;
     1437      Angle := OverloadDuration / MaxPassengersOveloadTime * 2 * Pi;
     1438      Canvas.Pie(Position.X - StationOverloadSize, Position.Y - StationOverloadSize,
     1439      Position.X + StationOverloadSize, Position.Y + StationOverloadSize,
     1440        Trunc(Position.X + StationOverloadSize * Cos(Angle)),
     1441        Trunc(Position.Y + StationOverloadSize * Sin(Angle)), Position.X + StationOverloadSize, Position.Y);
     1442    end;
     1443  end;
    14061444
    14071445  // Draw lines
     
    14691507      DrawShape(Canvas, Position, Shape, StationSize + Canvas.Pen.Width + 6, 0);
    14701508    end;
     1509
    14711510    Canvas.Brush.Color := clWhite;
    14721511    Canvas.Brush.Style := bsSolid;
Note: See TracChangeset for help on using the changeset viewer.