Exemple #1
0
        public void OnMatchStateChanged(MatchStateTransition transition)
        {
            switch (transition.newState)
            {
            case MatchState.WaitingToStart:
            case MatchState.GoalMade:
                ShowStatusText("Ready");
                break;

            case MatchState.Running:
                ShowStatusText("Start!", false, 0.5f);
                break;

            case MatchState.Ended:
                ShowStatusText(
                    System.Enum.GetName(typeof(PlayerID), transition.lastGoalPlayerID) + " WON",
                    true
                    );
                break;

            default:
                HideStatusText();
                break;
            }
        }
Exemple #2
0
 public void OnMatchStateChanged(MatchStateTransition transition)
 {
     if (transition.newState == MatchState.WaitingToStart)
     {
         // gameSettings is null only when the scene is ran directly from unity
         RightPlayerKeysPlaceholder.SetActive(gameSettings == null || gameSettings.RightPlayerType == PlayerType.Human);
         LeftPlayerKeysPlaceholder.SetActive(gameSettings == null || gameSettings.LeftPlayerType == PlayerType.Human);
     }
     else
     {
         RightPlayerKeysPlaceholder.SetActive(false);
         LeftPlayerKeysPlaceholder.SetActive(false);
     }
     if (transition.newState == MatchState.Ended)
     {
         for (int i = 0; i < endGameActions.Length; i++)
         {
             endGameActions[i].gameObject.SetActive(true);
         }
         EventSystem.current.SetSelectedGameObject(endGameActions[0].gameObject);
     }
     else
     {
         for (int i = 0; i < endGameActions.Length; i++)
         {
             endGameActions[i].gameObject.SetActive(false);
         }
         EventSystem.current.SetSelectedGameObject(null);
     }
 }
Exemple #3
0
 public void OnMatchStateChanged(MatchStateTransition transition)
 {
     enabled = transition.newState == MatchState.Running;
     if (transition.newState == MatchState.GoalMade || transition.newState == MatchState.Ended)
     {
         transform.position = new Vector3(transform.position.x, 0, transform.position.z);
     }
 }
Exemple #4
0
 void HighlightLastGoalScore(MatchStateTransition transition)
 {
     LeftMatchPointText.alpha = RightMatchPointText.alpha = 1;
     if (transition.lastGoalPlayerID == PlayerID.Left)
     {
         LeftScoreText.alpha = 1;
     }
     else
     {
         RightScoreText.alpha = 1;
     }
 }
Exemple #5
0
 public void OnMatchStateChanged(MatchStateTransition transition)
 {
     if (IsPauseState(transition.newState))
     {
         transform.localPosition = Vector3.zero;
         rb.velocity             = Vector2.zero;
     }
     else if (transition.newState == MatchState.Running)
     {
         Vector2 movementDirection = transition.lastGoalPlayerID.HasValue
             ? new Vector2(transition.lastGoalPlayerID.Value == PlayerID.Left ? 1 : -1, Random.Range(-1f, 1f))
             : new Vector2(Mathf.Sign(Random.Range(-1, 1)), Random.Range(-1f, 1f));
         currentMovementSpeed = startMovementSpeed;
         rb.velocity          = (currentMovementSpeed * 0.75f) * movementDirection.normalized;
     }
 }
Exemple #6
0
 void ShowMatchPoint(MatchStateTransition transition)
 {
     if (!transition.isMatchPoint)
     {
         HideMatchPoint();
     }
     else if (transition.leftScore > transition.rightScore)
     {
         LeftMatchPointText.gameObject.SetActive(true);
         RightMatchPointText.gameObject.SetActive(false);
     }
     else
     {
         LeftMatchPointText.gameObject.SetActive(false);
         RightMatchPointText.gameObject.SetActive(true);
     }
 }
Exemple #7
0
        public void OnMatchStateChanged(MatchStateTransition transition)
        {
            LeftScoreText.SetText(transition.leftScore.ToString());
            RightScoreText.SetText(transition.rightScore.ToString());
            ShowMatchPoint(transition);
            switch (transition.newState)
            {
            case MatchState.GoalMade:
                HighlightLastGoalScore(transition);
                break;

            case MatchState.Ended:
                HighlightScores();
                HideMatchPoint();
                break;

            default:
                ResetHighlight();
                break;
            }
        }