public void Start() { //TODO Coroutine hide Core.Instance.GetService <UIManager>().ShowWindow(UIWindowEnum.SPLASH, false); ResetEarnedValues(); if (TryesCount > 2) { _gameWindow.timerText.text = ""; _playerCar.EnablePlayerControll(false); _enemyCar.carBase.EnableEnemyControll(false); _gameWindow.Show(); CalculateResults(); } else { var enemyName = (_playerManager.PlayerId == _gameData.player1_Id) ? (_gameData.player2_name) : (_gameData.player1_name); //_gameWindow.textInfoWindow("Racing versus " + enemyName); _gameWindow.ShowEnemyMeters(); _gameWindow.ActiveGold(); _gameWindow.Show(); _startTimer = Core.Instance.StartCor(StartTimer()); EventManager._init.Game.TrackEvent.GetEvent.Invoke_Start(); } }
protected IEnumerator StartTimer(IGameWindow gameWindow, Action OnComplete = null) { _audioService.StartGameMusic(); float seconds = 4; previousSecondCounter = seconds; Rigidbody _prb = null; if (_playerCar != null) { _prb = _playerCar.GetComponent <Rigidbody>(); } Rigidbody _erb = null; if (_ghostCar != null) { _erb = _ghostCar.GetComponent <Rigidbody>(); } gameWindow.Get_TimerText().GetComponent <CanvasGroup>().alpha = 1; while (seconds > 1) { gameWindow.Get_TimerText().text = (seconds - (seconds % 1)).ToString(); if (previousSecondCounter != (seconds - (seconds % 1)) && seconds != 4) { previousSecondCounter = (seconds - (seconds % 1)); _audioService.RM_PlayOneShot(audioCounterPath); } yield return(new WaitForEndOfFrame()); seconds -= Time.deltaTime; if (_prb != null) { _prb.velocity = new Vector3(0, _prb.velocity.y, _prb.velocity.z); } if (_erb != null) { _erb.velocity = new Vector3(0, _erb.velocity.y, _erb.velocity.z); } _playerCar.transform.position = new Vector3(_playerCar.transform.position.x, _playerCar.transform.position.y, 2); } gameWindow.Get_TimerText().GetComponent <CanvasGroup>().alpha = 0; _playerCar.EnablePlayerControll(true); if (_gameData.ghostData.Count > 0) { _ghostCar.EnableEnemyControll(true); } gameWindow.Get_PauseButton().interactable = true; // invoke callback if (OnComplete != null) { OnComplete(); } }