예제 #1
0
        public bool HandleKeyboard(Keys key, ModifierState modifierState)
        {
            Direction dirToMove = Controls.Move(key);
            bool      handled   = true;

            if (dirToMove == Direction.NONE)
            {
                switch (key)
                {
                case Keys.Enter:
                    if (_targetValidator(TargetPos))     // CurrentPos is valid
                    {
                        InputStack.Remove(this);
                        GrimDank.Instance.TestLevel.Targeter = null;
                        _onTargetSelected(TargetPos);
                    }
                    else
                    {
                        MessageLog.Write("Invalid target.");
                    }

                    break;

                case Keys.Add:
                    // This works even if we started at -1.
                    if (_validTargets.Count != 0)
                    {
                        _currentTargetIndex = MathHelpers.WrapAround(_currentTargetIndex + 1, _validTargets.Count);
                        TargetPos           = _validTargets[_currentTargetIndex];
                    }
                    break;

                case Keys.Escape:
                    InputStack.Remove(this);
                    GrimDank.Instance.TestLevel.Targeter = null;
                    break;

                default:
                    handled = false;
                    break;
                }
            }
            // Here we purposely do NOT reset the _currentTargetIndex to -1, to preserve the starting point in case the user presses + sometime again
            // in the future (we pick up where we left off)
            else
            {
                TargetPos += dirToMove;
            }

            return(handled);
        }
예제 #2
0
파일: GrimDank.cs 프로젝트: TimyJ/GrimDank
        /// <summary>
        /// LoadContent will be called once per game and is the place to load
        /// all of your content.
        /// </summary>
        protected override void LoadContent()
        {
            // Create a new SpriteBatch, which can be used to draw textures.
            spriteBatch = new SpriteBatch(GraphicsDevice);

            //load font from the content manager
            var fontTexture = Content.Load <Texture2D>("font12x12");

            font12x12               = new TextureFont(fontTexture, 12, 16);
            MapRenderer             = new MapRenderer(font12x12, TestLevel);
            MapRenderer.Camera.Area = MapRenderer.Camera.Area.CenterOn(Player.Position);
            MessageLog.Write("Font Loaded");

            fpsFont = Content.Load <SpriteFont>("_spritefont");

            hudTest = Content.Load <Texture2D>("BetterEnergyBar");

            reticle = Content.Load <Texture2D>("reticles");

            // TODO: use this.Content to load your game content here
        }