コード例 #1
0
    public void onRecieveFrame(FRAME_DATA frameMsg)
    {
        curreFrameId = frameMsg.frameid;
//        Debug.Log("id:"+ entity.id +",frameid:" + frameMsg.frameid + ",----------onRecieveFrame tick : " + DateTime.Now.TimeOfDay.ToString());

        bool isEmptyFrame = true;

        for (int i = 0; i < frameMsg.operation.Count; i++)
        {
            var oper = frameMsg.operation[i];
            //           Debug.Log("operation id:" + oper.entityid +"entity:" + entity);

            if (oper.entityid != entity.id)
            {
                continue;
            }

            isEmptyFrame = false;
            var data = new FrameData();
            data.duration = playTime;
            data.operation.Add(oper);

            framePool.Enqueue(new KeyValuePair <UInt32, FrameData>(curreFrameId, data));
            lastFrameData = data;
        }

        if (isEmptyFrame && lastFrameData != null)
        {
            framePool.Enqueue(new KeyValuePair <UInt32, FrameData>(curreFrameId, lastFrameData));
        }
    }
コード例 #2
0
        void Update()
        {
            tsDeltaTime += Time.deltaTime;

            if (tsDeltaTime >= tsDuration)
            {
                tsDeltaTime = 0;

                if (GameData.Instance.frameList.Count > 0)
                {
                    int count = GameData.Instance.frameList.Count;
                    tsDuration = Config.lockedTimeStep / (count <= ThresholdFrame ? 1 : count / ThresholdFrame);

                    FRAME_DATA framedata = GameData.Instance.frameList.Dequeue();

                    currenFrameId = framedata.frameid;

                    if (framedata.operation.Count == 1 && framedata.operation[0].cmd_type == (Byte)SyncFrame.CMD.EMPTY)
                    {
                        for (int i = 0; i < GameData.Instance.RoomPlayers.Count; i++)
                        {
                            int entityId = GameData.Instance.RoomPlayers[i].id;
                            playerBehaviours[entityId].OnSyncedUpdate(currenFrameId, (new FrameFPS()).Serialize());
                        }
                    }
                    else
                    {
                        for (int i = 0; i < framedata.operation.Count; i++)
                        {
                            ENTITY_DATA oper = framedata.operation[i];
                            if (playerBehaviours.ContainsKey(oper.entityid))
                            {
                                playerBehaviours[oper.entityid].OnSyncedUpdate(currenFrameId, oper);
                            }
                        }
                    }

                    foreach (var item in instance.queuedBehaviours)
                    {
                        item.OnSyncedUpdate();
                    }
                    PhysicsManager.instance.UpdateStep();

                    OnSyncedPlayerInput();
                }
            }
        }
コード例 #3
0
        private void Update()
        {
            if (GameData.Instance.frameList.Count > 0)
            {
                FRAME_DATA framedata = GameData.Instance.frameList.Dequeue();

                currenFrameId = framedata.frameid;
                if (currenFrameId < 4000)
                {
                    PhysicsManager.instance.UpdateStep();

                    PlayerBehaviour();

                    //KBEngine.Event.fireOut("recieveFrameTick", new object[] { framedata });
                }
            }
        }
コード例 #4
0
ファイル: World.cs プロジェクト: tangeping/SurvivalShooter
    public void onRecieveFrame(KBEngine.Entity entity, FRAME_DATA frameMsg)
    {
        if (entity.renderObj == null)
        {
            return;
        }

        Debug.Log("world::frameid:" + frameMsg.frameid + ",----------onRecieveFrame tick : " + DateTime.Now.TimeOfDay.ToString());

        CBGlobalEventDispatcher.Instance.TriggerEvent((int)EVENT_ID.EVENT_FRAME_TICK, frameMsg);


//         for (int i = 0; i < frameMsg.operation.Count; i++)
//         {
//             ENTITY_DATA entityData = frameMsg.operation[i];
//
//             CBGlobalEventDispatcher.Instance.TriggerEvent((int)EVENT_ID.EVENT_FRAME_CMD,frameMsg.frameid, entityData);
//
//         }
    }
コード例 #5
0
        void FixedUpdateOld()
        {
            tsDeltaTime += Time.deltaTime;

            if (tsDeltaTime >= tsDuration)
            {
                tsDeltaTime = 0;

                if (GameData.Instance.frameList.Count > 0)
                {
                    int count = GameData.Instance.frameList.Count;
                    tsDuration = Config.lockedTimeStep / (count <= ThresholdFrame ? 1 : count / ThresholdFrame);

                    FRAME_DATA framedata = GameData.Instance.frameList.Dequeue();
                    currenFrameId = framedata.frameid;
                    if (currenFrameId < 4000)
                    {
                        PhysicsManager.instance.UpdateStep();

                        KBEngine.Event.fireOut("recieveFrameTick", new object[] { framedata });
                    }
                }
            }
        }
コード例 #6
0
        // Use this for initialization

        public void LockStepUpate(KBEngine.Entity entity, FRAME_DATA framedata)
        {
            lockstep = AbstractLockstep.NewInstance(Config.lockedTimeStep, Config, PhysicsManager.instance);
        }