void Update()
 {
     if (DarkRiftAPI.isConnected)
     {
         DarkRiftAPI.Recieve();
     }
 }
Exemple #2
0
    private void FixedUpdate()
    {
        DarkRiftAPI.Recieve();
        //Adjust the simulation rate based on how many frames in advance we have
        //This prevents lag stutters and promotes responsiveness
        //If we have 0 frames ahead, we cannot go ahead (hence the if statement)
        //ForeSight代表还有多少数据帧没有被执行
        if (ForeSight > 0)
        {
            float NewSimRate = (TargetSimulationRate * 1.1f) - (ForeSight * TargetSimulationRate * .1f);
            if (NewSimRate < TargetSimulationRate / 2)            //相当于数据帧缓存超过6那么就加速一倍执行fixedupdate
            {
                NewSimRate  = TargetSimulationRate / 2;
                DoVisualize = false;
            }
            else
            {
                DoVisualize = true;
            }
            Time.fixedDeltaTime = NewSimRate;
            ForeSight--;

            //Get our current frame
            Frame CurrentFrame = Frames [_StepCount];
            //Get the commands of our current frame and execute them
            List <Command> CurrentCommands = Command.Deserialize(CurrentFrame._Data);
            foreach (Command com in CurrentCommands)
            {
                //Executes the command...
                //Explore to TestCommands.cs to find the game logic behind commands
                TestCommands.Execute(com);
            }

            //Spawns a few objects in the beginning
            if (_StepCount == 0)
            {
                TestSpawn();
            }

            //Simulate the physics
            DPhysicsManager.Simulate();

            //Increase our step and advance forward in time
            _StepCount++;
        }
    }
Exemple #3
0
 private void FixedUpdate()
 {
     DarkRiftAPI.Recieve();
 }