Пример #1
0
        public override void Update(TimeSpan timeElapsed)
        {
            if (IsPaused)
            {
                return;
            }

            foreach (var component in ComponentsUpdate.ToArray())
            {
                component.Update(this, timeElapsed);
            }

            var copyList = new List <Console>(Children);

            foreach (var child in copyList)
            {
                child.Update(timeElapsed);
            }
        }
Пример #2
0
        public override void Update(TimeSpan delta)
        {
            if (GameBoard == null)
            {
                return;
            }

            // Update any tick/component on this world object.
            foreach (var component in ComponentsUpdate.ToArray())
            {
                component.Update(this, delta);
            }

            if (_tempPositionMovementValue == Direction.None)
            {
                if (GameBoard.PlayerControlledObject != null)
                {
                    //if (GameBoard.PlayerControlledObject.HasComponent<>)
                    if (GameHost.Instance.Keyboard.IsKeyPressed(Keys.Left))
                    {
                        _tempPositionMovementValue = Direction.Left;
                    }
                    else if (GameHost.Instance.Keyboard.IsKeyPressed(Keys.Right))
                    {
                        _tempPositionMovementValue = Direction.Right;
                    }
                    else if (GameHost.Instance.Keyboard.IsKeyPressed(Keys.Up))
                    {
                        _tempPositionMovementValue = Direction.Up;
                    }
                    else if (GameHost.Instance.Keyboard.IsKeyPressed(Keys.Down))
                    {
                        _tempPositionMovementValue = Direction.Down;
                    }
                }
            }

            // Move the character if requested
            if (_tempPositionMovementValue != Direction.None)
            {
                ((GoRogue.IHasComponents)GameBoard.PlayerControlledObject).GetComponent <ObjectComponents.Movable>()
                .RequestMove(_tempPositionMovementValue, GameBoard, GameBoard.PlayerControlledObject);

                _tempPositionMovementValue = Direction.None;
            }

            // We have a tick this frame; process objects
            if (_tickManager.TickThisFrame)
            {
                // All game objects
                foreach (var item in GameBoard.GetObjects())
                {
                    item.ProcessTickComponents(this);
                }
            }

            foreach (IScreenObject child in new List <IScreenObject>(Children))
            {
                child.Update(delta);
            }
        }