Ejemplo n.º 1
0
        protected override void Update(GameTime gameTime)
        {
            if (shouldQuit)
            {
                Exit();
            }

            KeyMouseReader.Update();

            if (KeyMouseReader.KeyPressed(Keys.Back))
            {
                Serializer.LoadGame();
            }
            if (KeyMouseReader.KeyPressed(Keys.Enter))
            {
                Serializer.SaveGame();
            }

            stateStack.Update(gameTime);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// If you press the 1 or 2 key you will change the wepon type that you're using.
        /// </summary>
        private void ChangeWeapon()
        {
            if (KeyMouseReader.KeyPressed(Keys.D1) && weapons[0].available) //KeyMouseReader.KeyPressed(Keys.None)
            {
                equipedWeapon = weapons[0];
                EventManager.Dispatch(new ChangeIconEvent(0));
            }

            if (KeyMouseReader.KeyPressed(Keys.D2) && weapons[1].available)
            {
                equipedWeapon = weapons[1];
                EventManager.Dispatch(new ChangeIconEvent(1));
            }

            if (KeyMouseReader.KeyPressed(Keys.D3) && weapons[2].available)
            {
                equipedWeapon = weapons[2];
                EventManager.Dispatch(new ChangeIconEvent(2));
            }
        }
Ejemplo n.º 3
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();
        }
Ejemplo n.º 4
0
        /// <summary>
        /// This handles all the inputs the player can made with movement, change weapon, fire etc.
        /// </summary>
        /// <param name="gameTime"></param>
        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.KeyPressed(Keys.J))
            {
                EventManager.Dispatch(new PushStateEvent(new Journal(Status.Missions)));
            }

            if (KeyMouseReader.LeftHold() && !hasFocusOnPlanet)
            {
                equipedWeapon.Fire(Center, KeyMouseReader.MouseWorldPosition, TypeOfBullet.Player, gameTime);
                EventManager.Dispatch(new PlayerShootEvent(Position, 1337));
            }

            ChangeWeapon();
        }