ScoreSystem.updateValue C# (CSharp) Method

updateValue() public method

public updateValue ( int amountIncrease, int playerIndex ) : void
amountIncrease int
playerIndex int
return void
    public void updateValue(int amountIncrease, int playerIndex)
    {
        scoreSystem[playerIndex].playerScore += amountIncrease;
        for (int i = 0; i < scoreSystem.Length; i++)
        {
            if (scoreSystem[i].player == null)
            {
                break;
            }
            if (scoreSystem[i].playerTxt[playerIndex] != null)
            {
                scoreSystem[i].playerTxt[playerIndex].text = "Player " + (playerIndex + 1) + " " + scoreSystem[playerIndex].playerScore;;
            }
            else
            {
                break;
            }
        }

        //Added a print statement for end game condition ~ Sean
        //		if(scoreSystem[playerIndex].playerScore >= 80)
        //		{
        //			print ("Player: " + (playerIndex + 1) + " has won the game");
        //			gameEndText.text = "Player: " + (playerIndex + 1) + " has won the game";
        //			StartCoroutine(restartWorld());
        //		}

        Rpc_updateClientValue(scoreSystem[playerIndex].playerScore, playerIndex);
    }

Usage Example

Esempio n. 1
0
 public void Cmd_increaseScore(int amount)
 {
     scoreSystem.updateValue(amount, playerNumber);
     //	scoreSystem.updateScore(playerNumber, amount);
 }