void FixedUpdate() { if (_isPaused) { _currentStickSoundRemainingTime -= Time.fixedDeltaTime; if (_currentStickSoundRemainingTime <= 0) { _currentStickSoundRemainingTime = StickSoundDelay; _player.PlayAudioById("tramdoorstuck"); } if (_currentStickPassenger == null) { _currentStickPassenger = GameController.GetInstance().GetStickPassenger(); if (_currentStickPassenger != null) { _currentStickDoor = MonobehaviorHandler.GetMonobeharior().GetObject <Floor>("Floor").GetPassengerDoor(_currentStickPassenger) .GetComponent <DoorsAnimationController>(); } } if (_currentStickDoor != null) { _currentStickDoor.Glitch(); } return; } if (_isDoorsOpen) { _currentStopDuration += Time.fixedDeltaTime; if (_currentStopDuration > _stopDuration) { _isDoorsOpen = false; _currentStopDuration = 0; UpdateDoors(); } } else { if (!_isMovementTimeLocked) { _currentMoveDuration += Time.fixedDeltaTime; } if (_currentMoveDuration > _currentStationTotalMoveDuration) { _isDoorsOpen = true; _currentMoveDuration = 0; GameController.GetInstance().CheckBeforeDoorsOpen(); UpdateDoors(); GameController.GetInstance().IncrementStationNumberForPassengers(); if (_countToFinish > 0) { _countToFinish--; if (_countToFinish == 0) { MonobehaviorHandler.GetMonobeharior() .GetObject <TrainingHandler>("TrainingHandler").ShowNext(); } } } } }
public void IncrementStationCount() { _currentTramStopCount++; if (_currentTramStopCount > _tramStopCount && !IsGoingAway) { DoorsAnimationController door1 = MonobehaviorHandler.GetMonobeharior().GetObject <DoorsAnimationController>("door1"); DoorsAnimationController door2 = MonobehaviorHandler.GetMonobeharior().GetObject <DoorsAnimationController>("door2"); DoorsAnimationController door3 = MonobehaviorHandler.GetMonobeharior().GetObject <DoorsAnimationController>("door3"); DoorsAnimationController door4 = MonobehaviorHandler.GetMonobeharior().GetObject <DoorsAnimationController>("door4"); List <DoorsAnimationController> selected = new List <DoorsAnimationController>(); if (door1.IsOpened()) { selected.Add(door1); } if (door2.IsOpened()) { selected.Add(door2); } if (door3.IsOpened()) { selected.Add(door3); } if (door4.IsOpened()) { selected.Add(door4); } if (selected.Count == 0) { return; } int randomPercent = Randomizer.GetRandomPercent(); int step = 100 / selected.Count; int currentStep = 0; int i = 0; for (i = 0; i < selected.Count - 1; i++) { if (currentStep > randomPercent) { break; } currentStep += step; } BoxCollider2D collider = selected[i].GetComponent <BoxCollider2D>(); Vector2 target = new Vector2(selected[i].gameObject.transform.position.x, selected[i].gameObject.transform.position.y) + collider.offset; Velocity *= 2; if (_isGoAwayVelocityIncreased) { Velocity *= 2; } IsGoingAway = true; base.SetTarget(target); } }
void FixedUpdate () { if (_isPaused) { _currentStickSoundRemainingTime -= Time.fixedDeltaTime; if (_currentStickSoundRemainingTime <= 0) { _currentStickSoundRemainingTime = StickSoundDelay; _player.PlayAudioById("tramdoorstuck"); } if (_currentStickPassenger == null) { _currentStickPassenger = GameController.GetInstance().GetStickPassenger(); if (_currentStickPassenger != null) { _currentStickDoor = MonobehaviorHandler.GetMonobeharior().GetObject<Floor>("Floor").GetPassengerDoor(_currentStickPassenger) .GetComponent<DoorsAnimationController>(); } } if(_currentStickDoor != null) _currentStickDoor.Glitch(); return; } if (_isDoorsOpen) { _currentStopDuration += Time.fixedDeltaTime; if (_currentStopDuration > _stopDuration) { _isDoorsOpen = false; _currentStopDuration = 0; UpdateDoors(); } } else { if(!_isMovementTimeLocked) _currentMoveDuration += Time.fixedDeltaTime; if (_currentMoveDuration > _currentStationTotalMoveDuration) { _isDoorsOpen = true; _currentMoveDuration = 0; GameController.GetInstance().CheckBeforeDoorsOpen(); UpdateDoors(); GameController.GetInstance().IncrementStationNumberForPassengers(); if (_countToFinish > 0) { _countToFinish--; if (_countToFinish == 0) { MonobehaviorHandler.GetMonobeharior() .GetObject<TrainingHandler>("TrainingHandler").ShowNext(); } } } } }