Exemple #1
0
        protected override void OnUpdating()
        {
            base.OnUpdating();

            if (!MapEvents.Any(obj => obj.IsUpdated))
            {
                foreach (MapObject item in Objects.Where(obj => obj is MapObject mapObject && (mapObject.GetGlobalPosition() - Player.Position).Length > 2500 && mapObject.IsUpdated))
                {
                    item.IsUpdated = false;
                    if (item.CollisionShape is PhysicalRectangleShape shape)
                    {
                        shape.IsActive = false;
                    }
                }

                foreach (MapObject item in Objects.Where(obj => obj is MapObject mapObject && (mapObject.GetGlobalPosition() - Player.Position).Length <= 2500 && !mapObject.IsUpdated))
                {
                    item.IsUpdated = true;
                    if (item.CollisionShape is PhysicalRectangleShape shape)
                    {
                        shape.IsActive = true;
                    }
                }
            }

            UpdateOtherPlayers();

            if (!SavePoints.Any(obj => obj.IsActive))
            {
                PhysicalWorld?.Update();
            }

            UpdateCollision();
        }
Exemple #2
0
        internal void Update(GameTime gameTime)
        {
            _physicalWorld.Update(gameTime);
            var gameObjectsToUpdate = _gameObjects.ToArray();

            foreach (var go in gameObjectsToUpdate)
            {
                go.Update(gameTime);
            }
            _camera.Update(gameTime);
            foreach (var go in gameObjectsToUpdate)
            {
                go.UpdateCoroutines(gameTime);
            }
            _camera.Update(gameTime);
            _particles.Update(gameTime);
        }