Пример #1
0
    public void saveServerMessages()
    {
        var tsn = new TableStartNotify();
        var ra  = fbGame.gamePlayers.GetEnumerator();

        while (ra.MoveNext())
        {
            tsn.allPlayerInfos.Add(new PlayerInfo
            {
                uid     = 0,
                frameId = (byte)ra.Current.Value.actor.id,
                roleId  = (ushort)ra.Current.Value.actor.roleId,
                team    = (byte)ra.Current.Value.actor.team,
                name    = ra.Current.Value.actor.name,
                ai      = ra.Current.Value.ai
            });
        }
        var fm = new FramesMsg();
        LinkedListNode <ServerFrameMsg> node = serverMessages.First;

        while (node != null)
        {
            fm.allFrameMessages.Add(node.Value);
            node = node.Next;
        }
        BytesStream stream = new BytesStream();

        tsn.marshal(stream);
        fm.marshal(stream);
//         tsn.serialize(stream);
//         fm.serialize(stream);
        ResourceManager.inst.saveToFile(stream, serverMessagesName, ResourceManager.PathType.PT_Resources);
    }
Пример #2
0
    public void onFramesMsg(FramesMsg cmd)
    {
        if (Game.instance.fbGame.frameSyncUpdater.thisType != FrameSyncUpdater.type)
        {
            return;
        }

        Game.instance.fbGame.frameSyncUpdater.updateFrames(cmd, UnityEngine.Time.unscaledTime);
    }
Пример #3
0
    //更新多帧
    public void updateFrames(FramesMsg cmd, float time)
    {
        if (frameSync == null)
        {
            return;
        }

        var count = cmd.allFrameMessages.Count;

        for (int i = 0; i < count; ++i)
        {
            frameSync.pushFrameInputEvent(cmd.allFrameMessages[i]);
            frameSync.udpateFrame(time);
        }
    }
Пример #4
0
    void loadServerMessages()
    {
        if (fbGame != null)
        {
            fbGame.destory();
            fbGame = null;
        }

        //byte[] data = ResourcesManager.instance.getFileData(serverMessagesName);
        byte[]      data   = ConfigResourceLoader.inst.getFileData(serverMessagesName);
        BytesStream stream = new BytesStream(data);

        serverMessages.Clear();

        var tsn = new TableStartNotify();

        tsn.unMarshal(stream);
        //tsn.unserialize(stream);

        fbGame = new FBGame();
        LogicEvent.fire("onFBGameNewed", fbGame);
        fbGame.setupFBGame(tsn.tableId, tsn.mapId);

        fbGame.createCoach(string.Format("{0}/Resources/Config/Behaviac", UnityEngine.Application.dataPath));

        //创建玩家
        var playerCount = tsn.allPlayerInfos.Count;

        for (int i = 0; i < playerCount; ++i)
        {
            var player = tsn.allPlayerInfos[i];
            fbGame.createPlayer(0, player.frameId, player.roleId, player.team, "给我来段FreeStyle", false, player.ai);
        }

        //处理输入消息
        var fm = new FramesMsg();

        fm.unMarshal(stream);
        //fm.unserialize(stream);
        for (int i = 0; i < fm.allFrameMessages.Count; ++i)
        {
            var msg = fm.allFrameMessages[i];

            pushServerMessage(msg);
        }

        fbGame.changeState(GameState.Ready);
    }
Пример #5
0
 public void updateFrames(FramesMsg cmd, float time)
 {
     frameUpdator.updateFrames(cmd, time);
 }