Exemplo n.º 1
0
        void Update()
        {
            if (moneyCounts != null)
            {
                return;
            }

            moneyCounts = MoneyManager.GetMoneyCounts();

            switch (Player.localPlayer.teamId)
            {
            case 1:
                myTeamCountText.text    = $"${moneyCounts[0].ToString()}";
                enemyTeamCountText.text = $"${moneyCounts[1].ToString()}";
                if (moneyCounts[0] >= moneyCounts[1])
                {
                    winText.gameObject.GetComponent <Text>().enabled  = true;
                    loseText.gameObject.GetComponent <Text>().enabled = false;
                }
                else
                {
                    winText.gameObject.GetComponent <Text>().enabled  = false;
                    loseText.gameObject.GetComponent <Text>().enabled = true;
                }

                break;

            case 2:
                myTeamCountText.text    = $"${moneyCounts[1].ToString()}";
                enemyTeamCountText.text = $"${moneyCounts[0].ToString()}";
                if (moneyCounts[1] >= moneyCounts[0])
                {
                    winText.gameObject.GetComponent <Text>().enabled  = true;
                    loseText.gameObject.GetComponent <Text>().enabled = false;
                }
                else
                {
                    winText.gameObject.GetComponent <Text>().enabled  = false;
                    loseText.gameObject.GetComponent <Text>().enabled = true;
                }
                break;

            default:
                myTeamCountText.text = "$0";
                break;
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Check what team this client belongs to, then set field texts to win, draw or lose appropriately.
        /// Also check display their money counts appropriately.
        /// </summary>
        private void RefreshTextViews()
        {
            //get array of moneycount where position 0 belongs to cops and 1 to robbers.
            moneyCounts = MoneyManager.GetMoneyCounts();

            switch (Player.localPlayer.teamId) //get teamid
            {
            case 1:                            //if client is cops
                myTeamCountText.text    = $"${moneyCounts[0].ToString()}";
                enemyTeamCountText.text = $"${moneyCounts[1].ToString()}";
                if (moneyCounts[0] > moneyCounts[1])       //if cops win
                {
                    ActivateTextView(true, false, false);  //display win message
                }
                else if (moneyCounts[0] == moneyCounts[1]) // if match draw
                {
                    ActivateTextView(false, true, false);  //display draw message
                }
                else                                       //if cops lose
                {
                    ActivateTextView(false, false, true);  //display lose message
                }
                break;

            case 2:     //if client is robbers
                myTeamCountText.text    = $"${moneyCounts[1].ToString()}";
                enemyTeamCountText.text = $"${moneyCounts[0].ToString()}";
                if (moneyCounts[1] > moneyCounts[0])       // if robbers win
                {
                    ActivateTextView(true, false, false);  //display win message
                }
                else if (moneyCounts[0] == moneyCounts[1]) // if match draw
                {
                    ActivateTextView(false, true, false);  //display draw message
                }
                else                                       //if cops win
                {
                    ActivateTextView(false, false, true);  //display lose message
                }
                break;

            default:
                myTeamCountText.text = "$0";
                break;
            }
        }