Example #1
0
        public void HandleInteractions()
        {
            if (KeyMouseReader.MouseWorldPosition.X < (Center.X + radius) &&
                KeyMouseReader.MouseWorldPosition.X > (Center.X - radius) &&
                KeyMouseReader.MouseWorldPosition.Y < (Center.Y + radius) &&
                KeyMouseReader.MouseWorldPosition.Y > (Center.Y - radius))
            {
                isHighlighted = true;
                EventManager.Dispatch(new MouseEnterPlanetEvent(this));

                // Display open menu text

                if (KeyMouseReader.KeyHold(Keys.E) && !isDisplayingUI)
                {
                    EventManager.Dispatch(new PlanetInteractionEvent(this));

                    // Open GUI
                    EventManager.Dispatch(new PushStateEvent(new MissionInterface(missions, missionCooldowns)));
                    isDisplayingUI = true;
                }
            }
            else
            {
                if (isHighlighted)
                {
                    isHighlighted = false;
                    EventManager.Dispatch(new MouseExitPlanetEvent());
                }
            }
        }
Example #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();
        }
Example #3
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();
        }