@@ -132,6 +132,11 @@ public static readonly (int Min, int Max) BarrierSideLengthRange = (
132132
133133 #region Parameters related to the charging piles.
134134
135+ /// <summary>
136+ /// The max number of charging piles of a camp.
137+ /// </summary>
138+ public const int ChargingPileMaxNumber = 3 ;
139+
135140 /// <summary>
136141 /// The increasing rate of the max distances of vehicles in the influence
137142 /// scope of their own charging piles in centimeter per second.
@@ -168,7 +173,7 @@ public static readonly (int Min, int Max) BarrierSideLengthRange = (
168173 /// The range of the delivery durations of orders.
169174 /// </summary>
170175 public static readonly ( long Min , long Max ) OrderDeliveryDurationRange = (
171- 20 , 60
176+ 20000 , 60000
172177 ) ;
173178
174179 /// <summary>
@@ -594,6 +599,26 @@ public void SetChargingPile()
594599 return ;
595600 }
596601
602+ // Avoid setting too many charging piles.
603+ int chargingPileNumber = 0 ;
604+ foreach ( var chargingPile in this . _chargingPileList )
605+ {
606+ if ( chargingPile . Camp == this . _camp )
607+ {
608+ ++ chargingPileNumber ;
609+ }
610+ }
611+ if ( chargingPileNumber > Game . ChargingPileMaxNumber )
612+ {
613+ return ;
614+ }
615+
616+ // Can only set charging piles in the first half.
617+ if ( this . _gameStage != GameStageType . FirstHalf )
618+ {
619+ return ;
620+ }
621+
597622 this . _chargingPileList . Add ( new ChargingPile (
598623 ( CampType ) this . _camp ,
599624 ( Dot ) this . _vehicle [ ( CampType ) this . _camp ] . Position ,
@@ -859,57 +884,54 @@ void TakeAndDeliverOrder()
859884
860885 var vehiclePosition = ( Dot ) vehicle . Position ;
861886
862- // The vehicle should park there for at least 0ms.
863- if ( vehicle . ParkingDuration >= 0 )
887+
888+ // Count the orders in delivery.
889+ var deliveringOrderNumber = 0 ;
890+ foreach ( var order in this . _orderList )
864891 {
865- // Count the orders in delivery.
866- var deliveringOrderNumber = 0 ;
867- foreach ( var order in this . _orderList )
892+ if ( order . Status == OrderStatusType . InDelivery )
868893 {
869- if ( order . Status == OrderStatusType . InDelivery )
870- {
871- ++ deliveringOrderNumber ;
872- }
894+ ++ deliveringOrderNumber ;
873895 }
896+ }
874897
875- foreach ( var order in this . _orderList )
898+ foreach ( var order in this . _orderList )
899+ {
900+ // Take orders.
901+ if ( order . Status == OrderStatusType . Pending )
876902 {
877- // Take orders .
878- if ( order . Status == OrderStatusType . Pending )
903+ // Check if the capacity is full .
904+ if ( deliveringOrderNumber > Game . OrderDeliveryCapacity )
879905 {
880- // Check if the capacity is full.
881- if ( deliveringOrderNumber > Game . OrderDeliveryCapacity )
882- {
883- continue ;
884- }
906+ continue ;
907+ }
885908
886- if ( ( decimal ) Dot . Distance ( order . DeparturePosition , vehiclePosition )
887- <= Game . OrderContactScopeRadius )
888- {
889- order . Take ( ( long ) this . GameTime ) ;
909+ if ( ( decimal ) Dot . Distance ( order . DeparturePosition , vehiclePosition )
910+ <= Game . OrderContactScopeRadius )
911+ {
912+ order . Take ( ( long ) this . GameTime ) ;
890913
891- // Play the take sound.
892- Game . OrderSoundTake . Play ( ) ;
893- }
914+ // Play the take sound.
915+ Game . OrderSoundTake . Play ( ) ;
894916 }
895- else if ( order . Status == OrderStatusType . InDelivery )
917+ }
918+ else if ( order . Status == OrderStatusType . InDelivery )
919+ {
920+ if ( ( decimal ) Dot . Distance ( order . DestinationPosition , vehiclePosition )
921+ <= Game . OrderContactScopeRadius )
896922 {
897- if ( ( decimal ) Dot . Distance ( order . DestinationPosition , vehiclePosition )
898- <= Game . OrderContactScopeRadius )
899- {
900- order . Deliver ( ( long ) this . GameTime ) ;
923+ order . Deliver ( ( long ) this . GameTime ) ;
901924
902- if ( order . OvertimeDuration == null )
903- {
904- throw new Exception ( "The overtime duration of the order is null." ) ;
905- }
925+ if ( order . OvertimeDuration == null )
926+ {
927+ throw new Exception ( "The overtime duration of the order is null." ) ;
928+ }
906929
907- this . _score [ ( CampType ) this . _camp ] +=
908- Math . Max ( order . Commission + Game . ScoreDeliveryOvertimeRate * ( long ) order . OvertimeDuration , 0 ) ;
930+ this . _score [ ( CampType ) this . _camp ] +=
931+ Math . Max ( order . Commission + Game . ScoreDeliveryOvertimeRate * ( long ) order . OvertimeDuration , 0 ) ;
909932
910- // Player the deliver sound.
911- Game . OrderSoundDeliver . Play ( ) ;
912- }
933+ // Player the deliver sound.
934+ Game . OrderSoundDeliver . Play ( ) ;
913935 }
914936 }
915937 }
0 commit comments