Пример #1
0
    void Update()
    {
        testVel = Velocity;

        // abstract out input
        float inputX = Input.GetAxisRaw("Horizontal");

        if (inputX != 0)
        {
            SwitchState(State.Run);

            if (inputX < 0)
            {
                SwitchDir(Direction.Left);
            }
            else
            {
                SwitchDir(Direction.Right);
            }

            moveByXCommand.execute(this);
        }
        else
        {
            SwitchState(State.Idle);
        }

        if (Input.GetKeyDown(KeyCode.Space))
        {
            JumpCommand j = new JumpCommand();
            j.execute(this);
        }
    }
Пример #2
0
    private void Jump()
    {
        JumpCommand jumpCommand = new JumpCommand(PlayerSettings.JumpForce, _heightAtJump);

        jumpCommand.execute(null, _player);
        _jumpCommands.Enqueue(jumpCommand);

        _player.PlaySound("jump");
    }
Пример #3
0
    private void Fall()
    {
        JumpCommand fallCommand = new JumpCommand(_currentFallForce, _heightAtJump);

        fallCommand.execute(null, _player);
        _jumpCommands.Enqueue(fallCommand);

        _currentFallForce += PlayerSettings.DefaultFallAcceleration;
        _currentTimer--;

        if (_player.IsGrounded() && _currentTimer <= 0 && !_undoActive)
        {
            _player.EnterState(new DefaultPlayerState());
        }
    }
Пример #4
0
    void Update()
    {
        testVel = Velocity;

        // abstract out input
        float inputX = Input.GetAxisRaw("Horizontal");

        if (inputX != 0)
        {
            SwitchState(State.Run);

            if (inputX < 0)
                SwitchDir(Direction.Left);
            else
                SwitchDir(Direction.Right);

            moveByXCommand.execute(this);
        }
        else
        {

            SwitchState(State.Idle);
        }

        if (Input.GetKeyDown(KeyCode.Space))
        {
            JumpCommand j = new JumpCommand();
            j.execute(this);
        }
    }