// Update is called once per frame void Update() { //Check if dead --> Start BACKUP death coroutine if ((int)PhotonNetwork.player.customProperties ["hp"] <= 0 && thisLoop.startedBackupDeath == false) { thisLoop.StartCoroutine("BackupDeath"); thisLoop.startedBackupDeath = true; } // Refresh Leaderboard If Needed (USED WHEN MURDERER RESPAWNS AS SPY) if (GameLoop.refreshAllLeaderboards == true) { leaderboard.Refresh(); GameLoop.refreshAllLeaderboards = false; } // Update Username While In Game if (GameManager.setChangeNameTrue == true && GameManager.changeName == false) { pv.RPC("SetChangeNameTrueForAll", PhotonTargets.All); } // Update Skin While In Game if (GameManager.setChangeSkinTrue == true && GameManager.changeSkin == false) { pv.RPC("SetChangeSkinTrueForAll", PhotonTargets.All); } if (GameManager.setChangeNameTrue == true && GameManager.changeName == true) { // Set All Players' Username for (int p = 0; p < PhotonNetwork.playerList.Length; p++) { string nameToSet = PhotonNetwork.playerList [p].name; GameObject targetPlayer = players [p].gameObject; GameLoop targetPlayerGL = players [p].gameObject.GetComponent <GameLoop> (); TextMesh usernameWorldText = targetPlayer.gameObject.transform.FindChild("Username").gameObject.GetComponent <TextMesh> (); // If Player Never Entered a Username if (targetPlayerGL.pv.owner.name == "" || targetPlayerGL.pv.owner.name == "Enter Username...") { targetPlayerGL.pv.owner.name = "No Name"; } usernameWorldText.text = targetPlayerGL.pv.owner.name; targetPlayer.gameObject.name = targetPlayerGL.pv.owner.name; } // Refresh Leaderboard leaderboard.Refresh(); GameManager.changeName = false; GameManager.setChangeNameTrue = false; } if (GameManager.setChangeSkinTrue == true && GameManager.changeSkin == true) { for (int p = 0; p < PhotonNetwork.playerList.Length; p++) { GameObject targetPlayer = players [p].gameObject; GameLoop targetPlayerGL = players [p].gameObject.GetComponent <GameLoop> (); if ((int)targetPlayerGL.pv.owner.customProperties ["cs"] < GM.charColors.Length) { targetPlayerGL.myTorso.color = GM.charColors [(int)targetPlayerGL.pv.owner.customProperties ["cs"]]; targetPlayerGL.myRightLeg.color = GM.charColors [(int)targetPlayerGL.pv.owner.customProperties ["cs"]]; targetPlayerGL.myRightArm.color = GM.charColors [(int)targetPlayerGL.pv.owner.customProperties ["cs"]]; targetPlayerGL.myLeftLeg.color = GM.charColors [(int)targetPlayerGL.pv.owner.customProperties ["cs"]]; targetPlayerGL.myLeftArm.color = GM.charColors [(int)targetPlayerGL.pv.owner.customProperties ["cs"]]; } } GameManager.changeSkin = false; GameManager.setChangeSkinTrue = false; } // Update waiting for players blur popup IF ACTIVE if (PhotonNetwork.playerList.Length < NetworkManager.playersNeededToStartGame && PhotonNetwork.offlineMode == false) { playersLeftToJoin = NetworkManager.playersNeededToStartGame - PhotonNetwork.playerList.Length; if (worldBlur.blurActive == false) { worldBlur.BlurMessage(2, 2, ""); } if (playersLeftToJoin > 0) { worldBlur.UpdateMessage("Not Enough Players. Need " + playersLeftToJoin + " More Player(s) to Play."); } } // RANDOM TEAM ASSIGNMENT (Used by ChooseRandomMurderer Method) if (murdererGL != null) { if (thisLoop.assignedTeam == 1 && murdererGL.pv.isMine == true) { if (worldBlur.blurActive) { worldBlur.ClearMessage(); } if (thisLoop.pv.isMine) { GM.ScaleBackInGameUI(); } thisLoop.StartCoroutine("murdererPopup", 2); thisLoop.assignedTeam = 0; } if (thisLoop.assignedTeam == 2 && murdererGL.pv.isMine == false) { if (worldBlur.blurActive) { worldBlur.ClearMessage(); } if (thisLoop.pv.isMine) { GM.ScaleBackInGameUI(); } thisLoop.StartCoroutine(spyPopup(2, false)); thisLoop.assignedTeam = 0; } } if (thisLoop.myDeathStage == 1) { if (GM.UIvisible == false) { GM.ChangeIdOKClicked(); } // IF IS SPY --> Died as Spy is TRUE if (thisLoop.pv.isMine) { if ((int)PhotonNetwork.player.customProperties ["t"] == 2) { thisLoop.diedAsSpy = true; } } } // BLUR MESSAGE ON LOCAL CLIENT if (thisLoop.myDeathStage == 2) { if (thisLoop.pv.isMine) { GM.HideInGameUI(); worldBlur.BlurMessage(2, 2, deathReasonGlobal); // Auto-Respawn ON and Become Spy If Died as Murderer if (thisLoop.diedAsSpy == false) { thisLoop.autoRespawn = true; thisLoop.gameObject.transform.position = NM.spawnPoints [NM.randomSpawnPoint].position; thisLoop.StartCoroutine(spyPopup(2, true)); thisLoop.diedAsSpy = true; } } thisLoop.myDeathStage = 0; } // LEAVE GAME RETURN TO MENU ON LOCAL CLIENT (pass control over to GM) if (thisLoop.myDeathStage == 3) { // Debug.Log ("Death Stage is 3"); // If NOT AutoRespawn if (thisLoop.autoRespawn == false) { if (thisLoop.pv.isMine) { PhotonNetwork.LeaveRoom(); } } // AutoRespawn? if (thisLoop.autoRespawn) { if (thisLoop.pv.isMine) { thisLoop.StopCoroutine("BackupDeath"); worldBlur.ClearMessage(); GM.ShowInGameUI(); thisLoop.diedAsSpy = false; thisLoop.autoRespawn = false; } } thisLoop.myDeathStage = 0; } }