public void OnPhotonPlayerConnected(PhotonPlayer newPlayer) { //Only MasterClient start Event to create Player //newPlayer is the new joind Client if (PhotonNetwork.isMasterClient) { Gamemode.AddPlayerToTeam(m_currenGameMode, newPlayer); NetworkEventHandler.SyncSpawnNode(newPlayer.GetPlayerTeam(), newPlayer); } SetPlayerCount(); IsRoomFull(); }
public void Refresh() { if (cachePlayer == null || cachePlayer.GetPlayerTeam() != InitTeam) { UIReference.RemoveUIPlayer(this); Destroy(gameObject); } NameText.text = cachePlayer.NickNameAndRole(); KillsText.text = cachePlayer.CustomProperties[PropertiesKeys.KillsKey].ToString(); DeathsText.text = cachePlayer.CustomProperties[PropertiesKeys.DeathsKey].ToString(); ScoreText.text = cachePlayer.CustomProperties[PropertiesKeys.ScoreKey].ToString(); }
public void UpdateTeams() { Array enumVals = Enum.GetValues(typeof(Team)); foreach (var enumVal in enumVals) { PlayersPerTeam[(Team)enumVal].Clear(); } for (int i = 0; i < PhotonNetwork.playerList.Length; i++) { PhotonPlayer player = PhotonNetwork.playerList[i]; Team playerTeam = player.GetPlayerTeam(); PlayersPerTeam[playerTeam].Add(player); } }
private void Register() { //Get The PhotonPlayer with the Owner Actor Nr PhotonPlayer m_thisPhotonPlayer = PhotonPlayer.Find(m_pView.OwnerActorNr); //Create new Custom Player PlayerList.CustomPlayer m_cp = new PlayerList.CustomPlayer() { Name = m_thisPhotonPlayer.NickName, PhotonPlayer = m_thisPhotonPlayer, Team = m_thisPhotonPlayer.GetPlayerTeam(), PhotonView = m_pView, PlayerObject = m_playerObject }; m_playerList.Add(m_cp); }
/// <summary>Switch that player's team to the one you assign.</summary> /// <remarks>Internally checks if this player is in that team already or not. Only team switches are actually sent.</remarks> /// <param name="player"></param> /// <param name="team"></param> public static void SetPlayerTeam(this PhotonPlayer player, Teams.Team team) { if (!PhotonNetwork.connectedAndReady) { Debug.LogWarning("JoinTeam was called in state: " + PhotonNetwork.connectionStateDetailed + ". Not connectedAndReady."); return; } Teams.Team currentTeam = player.GetPlayerTeam(); if (currentTeam != team) { player.SetCustomProperties(new Hashtable() { { PlayerProperties.Team, team } }); } }
private void Start() { this.m_player = PhotonPlayer.Find(m_pView.OwnerActorNr); m_nameField.text = m_player.NickName; m_currentTeam = m_player.GetPlayerTeam(); m_healthHandler.CurrentTeam = m_currentTeam; m_healthHandler.OnChangeHealthEvent += OnHealthEventChanged; if (m_pView.isMine) { m_healthBarMode = HealthBarMode.ScreenSpace; } else { m_healthBarMode = HealthBarMode.WorldSpace; } Initialize(); }
public void Init(PhotonPlayer player, bl_UIReferences uir) { cachePlayer = player; gameObject.name = player.NickName + player.ID; UIReference = uir; BackgroundImage = GetComponent <Image>(); if (player.ID == PhotonNetwork.player.ID) { Color c = BackgroundImage.color; c.a = 0.35f; BackgroundImage.color = c; } InitTeam = player.GetPlayerTeam(); NameText.text = player.NickNameAndRole(); KillsText.text = player.CustomProperties[PropertiesKeys.KillsKey].ToString(); DeathsText.text = player.CustomProperties[PropertiesKeys.DeathsKey].ToString(); ScoreText.text = player.CustomProperties[PropertiesKeys.ScoreKey].ToString(); KickButton.SetActive(PhotonNetwork.isMasterClient && player.ID != PhotonNetwork.player.ID); }
void RespawnPlayer() { m_currenGameMode = (Mode)PhotonNetwork.room.GetGamemode(); PhotonPlayer localPlayer = PhotonNetwork.player; Teams.Team team = localPlayer.GetPlayerTeam(); switch (m_currenGameMode) { case Mode.TeamDeathMatch: NetworkEventHandler.TeamBasedRespawn(team, localPlayer); break; case Mode.DeatchMatch: NetworkEventHandler.RespawnRandomSpawnNode(localPlayer); break; } m_countDown = m_respawnTime; if (m_counter.gameObject.activeInHierarchy) { m_counter.gameObject.SetActive(false); } }