网络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;
}
}