@@ -43,7 +43,7 @@ public class Game
4343 /// The score obtained when a vehicle is hitting a wall
4444 /// per millisecond.
4545 /// </summary>
46- public const decimal ScoreHittingWallRate = - 0.1M ;
46+ public const decimal ScoreHittingWallRate = - 0.01M ;
4747
4848 /// <summary>
4949 /// The score obtained when the vehicle park overtime per
@@ -187,24 +187,43 @@ public static readonly (long Min, long Max) OrderDeliveryDurationRange = (
187187 { GameStageType . PreMatch , null }
188188 } ;
189189
190- /// <summary>
191- /// The sound to play when delivering an order.
192- /// </summary>
193- public static readonly SoundPlayer OrderSoundDeliver = new SoundPlayer (
190+ private static readonly SoundPlayer _soundDeliverOrder = new SoundPlayer (
194191 @"Assets/Sounds/Deliver.wav"
195192 ) ;
196193
197- /// <summary>
198- /// The sound to play when taking an order.
199- /// </summary>
200- public static readonly SoundPlayer OrderSoundTake = new SoundPlayer (
194+ private static readonly SoundPlayer _soundTakeOrder = new SoundPlayer (
201195 @"Assets/Sounds/Order.wav"
202196 ) ;
203197
198+ private static readonly SoundPlayer _soundNotMoving = new SoundPlayer (
199+ @"Assets/Sounds/NotMoving.wav"
200+ ) ;
201+ private static bool _isSoundNotMovingPlaying = false ;
202+
203+ private static readonly SoundPlayer _soundInBarrier = new SoundPlayer (
204+ @"Assets/Sounds/InBarrier.wav"
205+ ) ;
206+ private static bool _isSoundInBarrierPlaying = false ;
207+
208+ private static readonly SoundPlayer _soundCharging = new SoundPlayer (
209+ @"Assets/Sounds/Charging.wav"
210+ ) ;
211+ private static bool _isSoundChargingPlaying = false ;
212+
213+ private static readonly SoundPlayer _soundDischarging = new SoundPlayer (
214+ @"Assets/Sounds/InBarrier.wav"
215+ ) ;
216+ private static bool _isSoundDischargingPlaying = false ;
217+
218+ private static readonly SoundPlayer _soundAutoCharge = new SoundPlayer (
219+ @"Assets/Sounds/AutoCharge.wav"
220+ ) ;
204221
205- public static readonly SoundPlayer SetChargingPileSound = new SoundPlayer (
222+ private static readonly SoundPlayer _soundSetChargingPile = new SoundPlayer (
206223 @"Assets/Sounds/SetChargingPile.wav"
207224 ) ;
225+
226+
208227 #endregion
209228
210229 #region Parameters related to vehicles
@@ -378,9 +397,14 @@ public long? RemainingTime
378397 public Game ( )
379398 {
380399 // Load sounds
381- Game . OrderSoundDeliver . Load ( ) ;
382- Game . OrderSoundTake . Load ( ) ;
383- Game . SetChargingPileSound . Load ( ) ;
400+ Game . _soundAutoCharge . Load ( ) ;
401+ Game . _soundCharging . Load ( ) ;
402+ Game . _soundDeliverOrder . Load ( ) ;
403+ Game . _soundDischarging . Load ( ) ;
404+ Game . _soundInBarrier . Load ( ) ;
405+ Game . _soundNotMoving . Load ( ) ;
406+ Game . _soundSetChargingPile . Load ( ) ;
407+ Game . _soundTakeOrder . Load ( ) ;
384408
385409 // Generate barriers
386410 this . _barrierList = new List < Barrier > ( ) ;
@@ -594,6 +618,15 @@ public void End()
594618 throw new Exception ( "The game is not running or paused." ) ;
595619 }
596620
621+ Game . _soundDeliverOrder . Stop ( ) ;
622+ Game . _soundTakeOrder . Stop ( ) ;
623+ Game . _soundNotMoving . Stop ( ) ;
624+ Game . _soundInBarrier . Stop ( ) ;
625+ Game . _soundCharging . Stop ( ) ;
626+ Game . _soundDischarging . Stop ( ) ;
627+ Game . _soundAutoCharge . Stop ( ) ;
628+ Game . _soundSetChargingPile . Stop ( ) ;
629+
597630 this . _gameState = GameStatusType . Ended ;
598631 }
599632
@@ -640,7 +673,7 @@ public void SetChargingPile()
640673
641674 this . _score [ ( CampType ) this . _camp ] += Game . ScoreSetChargingPile ;
642675
643- Game . SetChargingPileSound . Play ( ) ;
676+ Game . _soundSetChargingPile . Play ( ) ;
644677 }
645678
646679 #endregion
@@ -661,6 +694,8 @@ private void AutoCharge()
661694
662695 if ( vehicle . IsPowerExhausted )
663696 {
697+ Game . _soundAutoCharge . Play ( ) ;
698+
664699 // Exchange time for power.
665700 this . _startTime -= Game . VehicleAutoChargingStep ;
666701 vehicle . IncreaseMaxDistance (
@@ -822,9 +857,23 @@ void ScoreMoving()
822857 ( long ) vehicle . ParkingDuration >= 5000 + this . LastTickDuration
823858 )
824859 {
860+ if ( ! Game . _isSoundNotMovingPlaying )
861+ {
862+ Game . _isSoundNotMovingPlaying = true ;
863+ Game . _soundNotMoving . PlayLooping ( ) ;
864+ }
865+
825866 this . _score [ ( CampType ) this . _camp ] +=
826867 Game . ScoreOvertimeParkingRate * this . LastTickDuration ;
827868 }
869+ else
870+ {
871+ if ( Game . _isSoundNotMovingPlaying )
872+ {
873+ Game . _isSoundNotMovingPlaying = false ;
874+ Game . _soundNotMoving . Stop ( ) ;
875+ }
876+ }
828877 }
829878
830879 /// <summary>
@@ -843,10 +892,24 @@ void TackleBarriers()
843892
844893 if ( this . IsInBarrier ( vehiclePosition ) )
845894 {
895+ if ( ! Game . _isSoundInBarrierPlaying )
896+ {
897+ Game . _isSoundInBarrierPlaying = true ;
898+ Game . _soundInBarrier . PlayLooping ( ) ;
899+ }
900+
846901 vehicle . IncreaseMaxDistance (
847902 ( int ) Math . Round ( Game . BarrierDischargingRate * this . LastTickDuration )
848903 ) ;
849904 }
905+ else
906+ {
907+ if ( Game . _isSoundInBarrierPlaying )
908+ {
909+ Game . _isSoundInBarrierPlaying = false ;
910+ Game . _soundInBarrier . Stop ( ) ;
911+ }
912+ }
850913 }
851914
852915 /// <summary>
@@ -873,21 +936,49 @@ void TackleChargingPiles()
873936 camp : ( CampType ) this . _camp
874937 ) )
875938 {
939+ if ( ! Game . _isSoundChargingPlaying )
940+ {
941+ Game . _isSoundChargingPlaying = true ;
942+ Game . _soundCharging . PlayLooping ( ) ;
943+ }
944+
876945 vehicle . IncreaseMaxDistance (
877946 ( int ) Math . Round ( Game . ChargingPileChargingRate * this . LastTickDuration )
878947 ) ;
879948 }
949+ else
950+ {
951+ if ( Game . _isSoundChargingPlaying )
952+ {
953+ Game . _isSoundChargingPlaying = false ;
954+ Game . _soundCharging . Stop ( ) ;
955+ }
956+ }
880957
881958 if ( this . IsInChargingPileInfluenceScope (
882959 position : vehiclePosition ,
883960 camp : ( CampType ) this . _camp ,
884961 reverse : true
885962 ) )
886963 {
964+ if ( ! Game . _isSoundDischargingPlaying )
965+ {
966+ Game . _isSoundDischargingPlaying = true ;
967+ Game . _soundDischarging . PlayLooping ( ) ;
968+ }
969+
887970 vehicle . IncreaseMaxDistance (
888971 ( int ) Math . Round ( Game . ChargingPileDischargingRate * this . LastTickDuration )
889972 ) ;
890973 }
974+ else
975+ {
976+ if ( Game . _isSoundDischargingPlaying )
977+ {
978+ Game . _isSoundDischargingPlaying = false ;
979+ Game . _soundDischarging . Stop ( ) ;
980+ }
981+ }
891982 }
892983
893984 /// <summary>
@@ -932,7 +1023,7 @@ void TakeAndDeliverOrder()
9321023 order . Take ( ( long ) this . GameTime ) ;
9331024
9341025 // Play the take sound.
935- Game . OrderSoundTake . Play ( ) ;
1026+ Game . _soundTakeOrder . Play ( ) ;
9361027 }
9371028 }
9381029 else if ( order . Status == OrderStatusType . InDelivery )
@@ -951,7 +1042,7 @@ void TakeAndDeliverOrder()
9511042 Math . Max ( ( decimal ) order . Commission + Game . ScoreDeliveryOvertimeRate * ( long ) order . OvertimeDuration , 0 ) ;
9521043
9531044 // Player the deliver sound.
954- Game . OrderSoundDeliver . Play ( ) ;
1045+ Game . _soundDeliverOrder . Play ( ) ;
9551046 }
9561047 }
9571048 }
0 commit comments