private void UpdateTeamList(CustomRoomOptions.Team team, ref List <PlayerListNode> teamNodeList, ref List <PhotonPlayer> playerList) { // Load player list form server. PhotonPlayer[] totalplayerList = PhotonNetwork.playerList; playerList.Clear(); foreach (var player in totalplayerList) { if (CustomRoomOptions.GetTeam((int)player.customProperties[PlayerProperties.Team]) == team) { playerList.Add(player); } } playerList.Sort(ComparerScore); for (int index = 0; index < teamNodeList.Count; index++) { if (index < playerList.Count) { teamNodeList[index].ShowNode(true); teamNodeList[index].SetInfo(playerList[index].isLocal, (index + 1).ToString(), playerList[index].name, (playerList[index].GetScore())); } else { teamNodeList[index].ShowNode(false); } } }
/// <summary> /// Check if the target team is full or not. /// </summary> /// <param name="team">The team you wanna check.</param> /// <returns>Return TRUE if team is full.</returns> public static bool CheckIfTeamFull(CustomRoomOptions.Team team) { PhotonPlayer[] playerlist = PhotonNetwork.playerList; int currentTeamSize = 0; foreach (var player in playerlist) { if (player.customProperties.ContainsKey(PlayerProperties.Team)) { // If the player's team is match with what we are looking for. if (CustomRoomOptions.GetTeam((int)player.customProperties[PlayerProperties.Team]) == team) { currentTeamSize++; } } else { Debug.LogError("Player property TEAM is not exist."); return(false); } } if (currentTeamSize >= (PhotonNetwork.room.maxPlayers / 2)) { Debug.LogError("Any one side of team's menber should not more than half of the maximun player count."); return(false); } return(currentTeamSize == PhotonNetwork.room.maxPlayers); }
public override Transform GetSpawnPoint(CustomRoomOptions.Team team) { switch (team) { case CustomRoomOptions.Team.OneManArmy: return(SpawnPointsManager.Instance.GetAvailableSpwanPoint(SpawnPointsManager.GetSwpanPointMode.Random)); case CustomRoomOptions.Team.Blue: return(SpawnPointsManager.Instance.GetAvailableSpwanPoint(SpawnPointsManager.GetSwpanPointMode.GetBlueOnly)); case CustomRoomOptions.Team.Red: return(SpawnPointsManager.Instance.GetAvailableSpwanPoint(SpawnPointsManager.GetSwpanPointMode.GetRedOnly)); default: return(null); } }
/// <summary> /// Use this method to synchronize every client which team this character's object is in. /// </summary> /// <param name="team"></param> public void SetTeam(CustomRoomOptions.Team team) { this.photonView.RPC("SyncTeam", PhotonTargets.AllBuffered, (int)team); }
/// <summary> /// Get spawn point for player object to respawn. /// </summary> /// <param name="team">Which team does the player object belong to.</param> /// <returns></returns> public abstract Transform GetSpawnPoint(CustomRoomOptions.Team team);
public override Transform GetSpawnPoint(CustomRoomOptions.Team team) { return(SpawnPointsManager.Instance.GetAvailableSpwanPoint(SpawnPointsManager.GetSwpanPointMode.Random)); }