public void Start() { PlayersPerTeam = new Dictionary <Team, List <PhotonPlayer> >(); Array enumVals = Enum.GetValues(typeof(Team)); foreach (var enumVal in enumVals) { PlayersPerTeam[(Team)enumVal] = new List <PhotonPlayer>(); } this.UpdateTeams(); //We get the playercount string players = this.countPlayers(); string[] playerTab = players.Split(';'); int blueCount = int.Parse(playerTab[0]); int redCount = int.Parse(playerTab[1]); //We get our player PhotonView myView = PhotonView.Get(this); PhotonPlayer myPlayer = myView.owner; //We set the team depending on the players if (myView.isMine) { if (blueCount <= redCount) { TeamExtensions.SetTeam(myPlayer, Team.blue); } else { TeamExtensions.SetTeam(myPlayer, Team.red); } Debug.Log("You are on team " + TeamExtensions.GetTeam(myPlayer)); } //If we are the masterclient we verify the score and if there are none we set it if (PhotonNetwork.isMasterClient) { if (!TeamExtensions.isTeamScoreSet("Blue")) { TeamExtensions.SetTeamScore("Blue", 0); } if (!TeamExtensions.isTeamScoreSet("Red")) { TeamExtensions.SetTeamScore("Red", 0); } if (isKillFeedEmpty) { TeamExtensions.AddKillFeed(-1, -1); } } }
public void AddPlayersToTeam(Player player) { Debug.Log(PunTeams.PlayersPerTeam[PunTeams.Team.blue].Count); Debug.Log(PunTeams.PlayersPerTeam[PunTeams.Team.red].Count); if (PunTeams.PlayersPerTeam[PunTeams.Team.blue].Count < PunTeams.PlayersPerTeam[PunTeams.Team.red].Count) { Debug.Log("blue"); TeamExtensions.SetTeam(player, PunTeams.Team.blue); } else if (PunTeams.PlayersPerTeam[PunTeams.Team.blue].Count >= PunTeams.PlayersPerTeam[PunTeams.Team.red].Count) { Debug.Log("red"); TeamExtensions.SetTeam(player, PunTeams.Team.red); } punTeams.UpdateTeams(); // pv.RPC("RPC_AddPlayersToTeam", RpcTarget.All, playername); }