public void GetInfo(PhotonPlayer player) { playerName.text = player.NickName; PunPlayerStateData playerStatus = player.GetStatus(); if (playerStatus.health == -1) { Debug.Log("player status null"); player.SetStatus(100, 0, ""); playerStatus = player.GetStatus(); } playerHealth.text = playerStatus.health.ToString(); }
public static PunPlayerStateData GetStatus(this PhotonPlayer player) { PunPlayerStateData playerStatus = new PunPlayerStateData(); object health; object score; object weaponName; if (player.CustomProperties.TryGetValue(PunPlayerState.PlayerStateHealth, out health)) { playerStatus.health = (int)health; } else { Debug.Log("Player State Health is null"); playerStatus.health = -1; } if (player.CustomProperties.TryGetValue(PunPlayerState.PlayerStateScore, out score)) { playerStatus.score = (int)score; } else { Debug.Log("Player State Score is null"); playerStatus.score = -1; } if (player.CustomProperties.TryGetValue(PunPlayerState.PlayerStateWeaponName, out weaponName)) { playerStatus.weaponName = (string)weaponName; } else { Debug.Log("Player State Score is null"); playerStatus.weaponName = "null"; } return(playerStatus); }