Esempio n. 1
0
    private void ReadControlAxes()
    {
        if (ControlManager.NoControlsPressed)
        {
            Motion.HaltEntity();
            return;
        }

        float verticalDirection   = ControlManager.GetAxis(VerticalAxis);
        float horizontalDirection = ControlManager.GetAxis(HorizontalAxis);

        MotionDirection direction = MotionDirection.None;

        if (verticalDirection > 0.0f)
        {
            if (Mathf.Abs(horizontalDirection - 0.0f) < 0.001f)
            {
                direction = MotionDirection.North;
            }
            else if (horizontalDirection > 0.0f)
            {
                direction = MotionDirection.NorthEast;
            }
            else if (horizontalDirection < 0.0f)
            {
                direction = MotionDirection.NorthWest;
            }
        }
        else if (verticalDirection < 0.0f)
        {
            if (Mathf.Abs(horizontalDirection - 0.0f) < 0.001f)
            {
                direction = MotionDirection.South;
            }
            else if (horizontalDirection > 0.0f)
            {
                direction = MotionDirection.SouthEast;
            }
            else if (horizontalDirection < 0.0f)
            {
                direction = MotionDirection.SouthWest;
            }
        }
        else if (Mathf.Abs(verticalDirection - 0.0f) < 0.001f)
        {
            if (horizontalDirection > 0.0f)
            {
                direction = MotionDirection.East;
            }
            else if (horizontalDirection < 0.0f)
            {
                direction = MotionDirection.West;
            }
        }

        FormattedDebugMessage(LogLevel.Info, "Vertical: {0} Horizontal: {1} D-Value: {2}", verticalDirection, horizontalDirection, direction.ToString());

        Motion.RotateEntity(direction);
        Motion.MoveEntity();
    }
    private void GetInput()
    {
        CheckWeaponFire();

        float walkAmount   = _controls.GetAxis(WalkAxis);
        float strafeAmount = _controls.GetAxis(StrafeAxis);

        PlanarMotion = new Vector3(strafeAmount, 0, walkAmount);
        _movement.ProcessPlanarMovement(PlanarMotion);

        bool jumpPressed  = _controls.GetAxisDown(JumpAxis);
        bool jumpHeld     = (_controls.GetAxis(JumpAxis) > 0.0f) && !jumpPressed;
        bool jumpReleased = _controls.GetAxisUp(JumpAxis);

        if (jumpPressed &&
            !_movement.IsJumping &&
            JumpCount > 0 &&
            JumpLockout.CanAttempt())
        {
            _movement.PerformJump();
            JumpCount--;
            JumpLockout.NoteLastOccurrence();
        }

        if (jumpHeld && _movement.IsJumping)
        {
            _movement.PerformJump();
        }

        if (jumpReleased && _movement.IsJumping)
        {
            _movement.AbortJump();
        }

        //result = PlayerActionStates.Idle;

        //if (walkAmount > 0)
        //    result = PlayerActionStates.Walk;
        //else if (walkAmount < 0)
        //    result = PlayerActionStates.Backstep;

        //if (strafeAmount > 0)
        //    result = PlayerActionStates.StrafeRight;
        //else if (strafeAmount < 0)
        //    result = PlayerActionStates.StrafeLeft;
    }
Esempio n. 3
0
    protected void DetectHorizontalMovement()
    {
        if (!canMove)
        {
            return;
        }

        if (_control.GetAxis(HorizontalAxis) > 0)
        {
            _isMovingHorizontally = true;
            isFacingRight         = true;
        }

        if (_control.GetAxis(HorizontalAxis) < 0)
        {
            _isMovingHorizontally = true;
            isFacingRight         = false;
        }

        if (_isMovingHorizontally)
        {
            _movement.MoveHorizontally(isFacingRight);
        }
    }
Esempio n. 4
0
    private void Run()
    {
        horizontal = cmn.GetAxis("Horizontal");
        if (!afk)
        {
            prb.velocity = new Vector2(movespeed * horizontal, prb.velocity.y);
        }
        else
        {
            if (horizontal != 0)
            {
                pan.SetTrigger("btk");
            }
        }

        if ((horizontal > 0 && !lookingRight) || (horizontal < 0 && lookingRight))
        {
            Flip();
        }
    }
Esempio n. 5
0
    public void DetectChangedSpells()
    {
        float spellChange = _controls.GetAxis(ChangeSpellAxis);

        if (spellChange == 0)
        {
            return;
        }

        if (Time.time < _lastSpellToggle + _spellToggleLockout)
        {
            return;
        }

        _lastSpellToggle = Time.time;

        // Supports a positive or negative axis!
        if (spellChange > 0)
        {
            _currentSpell++;
            if (_currentSpell == CharacterSpells.Count)
            {
                _currentSpell = 0;
            }
        }
        else
        {
            _currentSpell--;
            if (_currentSpell == -1)
            {
                _currentSpell = CharacterSpells.Count - 1;
            }
        }

        DebugMessage("Swapped to spell: " + ActiveSpell.Name);
        _spellInterface.UpdateInterface(ActiveSpell);
    }