/// <summary> /// Spawns a new child gameobject for the passed in player. /// </summary> /// <param name="target_player">KeyValuePair<int, Photon.Realtime.Player> type, the connected player dictionary</param> protected virtual void SpawnChild(KeyValuePair <int, Photon.Realtime.Player> target_player) { if (string.IsNullOrEmpty(teamName) || teamName == logic.GetUserTeamName(target_player.Value.UserId)) { if (debugging == true) { Debug.Log("Spawning local player object: " + target_player.Value.NickName); } GameObject newChild = null; if (target_player.Value.IsMasterClient == true) { newChild = Instantiate(ownerPlayer); } else { newChild = Instantiate(otherPlayer); } newChild.transform.SetParent(parentObj); newChild.transform.localScale = new Vector3(1, 1, 1); newChild.transform.position = Vector3.zero; if (newChild.GetComponent <PlayerListObject>()) { newChild.GetComponent <PlayerListObject>().SetPlayerContents(target_player.Value); newChild.GetComponent <PlayerListObject>().SetReadyState(logic.PlayerIsReady(target_player.Value.UserId)); } if (allocateViewIds == true) { if (newChild.GetComponent <PhotonView>()) { if (logic.GetPlayerVoiceView(target_player.Value.UserId) == 999999 && PhotonNetwork.IsMasterClient == true) { logic.SendUpdateVoiceView(target_player.Value.UserId, PhotonNetwork.AllocateViewID(target_player.Value.ActorNumber)); } else if (logic.GetPlayerVoiceView(target_player.Value.UserId) != 999999) { newChild.GetComponent <PhotonView>().ViewID = logic.GetPlayerVoiceView(target_player.Value.UserId); newChild.GetComponent <PhotonView>().OwnershipTransfer = OwnershipOption.Takeover; newChild.GetComponent <PhotonView>().TransferOwnership(target_player.Value); } } } } }
/// <summary> /// Calls the `SetText` function to set the values of the `texts` to be /// what the current input count is. If the input count was different from /// the last time you called this function it will execute the `OnCountChanged` /// UnityEvent. /// </summary> /// <param name="count">int type, the count to display on all the texts.</param> protected virtual void DisplayCount(int count) { if (string.IsNullOrEmpty(teamName)) { SetText(count.ToString()); } else { int total_count = 0; foreach (KeyValuePair <int, Photon.Realtime.Player> target_player in PhotonNetwork.CurrentRoom.Players) { if (logic.GetUserTeamName(target_player.Value.UserId) == teamName) { total_count += 1; } } SetText(total_count.ToString()); if (_prevCount != total_count) { _prevCount = total_count; OnCountChanged.Invoke(total_count); } } }