public static void FixedUpdate(this UnitStateMgrComponent unitStateMgrComponent)
 {
     unitStateMgrComponent.currFrame++; //当前帧前进1
     foreach (var v in unitStateMgrComponent.unitStateComponents)
     {
         v.FixedUpdate();
     }
 }
Beispiel #2
0
        public static void FixedUpdate(this UnitStateComponent unitStateComponent)
        {
            if (!unitStateComponent.haveInited)
            {
                return;
            }
            if (unitStateComponent.unitStatesDic.Count == 0)
            {
                return;
            }
            UnitStateMgrComponent mgr = Game.Scene.GetComponent <UnitStateMgrComponent>();

            Log.Info(string.Format("frame {0} : 玩家位置信息 {1}", mgr.currFrame, unitStateComponent.unit.Position));
            //每间隔3帧发一次数据
            if (mgr.currFrame - unitStateComponent.preSendMsgFrame < UnitStateMgrComponent.sendMsgDelta)
            {
                return;
            }
            unitStateComponent.preSendMsgFrame = mgr.currFrame;

            if (!unitStateComponent.collectInput)
            {
                return;
            }

            //TODO : 这里有大量GC,需要处理
            //if (unitStateComponent.currGetInputFrame - unitStateComponent.preClearInputFrame >= UnitStateComponent.maxFrameCount_SaveStateDelta)
            //{
            //    for (int i = unitStateComponent.preClearInputFrame; i < unitStateComponent.currGetInputFrame - UnitStateComponent.maxFrameCount_SaveStateDelta; i++)
            //    {
            //        if (unitStateComponent.unitStatesDic.ContainsKey(i))
            //        {
            //            unitStateComponent.unitStatesDic.Remove(i);
            //        }
            //    }
            //}

            //每次发送都发最新的的结果
            //var state = unitStateComponent.unitStatesDic[unitStateComponent.currGetInputFrame];

            //foreach (var v in state.commandResults)
            //{
            //    CommandResultInfo_Move commandResultInfo_Move = new CommandResultInfo_Move();
            //    commandResultInfo_Move.Frame = state.frame;

            //    switch (v.Value)
            //    {
            //        case CommandResult_Move result_Move:

            //            continue;
            //    }
            //}
            unitStateComponent.collectInput = false;
        }