Exemplo n.º 1
0
        private void MoveTowards(Vector2 to)
        {
            Vector2 v = to * MovementSpeed;

            if (IsPlayerSucking())
            {
                v = to * MovementSpeed * Tweak.SUCK_SPEED_MULTIPLIER;
            }
            DynamicBody.ApplyForce(v);
        }
Exemplo n.º 2
0
        public void HandleKeyboardInput()
        {
            _movementDirection = Vector2.Zero;
            if (Input.ButtonJustDownMapped((int)Controls.Select))
            {
                CurrentWeapon = CurrentWeapon == Weapon.Melee ? Weapon.Pistol : Weapon.Melee;
                SwitchToIdleOrMoving(CurrentState);
            }

            switch (CurrentState)
            {
            case State.Idle:
            case State.Run:
            {
                if (Input.ButtonDownMapped((int)Controls.Attack1))
                {
                    SwitchToAttacking();
                    break;
                }

                _movementDirection = GetFacingDirectionFromControls();
                if (_movementDirection != Vector2.Zero)
                {
                    _sensorRotation = MathHelper.ToDegrees((float)Math.Atan2(_movementDirection.Y, _movementDirection.X) - MathHelper.PiOver2);
                    _movementDirection.Normalize();
                    DynamicBody.ApplyForce(_movementDirection * MOVEMENT_FORCE);
                }

                break;
            }

            case State.Attack:
            {
                if (Input.ButtonDownMapped((int)Controls.Attack1))
                {
                    SuckIn();
                }
                else
                {
                    SwitchToMoving();
                }
                break;
            }
            }
        }
Exemplo n.º 3
0
        public void HandleKeyboardInput()
        {
            _movementDirection = Vector2.Zero;

            switch (CurrentState)
            {
            case State.Eating:
                break;

            case State.Idle:
            case State.Moving:
            {
                if (Input.ButtonDownMapped((int)Controls.Suck))
                {
                    SwitchToSucking();
                    SuckIn();
                    break;
                }

                _movementDirection = GetFacingDirectionFromControls();
                if (_movementDirection != Vector2.Zero)
                {
                    _sensorRotation = MathHelper.ToDegrees((float)Math.Atan2(_movementDirection.Y, _movementDirection.X) - MathHelper.PiOver2);
                    _movementDirection.Normalize();
                    DynamicBody.ApplyForce(_movementDirection * MOVEMENT_FORCE);
                }

                break;
            }

            case State.Sucking:
            {
                if (Input.ButtonDownMapped((int)Controls.Suck))
                {
                    SuckIn();
                }
                else
                {
                    SwitchToMoving();
                }
                break;
            }
            }
        }
Exemplo n.º 4
0
        private void MoveTowards(Vector2 to)
        {
            Vector2 v = to * MovementSpeed;

            DynamicBody.ApplyForce(v);
        }