예제 #1
0
        private void _Call_NotifyGameStart()
        {
            FSPGameStartParam param = new FSPGameStartParam();

            param.fspParam        = FSPServer.Instance.GetParam();
            param.players         = m_data.players;
            param.customGameParam = m_customGameParam;

            FSPServer.Instance.StartGame();
            FSPServer.Instance.Game.onGameExit += OnGameExit;
            FSPServer.Instance.Game.onGameEnd  += OnGameEnd;

            for (int i = 0; i < m_data.players.Count; i++)
            {
                var        player  = m_data.players[i];
                IPEndPoint address = m_mapUserId2Address[player.userId];
                param.fspParam.sid = player.sid;

                //将玩家加入到FSPServer中
                FSPServer.Instance.Game.AddPlayer(player.id, player.sid);

                byte[] buff = PBSerializer.NSerialize(param);
                RPC(address, RPC_NotifyGameStart, buff);
            }
        }
예제 #2
0
        void _RPC_NotifyGameStart(IPEndPoint remote, byte[] bytes)
        {
            // Debuger.Log(LOG_TAG, "_RPC_NotifyGameStart()");
            FSPGameStartParam data = PBSerializer.Deserialize <FSPGameStartParam>(bytes);

            PVPStartParam startParam = new PVPStartParam();

            startParam.fspParam  = data.fspParam;
            startParam.gameParam = PBSerializer.Deserialize <GameParam>(data.customGameParam);

            for (int i = 0; i < data.players.Count; i++)
            {
                FSPPlayerData player = data.players[i];
                byte[]        buff   = player.customPlayerData;

                PlayerData pb = PBSerializer.Deserialize <PlayerData>(buff);
                pb.playerID = (int)player.id;
                pb.userID   = (uint)player.userId;
                pb.userName = player.name;
                pb.teamID   = (int)player.id;
                startParam.players.Add(pb);

                Debuger.Log(LOG_TAG, "_RPC_NotifyGameStart: {0}", pb.ToString());
            }

            // EventManager.Instance.SendEvent<PVPStartParam>("OnGameStart", startParam);
        }
예제 #3
0
        void Call_NotifyGameStart()
        {
            Debuger.Log(LOG_TAG, "Call_NotifyGameStart()");

            var players = m_data.players;

            FSPGameStartParam param = new FSPGameStartParam();

            param.fspParam = FSPServer.Instance.GetParam();

            foreach (var player in players)
            {
                param.players.Add(player);
            }
            param.customGameParam = m_customGameParam;

            FSPServer.Instance.StartGame();
            FSPServer.Instance.Game.onPlayerExit += _OnPlayerExit;
            FSPServer.Instance.Game.onGameEnd    += _OnGameEnd;

            for (int i = 0; i < players.Count; i++)
            {
                var player = players[i];

                param.fspParam.sid = player.sid;

                //将玩家加入到FSPServer中
                FSPServer.Instance.Game.AddPlayer(player.id, player.sid);

                if (m_mapUserId2Address.ContainsKey(player.userId))
                {
                    IPEndPoint address = m_mapUserId2Address[player.userId];

                    byte[] buff = PBSerializer.Serialize(param);
                    RPC(address, RoomRPC.RPC_NotifyGameStart, buff);
                }
                else
                {
                    Debuger.LogError(LOG_TAG, "User {0} does not have net address", player.userId);
                }
            }
        }