/// <inheritdoc />
 /// <summary>
 /// </summary>
 public void CloseState()
 {
     exitListener.OnExitClicked -= OnExit;
     exitListener.Disable();
     menuActivator.CloseMenu();
     playStateType = StateType.START_GAME_STATE;
     resultType    = UserResultType.NONE;
 }
 /// <summary>
 /// Determines the winner if some user lefts the game.
 /// </summary>
 /// <param name="leftParticipantId"> The id of user who has left.
 /// If it is an empty string, consider that we have left. </param>
 private void ProcessPlayerLeft(string leftParticipantId)
 {
     if (myId == leftParticipantId || leftParticipantId == "")
     {
         //We have left, so we loose.
         currentUserResultType = UserResultType.LOSE;
     }
     else
     {
         //Another user left, so we win.
         currentUserResultType = UserResultType.WIN;
         multiplayerController.LeaveRoom();
     }
     CloseGame();
 }
Esempio n. 3
0
 /// <summary>
 /// Starts displaying the string with the game result and saves it for further processing.
 /// </summary>
 public override void OnFinishGame(ResultType resultType)
 {
     base.OnFinishGame(resultType);
     if (resultType == ResultType.FIRST_WIN)
     {
         //User wins
         lerpedText.PerformLerpString(userWinText, Color.green);
         this.resultType = UserResultType.WIN;
     }
     else if (resultType == ResultType.SECOND_WIN)
     {
         //Bot wins
         lerpedText.PerformLerpString(aiWinText, Color.red);
         this.resultType = UserResultType.LOSE;
     }
     else if (resultType == ResultType.DRAW)
     {
         lerpedText.PerformLerpString(drawText, Color.blue);
         this.resultType = UserResultType.DRAW;
     }
 }
        /// <inheritdoc />
        /// <summary>
        /// Displays an appropriate text to the user.
        /// </summary>
        public override void OnFinishGame(ResultType resultType)
        {
            base.OnFinishGame(resultType);

            if (resultType == ResultType.FIRST_WIN)
            {
                if (isHost)
                {
                    //We are the host (the first), so we win.
                    lerpedText.PerformLerpString(userWinString, Color.green);
                    currentUserResultType = UserResultType.WIN;
                }
                else
                {
                    //We are not the host (the second), so we lose.
                    lerpedText.PerformLerpString(userLoseString, Color.red);
                    currentUserResultType = UserResultType.LOSE;
                }
            }
            else if (resultType == ResultType.SECOND_WIN)
            {
                if (!isHost)
                {
                    //We are not the host (the first), so we win.
                    lerpedText.PerformLerpString(userWinString, Color.green);
                    currentUserResultType = UserResultType.WIN;
                }
                else
                {
                    //We are host (the first), so we lose.
                    lerpedText.PerformLerpString(userLoseString, Color.red);
                    currentUserResultType = UserResultType.LOSE;
                }
            }
            else if (resultType == ResultType.DRAW)
            {
                lerpedText.PerformLerpString(drawString, Color.blue);
                currentUserResultType = UserResultType.DRAW;
            }
        }
 /// <summary>
 /// Updates the text on the top of the menu depending on the result for the user.
 /// </summary>
 private void UpdateResultText(UserResultType resultType)
 {
     //TODO: maybe better to make colors and strings serialized to setup in the editor?
     if (resultType == UserResultType.WIN)
     {
         resultText.color = Color.green;
         resultText.text  = "You win!";
     }
     else if (resultType == UserResultType.LOSE)
     {
         resultText.color = Color.red;
         resultText.text  = "You lose!";
     }
     else if (resultType == UserResultType.DRAW)
     {
         resultText.color = Color.black;
         resultText.text  = "Draw";
     }
     else
     {
         resultText.color = Color.black;
         resultText.text  = "Statistics";
     }
 }
 /// <summary>
 /// Updates the text on the top of the menu depending on the result for the user.
 /// </summary>
 private void UpdateResultText(UserResultType resultType)
 {
     //TODO: maybe better to make colors serialized to setup in the editor?
     if (resultType == UserResultType.WIN)
     {
         resultText.color = Color.green;
         resultText.text  = winResultString;
     }
     else if (resultType == UserResultType.LOSE)
     {
         resultText.color = Color.red;
         resultText.text  = loseResultString;
     }
     else if (resultType == UserResultType.DRAW)
     {
         resultText.color = Color.black;
         resultText.text  = drawResultString;
     }
     else
     {
         resultText.color = Color.black;
         resultText.text  = defaultTitleString;
     }
 }
Esempio n. 7
0
 public UserResult(UserResultType userState, ApplicationUser u, string msg, BusinessResultType state)
     : base(u, msg, state)
 {
     UserState = userState;
 }
 /// <summary>
 /// Displays the given statistics.
 /// </summary>
 /// <param name="resultType">Result type for the title.</param>
 public void DisplayStatistics(Record record, UserResultType resultType)
 {
     UpdateResultText(resultType);
     UpdateStatisticLabels(record);
 }
 /// <summary>
 /// Must be called by PlayGameState.
 /// </summary>
 public void Initialize(UserResultType resultType, StateType playStateType)
 {
     this.resultType    = resultType;
     this.playStateType = playStateType;
 }