/// <summary> /// If a player no longer has any health kill them /// </summary> public void Update() { if (moneyM == null) { try { moneyM = FindObjectOfType <MoneyManager>().GetComponent <MoneyManager>(); } catch (NullReferenceException ex) { // Do nothing as there is a null ref exception here. } } if (currentHealth <= 0) { Die(); } if (spawner.respawned) { Debug.Log("if spawner.respawner"); CmdRespawn(); spawner.setRespawn(false); spawner.RemoveFloatingText(); Respawn(); Debug.Log("if spawner.respawner end"); } RefreshRespawn(); }
/// <summary> /// Update is called once per frame /// </summary> private void Update() { if (moneyManager == null) { moneyManager = FindObjectOfType <MoneyManager>().GetComponent <MoneyManager>(); //moneyManager = GetComponent<MoneyManager>(); //moneyManager = moneyManagerGameObject.GetComponent<MoneyManager>(); } }
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; } }
/// <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; } }
/// <summary> /// If a player no longer has any health kill them /// </summary> public void Update() { if (moneyM == null) { moneyM = FindObjectOfType <MoneyManager>().GetComponent <MoneyManager>(); } if (currentHealth <= 0) { Die(); } if (spawner.respawned) { CmdRespawn(); Respawn(); spawner.setRespawn(false); spawner.RemoveFloatingText(); } RefreshRespawn(); }