Photon网络中Player中存取数据

网络player中自然在应用中要根据需要存储一些游戏数据,比如头像、击杀对方英雄数,击杀的英雄列表等。
Hashtable initialProps = new Hashtable() { { AsteroidsGame.PLAYER_READY, isPlayerReady }, { AsteroidsGame.PLAYER_LIVES,AsteroidGame.PLAYER_MAX_lives} };
PhotonNetwork.LocalPlayer.SetCustomProperties(initialProps);
PhotonNetwork.LocalPlayer.SetScore(0);

存储数据如上,读取数据如下:
foreach (Player p in PhotonNetwork.PlayerList)
{
object isPlayerReady;
if (p.CustomProperties.TryGetValue(AsteroidsGame.PLAYER_READY, out isPlayerReady))
{
if (!(bool) isPlayerReady)
{
return false;
}
}
else
{
return false;
}
}

发布了49 篇原创文章 · 获赞 8 · 访问量 1万+

猜你喜欢

转载自blog.csdn.net/qq_23158477/article/details/90614009