// --------------- Actions handlers ----------------- public void SyncTurnActions(GameLogicClient game) { ClientRegisterTurnActionsMessage msg = new ClientRegisterTurnActionsMessage(); msg.gameId = game.gameId; msg.userId = user.userId; msg.userName = user.userName; msg.actions = game.generateTurnActionsJSON(); client.Send(ClientRegisterTurnActionsMessage.ID, msg); Debug.Log("Client sent RegisterTurnActions"); }
public void LoadGame(Dictionary <string, object> args) { ServerJoinGameResponseMessage msg = (ServerJoinGameResponseMessage)args["msg"]; if (msg.hasJoined) { gameLogic = new GameLogicClient(msg.mapId); gameLogic.game1v1 = this; gameLogic.gameId = msg.gameId; gameLogic.currentTurn = msg.currentTurn; NetworkMasterClient.user.currentGameId = gameLogic.gameId; for (int i = 0; i < msg.cellIds.Length; i++) { ulong playerId = msg.playerIds[i]; int cellId = msg.cellIds[i]; int entityId = msg.entityIds[i]; string displayedName = msg.displayedNames[i]; float r = msg.r[i]; float g = msg.g[i]; float b = msg.b[i]; Player newPlayer = spawnPlayer(playerId, cellId, entityId, displayedName, r, g, b); if (msg.clientPlayerId == playerId) { NetworkMasterClient.user.player = newPlayer; gameLogic.localPlayer = newPlayer; localPlayer = newPlayer; //GUIManager.gui.linkWithLocalEntity(NetworkMasterClient.user.player.playerEntity); } newPlayer.playerEntity.initSpell(msg.spellIds); } NetworkMasterClient.singleton.ClientReadyToPlay(); } else { Debug.LogError("Failed to join game."); } }