public void SendIntoGame(string connectionID, string playerName) { Vector3 spawnPos = ServerSideGameManager.instance.spawnPositions[(count++) % ServerSideGameManager.instance.spawnPositions.Count]; serverMasterController = ServerSideGameManager.instance.InstantiatePlayer((int)EnumData.Heroes.Medusa); serverMasterController.Initialise(id, connectionID, playerName, spawnPos); //This will send all other players information to our new player foreach (ServerSideClient client in Server.clients.Values) { if (client.serverMasterController != null) { if (client.id != id) { ServerSend.SpawnPlayer(id, client.serverMasterController); } } } //This will send new player information to all other players and themselves foreach (ServerSideClient client in Server.clients.Values) { if (client.serverMasterController != null) { ServerSend.SpawnPlayer(client.id, serverMasterController); } } List <WorldGridItem> worldGridItemList = new List <WorldGridItem>(); for (int i = 0; i < ServerSideGameManager.instance.toNetworkTileType.Count; i++) { List <Vector3Int> positionsOfTile = GridManager.instance.GetAllPositionForTileMap(ServerSideGameManager.instance.toNetworkTileType[i]); WorldGridItem worldGridItem = new WorldGridItem((int)ServerSideGameManager.instance.toNetworkTileType[i], positionsOfTile); worldGridItemList.Add(worldGridItem); } WorldUpdate worldUpdate = new WorldUpdate(ServerSideGameManager.instance.serverWorldSequenceNumber, worldGridItemList.ToArray(), new GameData((int)ServerSideGameManager.instance.currentGameState, ServerSideGameManager.instance.timeToStartMatch), ServerSideGameManager.projectilesDic, ServerSideGameManager.enemiesDic, ServerSideGameManager.animatingStaticTileDic, GridManager.instance.portalTracker.portalEntranceDic); ServerSend.SpawnGridWorld(id, worldUpdate); }
public void SendIntoGame(string playerName) { serverMasterController = ServerSideGameManager.instance.InstantiatePlayer(); serverMasterController.Initialise(id, playerName, new Vector3(0.5f, 0.5f, 0f)); //This will send all other players information to our new player foreach (ServerSideClient client in Server.clients.Values) { if (client.serverMasterController != null) { if (client.id != id) { ServerSend.SpawnPlayer(id, client.serverMasterController); } } } //This will send new player information to all other players and themselves foreach (ServerSideClient client in Server.clients.Values) { if (client.serverMasterController != null) { ServerSend.SpawnPlayer(client.id, serverMasterController); } } List <WorldGridItem> worldGridItemList = new List <WorldGridItem>(); for (int i = 0; i < ServerSideGameManager.instance.toNetworkTileType.Count; i++) { List <Vector3Int> positionsOfTile = GridManager.instance.GetAllPositionForTileMap(GridManager.instance.gameStateDependentTileArray[(int)ServerSideGameManager.instance.toNetworkTileType[i] - 1].tileMap); WorldGridItem worldGridItem = new WorldGridItem((int)ServerSideGameManager.instance.toNetworkTileType[i], positionsOfTile); worldGridItemList.Add(worldGridItem); } WorldUpdate worldUpdate = new WorldUpdate(ServerSideGameManager.instance.serverWorldSequenceNumber, worldGridItemList.ToArray()); ServerSend.SpawnGridWorld(id, worldUpdate); }