/// <summary> /// Player state change . /// </summary> /// <param name="sender"></param> /// <param name="eventArgs"></param> private void PlayerStatusChange(object sender, PlayerStateChangeEventArgs eventArgs) { //Check player have failed. if (eventArgs.PreviousState == PlayerState.Fallen) { //But it want to restart. if (eventArgs.NextPlayerState == PlayerState.Idle) { //If not already started. if (!_obstacleCreationStarted) { StartObstacleCreate(); } return; } } if (eventArgs.NextPlayerState == PlayerState.Fallen) { //stop the routine StopCoroutine(_obstacleCoRoutine); //reset. _obstacleCreationStarted = false; } else { //If not already started. if (!_obstacleCreationStarted) { StartObstacleCreate(); } } }
/// <summary> /// On status change . /// </summary> private void PlayerStatusChange(object sender, PlayerStateChangeEventArgs eventArgs) { if (eventArgs.NextPlayerState == PlayerState.Fallen) { //no more update. _updateScore = false; if (_startScore > HighestScore) { HighestScore = (int)_startScore; } //Activate. highestScoreObject.SetActive(true); //set up. highestScoreText.text = HighestScore.ToString(); } //Restart Condition. else if (eventArgs.PreviousState == PlayerState.Fallen && eventArgs.NextPlayerState == PlayerState.Idle) { //Deactivate the highest score. highestScoreObject.SetActive(false); //reset start score. _startScore = 0; //Start updating score . _updateScore = true; } }
/// <summary> /// Player state changed. /// </summary> /// <param name="sender"></param> /// <param name="eventArgs"></param> private void PlayerStatusChange(object sender, PlayerStateChangeEventArgs eventArgs) { //fall condition. if (eventArgs.NextPlayerState == PlayerState.Fallen) { retryButton.gameObject.SetActive(true); } //Restart Condition. else if (eventArgs.PreviousState == PlayerState.Fallen && eventArgs.NextPlayerState == PlayerState.Idle) { retryButton.gameObject.SetActive(false); } }
/// <summary> /// Player event. /// </summary> /// <param name="sender"></param> /// <param name="eventArgs"></param> private void PlayerStatusChange(object sender, PlayerStateChangeEventArgs eventArgs) { if (eventArgs.NextPlayerState == PlayerState.Fallen) { //hold previous speed. _lastScrollSpeed = scrollSpeed; //set to zero. scrollSpeed = 0f; } else if (eventArgs.PreviousState == PlayerState.Fallen && eventArgs.NextPlayerState == PlayerState.Idle) { //Start over. scrollSpeed = _lastScrollSpeed; } }
/// <summary> /// Player state change . /// </summary> /// <param name="sender"></param> /// <param name="eventArgs"></param> private void PlayerStatusChange(object sender, PlayerStateChangeEventArgs eventArgs) { //if fallen. if (eventArgs.NextPlayerState == PlayerState.Fallen) { if (_rigidBody != null) { _rigidBody.velocity = Vector2.zero; } } //Restart Condition. else if (eventArgs.PreviousState == PlayerState.Fallen && eventArgs.NextPlayerState == PlayerState.Idle) { if (_rigidBody != null) { _rigidBody.velocity = Vector2.left * speed; } } }