コード例 #1
0
ファイル: Menu.cs プロジェクト: Pfizerr/G01_Perseus
        public void Update(GameTime gameTime)
        {
            hoveredOption = null;

            for (int i = 0; i < Options.Count; i++)
            {
                Rectangle rect = GetBounds(i);
                if (rect.Contains(KeyMouseReader.MouseScreenPosition))
                {
                    hoveredOption = Options[i];
                    if (KeyMouseReader.LeftClick())
                    {
                        Options[i].Action();
                    }
                }
            }
        }
コード例 #2
0
        public void HandleInput(GameTime gameTime)
        {
            direction = Vector2.Zero;

            direction.Y += KeyMouseReader.KeyHold(Keys.W) ? -1 : 0;
            direction.Y += KeyMouseReader.KeyHold(Keys.S) ? 1 : 0;
            direction.X += KeyMouseReader.KeyHold(Keys.A) ? -1 : 0;
            direction.X += KeyMouseReader.KeyHold(Keys.D) ? 1 : 0;

            direction = direction.LengthSquared() > 1 ? Vector2.Normalize(direction) : direction;

            if (KeyMouseReader.LeftClick() && !hasFocusOnPlanet)
            {
                //EntityManager.CreateBullet(this, Center, Input.MouseWorldPosition);

                equipedWeapon.Fire(Center, KeyMouseReader.MouseWorldPosition, rotation, TypeOfBullet.Player, gameTime);

                EventManager.Dispatch(new PlayerShootEvent(Position, 1337));
            }

            ChangeWeapon();
        }