示例#1
0
        public void Service()
        {
            //Just do one a tick.
            if (EventQueue.Any())
            {
                if (EventQueue.TryDequeue(out var action))
                {
                    action?.Invoke();
                }
            }

            foreach (var tickable in CurrentGameTickables)
            {
                tickable.Tick();
            }

            long currentMilliseconds = TimeService.CurrentTimeInMilliseconds();

            if (LastMilliseconds == -1)
            {
                LastMilliseconds = currentMilliseconds;
            }
            else if (currentMilliseconds - 600 >= LastMilliseconds)
            {
                //It's been 600ms, time for another tick.
                LastMilliseconds = currentMilliseconds;

                foreach (var fixedTickable in CurrentGameFixedTickables)
                {
                    fixedTickable.OnGameFixedTick();
                }
            }
        }
示例#2
0
        public override void processGameLoop()
        {
            base.processGameLoop();

            long currentMilliseconds = TimeService.CurrentTimeInMilliseconds();

            if (LastMilliseconds == -1)
            {
                LastMilliseconds = currentMilliseconds;
            }
            else if (currentMilliseconds - 600 >= LastMilliseconds)
            {
                //It's been 600ms, time for another tick.
                LastMilliseconds = currentMilliseconds;
                ProcessGameTick();
            }
        }