private void OnTriggerEnter(Collider other) { if (other.gameObject.tag == "Player") { ElectronManager otherEM = other.gameObject.transform.GetChild(2).GetComponent <ElectronManager>(); if (otherEM.countOfCurrentElectrons < otherEM.E.Count) { GetComponent <MeshRenderer>().enabled = false; trigger.enabled = false; if (other.GetComponent <PlayerController>().Camera != null) { other.GetComponent <PlayerController>().Camera.GetComponent <CameraFollow>().MoveUpLightning(); } otherEM.add(); if (PV.IsMine) { pleaseDesrtoryMe = true; //PhotonNetwork.Destroy(gameObject); //other.GetComponent<PlayerController>().Camera.GetComponent<CameraFollow>().lightningScript.MoveUp(); //StartCoroutine(selfDesctruct()); } else { PV.RPC("SendDestroyRequest", RpcTarget.All); } } } }
// Update is called once per frame void Update() { totalElectronCount = 0; bluecount = 0; redcount = 0; foreach (var item in GameObject.FindGameObjectsWithTag("Player")) { ElectronManager EM = item.transform.GetChild(2).GetComponent <ElectronManager>(); totalElectronCount = totalElectronCount + EM.E.Count; if (item.GetComponent <PlayerController>().TeamNumber == 1) { bluecount = bluecount + EM.countOfCurrentElectrons; } else if (item.GetComponent <PlayerController>().TeamNumber == 2) { redcount = redcount + EM.countOfCurrentElectrons; } } slider.maxValue = redcount + bluecount; slider.value = redcount; tBlue.text = bluecount.ToString(); tRed.text = redcount.ToString(); if (startTIme + 1 <= PhotonNetwork.Time) { time -= Time.deltaTime; textUI.text = decimal.Truncate(decimal.Parse(time.ToString())).ToString(); if (time <= 5 && Anim.GetBool("End") == false) { Anim.SetBool("End", true); } if (time < 0) { GameObject GOO = Instantiate(GameOverObject, Vector3.zero, Quaternion.identity); if (redcount > bluecount) { GOO.GetComponent <GameOverObjectScript>().winner = "Red Wins!"; } else if (redcount < bluecount) { GOO.GetComponent <GameOverObjectScript>().winner = "Blue Wins!"; } else { GOO.GetComponent <GameOverObjectScript>().winner = "It was a Tie"; } SceneManager.LoadScene(3); } } }