private static NetworkingData.PlayerSpawnData[] getAllPlayersSpawnData() { NetworkingData.PlayerSpawnData[] playerSpawnDatas = new NetworkingData.PlayerSpawnData[Server.Instance.Players.Count]; int i = 0; foreach (KeyValuePair <string, Player> entry in Server.Instance.PlayersByName) { Player p = entry.Value; playerSpawnDatas[i] = new NetworkingData.PlayerSpawnData(p.Client.ID, p.Name, p.spriteRow, p.ServerPosition); i++; } return(playerSpawnDatas); }
void SpawnPlayer(NetworkingData.PlayerSpawnData data) { GameObject go = Instantiate(PlayerPrefab); ClientPlayer player = go.GetComponent <ClientPlayer>(); player.SpriteArray = SpriteArray; player.Prefab = go; player.Initialize(data.Id, data.Name, data.SpriteRowIndex, data.Position.X, data.Position.Y, go); if (player.isOwn) { myPlayer = player; } players.Add(data.Id, player); Debug.Log($"Spawn player {data.Name} at [{data.Position.X}, {data.Position.Y}]"); }