Beispiel #1
0
    public static void SendStartMsg(WorldBase world)
    {
        //获取所有的Player组件,并派发
        List <EntityBase> list = world.GetEntityList(s_playerFilter);

        StartSyncMsg startMsg = CreateStartMsg(world);

        SyncEntityMsg playerInfo = new SyncEntityMsg();

        playerInfo.frame = world.FrameCount;
        playerInfo.infos = new List <EntityInfo>();

        for (int i = 0; i < list.Count; i++)
        {
            playerInfo.infos.Add(CreatePlayerComponentInfo(list[i]));
        }

        for (int i = 0; i < list.Count; i++)
        {
            ConnectionComponent cc          = list[i].GetComp <ConnectionComponent>();
            SyncEntityMsg       serviceInfo = CreateServiceMsg(world, cc.m_session);

            ProtocolAnalysisService.SendMsg(cc.m_session, playerInfo);
            ProtocolAnalysisService.SendMsg(cc.m_session, serviceInfo);
            ProtocolAnalysisService.SendMsg(cc.m_session, startMsg);
        }
    }
    void ReceviceStartSyncMsg(StartSyncMsg msg, params object[] objs)
    {
        Debug.Log("Start Msg " + msg.frame);

        m_world.FrameCount  = msg.frame;
        m_world.IsStart     = true;
        m_world.EntityIndex = msg.createEntityIndex;
        m_world.SyncRule    = msg.SyncRule;

        m_world.m_isRecalc = true;

        WorldManager.IntervalTime = msg.intervalTime;

        //立即执行创建操作
        m_world.LazyExecuteEntityOperation();

        //执行未处理的命令
        GameDataCacheComponent gdcc = m_world.GetSingletonComp <GameDataCacheComponent>();

        for (int i = 0; i < gdcc.m_noExecuteCommandList.Count; i++)
        {
            for (int j = 0; j < gdcc.m_noExecuteCommandList[i].msg.Count; j++)
            {
                RecordCommand(gdcc.m_noExecuteCommandList[i].msg[j]);
            }
        }

        m_world.m_isRecalc = false;

        AdvanceCalc(msg.frame + msg.advanceCount); //提前计算一帧

        ConnectStatusComponent csc = m_world.GetSingletonComp <ConnectStatusComponent>();

        csc.aheadFrame = msg.advanceCount;
    }
        public void PushStartSyncMsg(SyncSession session)
        {
            StartSyncMsg msg = new StartSyncMsg();

            msg.frame        = m_world.FrameCount + 1;
            msg.intervalTime = UpdateEngine.IntervalTime;

            ProtocolAnalysisService.SendMsg(session, msg);
        }
    void ReceviceStartSyncMsg(StartSyncMsg msg, params object[] objs)
    {
        Debug.Log("StartSyncMsg " + msg.frame);

        m_world.FrameCount = msg.frame;
        m_world.IsStart    = true;

        WorldManager.IntervalTime = msg.intervalTime;
    }
Beispiel #5
0
        public void PushStartSyncMsg(SyncSession session)
        {
            Debug.Log("PushStartSyncMsg");

            StartSyncMsg msg = new StartSyncMsg();

            msg.frame        = m_world.FrameCount + 1;
            msg.intervalTime = UpdateEngine.IntervalTime;

            session.SendMsg(msg);
        }
    void PushStartSyncMsg(SyncSession session)
    {
        Debug.Log("PushStartSyncMsg " + m_world.FrameCount);

        StartSyncMsg msg = new StartSyncMsg();

        msg.frame             = m_world.FrameCount;
        msg.advanceCount      = 1; //客户端提前一帧
        msg.intervalTime      = UpdateEngine.IntervalTime;
        msg.createEntityIndex = m_world.EntityIndex;

        ProtocolAnalysisService.SendMsg(session, msg);
    }
Beispiel #7
0
    public static StartSyncMsg CreateStartMsg(WorldBase world)
    {
        Debug.Log("PushStartSyncMsg " + world.FrameCount);

        StartSyncMsg msg = new StartSyncMsg();

        msg.frame             = world.FrameCount;
        msg.advanceCount      = 1; //客户端提前一帧
        msg.intervalTime      = UpdateEngine.IntervalTime;
        msg.createEntityIndex = 0;
        msg.randomSeed        = world.m_RandomSeed;

        return(msg);
    }
Beispiel #8
0
    void SendReconnectMsg(ConnectionComponent comp)
    {
        float time = ServiceTime.GetServiceTime();

        //发送游戏全部数据
        PushAllEnityData(comp);

        //发送单例数据
        PushSingleComponentData(comp);

        //发送游戏开始消息
        StartSyncMsg startMsg = CreateStartMsg(m_world);

        ProtocolAnalysisService.SendMsg(comp.m_session, startMsg);

        Debug.Log("重连时间 " + (ServiceTime.GetServiceTime() - time));
    }
Beispiel #9
0
    void ReceviceStartSyncMsg(StartSyncMsg msg, params object[] objs)
    {
        Debug.Log("StartSyncMsg " + msg.frame);

        m_world.FrameCount  = msg.frame;
        m_world.IsStart     = true;
        m_world.EntityIndex = msg.createEntityIndex;
        m_world.SyncRule    = msg.SyncRule;

        WorldManager.IntervalTime = msg.intervalTime;

        //执行未处理的命令
        GameDataCacheComponent gdcc = m_world.GetSingletonComp <GameDataCacheComponent>();

        for (int i = 0; i < gdcc.m_noExecuteCommandList.Count; i++)
        {
            ReceviceCommandMsg((T)gdcc.m_noExecuteCommandList[i]);
        }

        AdvanceCalc(msg.frame + msg.advanceCount); //提前计算一帧
    }
    void ReceviceStartSyncMsg(StartSyncMsg msg, params object[] objs)
    {
        ConnectStatusComponent csc = m_world.GetSingletonComp <ConnectStatusComponent>();

        csc.confirmFrame = msg.frame; //从目标帧之后开始计算

        //Debug.Log("ReceviceStartSyncMsg " + csc.confirmFrame);

        m_world.FrameCount = msg.frame;
        m_world.IsStart    = true;
        //m_world.EntityIndex = msg.createEntityIndex;
        m_world.SyncRule = msg.SyncRule;

        WorldManager.IntervalTime = msg.intervalTime;
        m_world.IsCertainty       = true;
        //立即执行创建操作
        m_world.LazyExecuteEntityOperation();
        m_world.IsCertainty = false;

        m_world.m_RandomSeed = msg.randomSeed;

        m_world.ClearAll();

        //执行未处理的命令
        GameDataCacheComponent gdcc = m_world.GetSingletonComp <GameDataCacheComponent>();

        for (int i = 0; i < gdcc.m_noExecuteCommandList.Count; i++)
        {
            ReceviceCommandMsg((T)gdcc.m_noExecuteCommandList[i]);
        }

        m_world.Record(m_world.FrameCount);

        Recalc();
        AdvanceCalc(msg.frame + msg.advanceCount); //提前计算一帧

        csc.aheadFrame = msg.advanceCount;
    }
Beispiel #11
0
    void ReceviceStartSyncMsg(StartSyncMsg msg, params object[] objs)
    {
        SyncDebugData data = GetSyncData(msg.frame);

        data.StartSyncMsgCount++;
    }