Esempio n. 1
0
        private void CommonHandleFrameImp(FrameObjSBase frameObjS)
        {
            m_CurrentFrameIndex++;

            //先进行操作帧处理
            frameObjS.ControlDataList.ForEach(controlData =>
            {
                m_ContolAgentList.ForEach(agent =>
                {
                    if (agent.IsCanControl(controlData))
                    {
                        agent.HandlerControlData(controlData);
                    }
                });
            });

            //再tick
            m_FrameSynAgentList.ForEach(frameAgent =>
            {
                frameAgent.FrameTick(frameObjS);
            });
            m_LastHandleFrameTime            = Time.time;
            m_isHandle                       = true;
            m_CurrentAuxiliaryFrameTickIndex = 0;
        }
Esempio n. 2
0
        private void HandleSendControlFrame()
        {
            //检测频率为MAX频率
            if (m_ControlFrameObjCDList.Count > 0)
            {
                //发送频率为服务器频率
                if (Time.time - m_LastSendContorlTime >= m_FrameInterval)
                {
                    m_LastSendContorlTime = Time.time;
                    //外部操作,处理并发送操作帧
                    if (m_OnSendContorl != null)
                    {
                        m_OnSendContorl(m_ControlFrameObjCDList);
                    }

                    //如果开启了预测则直接做预测帧
                    if (m_ForecastFrameNum > 0)
                    {
                        //先获取最近一帧数据然后修改里面如果有的agent的操作为目前的操作,其他人的用默认
                        int           currentForcastIndex = m_ForecastFrameObjSDic.Count;
                        int           serverFrameIndex    = m_CurrentFrameIndex - currentForcastIndex;
                        FrameObjSBase forcastFrameObjS    = m_FrameObjSDic[serverFrameIndex - 1];
                        foreach (var controlFrameObj in m_ControlFrameObjCDList)
                        {
                            forcastFrameObjS.ControlDataList.RemoveAll(conrolData => controlFrameObj.Key.IsCanControl(conrolData));
                            forcastFrameObjS.ControlDataList.Add(controlFrameObj.Value);
                        }

                        m_ForecastFrameObjSDic.Add(m_CurrentFrameIndex, forcastFrameObjS);

                        //作为预测的操作为了达到实时响应肯定要马上做帧处理
                        m_LastHandleFrameTime -= m_FrameInterval;
                    }
                }
                m_ControlFrameObjCDList.Clear();
            }
        }
Esempio n. 3
0
 abstract public void FrameTick(FrameObjSBase frameObj);
Esempio n. 4
0
 abstract public bool CompareTo(FrameObjSBase frameObj);