Example #1
0
        protected override void Update(GameTime gameTime)
        {
            if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed || Keyboard.GetState().IsKeyDown(Keys.Escape))
            {
                Exit();
            }

            if (IsActive)
            {
                _keyBoardTracker.TrackState();

                Keys?key;

                while ((key = _keyBoardTracker.GetKeyPress()) != null)
                {
                    switch (key)
                    {
                    case Keys.Right:
                        _map.Rotation = _map.Rotation == 270
                                                ? 0
                                                : _map.Rotation + 90;

                        _eventManager.RaiseEvent(EventType.RotationChanged);
                        break;

                    case Keys.Left:
                        _map.Rotation = _map.Rotation == 0
                                                ? 270
                                                : _map.Rotation - 90;

                        _eventManager.RaiseEvent(EventType.RotationChanged);
                        break;

                    case Keys.Up:
                        if (_keyBoardTracker.Ctrl)
                        {
                            GameState.WaterLevel++;
                        }

                        break;

                    case Keys.Down:
                        if (_keyBoardTracker.Ctrl)
                        {
                            GameState.WaterLevel--;
                        }

                        break;

                    case Keys.E:
                        AppSettings.Instance.Rendering.RenderBoardEdges = !AppSettings.Instance.Rendering.RenderBoardEdges;
                        break;
                    }
                }

                if (Keyboard.GetState().IsKeyDown(Keys.Up) && !_keyBoardTracker.Ctrl)
                {
                    GameState.WaterLevel++;
                }

                if (Keyboard.GetState().IsKeyDown(Keys.Down) && !_keyBoardTracker.Ctrl)
                {
                    GameState.WaterLevel--;
                }

                var movement = _mouseTracker.GetMapMovement();

                _map.Move(movement);
            }

            foreach (var actor in _actors)
            {
                actor.UpdateState();
            }

            base.Update(gameTime);
        }