public override bool OnLobbyServerSceneLoadedForPlayer(GameObject lobbyPlayer, GameObject gamePlayer) { Debug.Log("OnLobbyServerSceneLoadedForPlayer"); NetworkLobbyPlayer nlp = lobbyPlayer.GetComponent <NetworkLobbyPlayer>(); var playerIndex = nlp.slot + 1; PlayerNetwork pn = gamePlayer.GetComponent <PlayerNetwork>(); pn.GetComponent <Unit_ID>().CmdSetPlayerIndex(playerIndex); pn.GetComponent <Unit_ID>().CmdSetMyUniqueID("Player" + playerIndex); pn.connectionId = nlp.connectionToClient.connectionId; return(true); }
private void OnPhotonPlayerConnected(PhotonPlayer photonPlayer) { PlayerJoinedRoom(photonPlayer, PhotonNetwork.playerList.Length); int rand = Random.Range(0, 2); if (rand == 0) { photonPlayer.SetTeam(PunTeams.Team.blue); pnet.GetComponent <PhotonView>().RPC("RPC_SetPlayerTeam", PhotonTargets.All, true, photonPlayer); } else { photonPlayer.SetTeam(PunTeams.Team.red); pnet.GetComponent <PhotonView>().RPC("RPC_SetPlayerTeam", PhotonTargets.All, false, photonPlayer); } }
public void OnClick_SetTeam() { if (PhotonNetwork.isMasterClient || PhotonNetwork.player.ID == photonPlayer.ID) { if (photonPlayer.GetTeam() == PunTeams.Team.red) { if (PunTeams.PlayersPerTeam.TryGetValue(PunTeams.Team.blue, out b)) { if (b.Count >= 5) { } else { button.color = new Color32(92, 171, 229, 254); photonPlayer.SetTeam(PunTeams.Team.blue); teamSet = PunTeams.Team.blue; pnet.GetComponent <PhotonView>().RPC("RPC_ChangeList", PhotonTargets.All, photonPlayer); } } } else { if (PunTeams.PlayersPerTeam.TryGetValue(PunTeams.Team.red, out r)) { if (r.Count >= 5) { } else { button.color = new Color32(254, 73, 92, 254); photonPlayer.SetTeam(PunTeams.Team.red); teamSet = PunTeams.Team.red; pnet.GetComponent <PhotonView>().RPC("RPC_ChangeList", PhotonTargets.All, photonPlayer); } } } } }