[PunRPC] public void EndGame(int[] ids) { List <float> scores = new List <float>(); List <GameObject> players = new List <GameObject>(); foreach (int id in ids) { GameObject obj = PhotonView.Find(id).gameObject; players.Add(obj); PlayerCube p = obj.GetComponent <PlayerCube>(); scores.Add(p.score); } var max = Mathf.Max(scores.ToArray()); foreach (GameObject p in players) { if (p.GetComponent <PlayerCube>().score == max) { ControlText.text = "The Winner Is: " + p.transform.name; } } StartCoroutine(FinishGame()); }
public void SpeedUpgrade() { Debug.Log("UPGRADED SPEED!"); if (cubeToUpgrade != null && SpeedUpgrades.Count > 0) { ScoreSystem.Score -= CurrentSpeedUpgrade.Cost; DestroyableObject desObj = cubeToUpgrade.GetComponent <DestroyableObject>(); ShootShots shootShots = cubeToUpgrade.GetComponent <ShootShots>(); cubeToUpgrade.speed += CurrentSpeedUpgrade.modifier; if (CurrentSpeedUpgrade.upgradePrefab != null) { GameObject upgradePrefab = PhotonNetwork.Instantiate("Armor/" + CurrentSpeedUpgrade.upgradePrefab.name, cubeToUpgrade.transform.position, cubeToUpgrade.transform.rotation, 0); upgradePrefab.transform.SetParent(cubeToUpgrade.transform); } int upgradeIndex = SpeedUpgrades.IndexOf(CurrentSpeedUpgrade); SpeedUpgrades.RemoveAt(upgradeIndex); } }
void Update() { if (isSetted) { player.GetComponent <PlayerCube>().enabled = false; player.GetComponent <Rigidbody>().isKinematic = true; player.GetComponent <PlayerCube>().enabled = false; player.transform.position = Vector3.Lerp(player.transform.position, nextposition, 4 * Time.deltaTime); player.GetComponent <PlayerCube>().direction = Vector3.zero; if (Vector3.Distance(player.transform.position, nextposition) <= .001f) { player.GetComponent <PlayerCube>().enabled = true; player.GetComponent <Rigidbody>().isKinematic = false; player.GetComponent <PlayerCube>().enabled = true; isSetted = false; if (gate.Count % 2 != 0) { SetposZ(); } } } Counter(); }