Ejemplo n.º 1
0
        protected override void Update(GameTime gameTime)
        {
            Time.UpdateTime(gameTime);
            InputManager.Update();

            if (InputManager.Exit)
            {
                Exit();
            }

            Time.IsInFixedUpdate  = true;
            timeSinceFixedUpdate += Time.UpdateDeltaTime;
            while (timeSinceFixedUpdate > Time.FixedDeltaTime)
            {
                timeSinceFixedUpdate -= Time.FixedDeltaTime;
                for (int i = 0; i < actors.Count; i++)
                {
                    Actor actor = actors[i];
                    if (!actor.IsDestroyed)
                    {
                        actor.EngineFixedUpdate();
                    }
                }

                CollisionHelper.CheckCollision(colliders);
            }
            Time.IsInFixedUpdate = false;

            for (int i = 0; i < actors.Count; i++)
            {
                Actor actor = actors[i];
                if (!actor.IsDestroyed)
                {
                    actor.EngineUpdate();
                }
            }

            while (toDestroy.Count > 0)
            {
                IDestroyable d = toDestroy[0];

                d.FinalDestroy();

                toDestroy.RemoveAt(0);
                if (d is Actor a)
                {
                    actors.Remove(a);
                }
                else if (d is RectangleCollider rc)
                {
                    colliders.Remove(rc);
                }
            }

            base.Update(gameTime);
        }