Esempio n. 1
0
        private void OnClientJoinGame(NetworkMessage netMsg)
        {
            ServerJoinGameResponseMessage msg = netMsg.ReadMessage <ServerJoinGameResponseMessage>();

            if (msg.hasJoined)
            {
                Debug.Log("Received ServerJoinGameResponseMessage " + msg.gameId);
                Dictionary <string, object> args = new Dictionary <string, object>();
                args.Add("msg", msg);
                SceneMaster.singleton.SwitchToGame1v1(args);
            }
            else
            {
                Debug.LogError("Failed to join game.");
            }
        }
Esempio n. 2
0
        void ServerSendNewGameDataToPlayers(GameLogic game)
        {
            ServerJoinGameResponseMessage msg = new ServerJoinGameResponseMessage();

            int playerCount = game.players.Count;

            msg.initArrays(playerCount);

            // Adding all existing players to message (including new player)
            int i = 0;

            foreach (Player p in game.players.Values)
            {
                msg.cellIds[i]        = p.getCurrentCellId();
                msg.playerIds[i]      = p.playerId;
                msg.entityIds[i]      = p.playerEntity.entityId;
                msg.displayedNames[i] = p.playerName;
                msg.r[i]     = p.playerColor.r;
                msg.g[i]     = p.playerColor.g;
                msg.b[i]     = p.playerColor.b;
                msg.spellIds = new string[4] {
                    "S001", "S002", "S003", "S004"
                };
                i++;
            }

            msg.gameId    = game.gameId;
            msg.mapId     = game.mapId;
            msg.hasJoined = true;

            foreach (Player player in game.players.Values)
            {
                msg.clientPlayerId = player.playerId;
                User u = player.user;
                u.connection.Send(ServerJoinGameResponseMessage.ID, msg);
            }
            Debug.Log("Server sent ServerSendNewGameDataToPlayers " + msg.gameId);
        }