Пример #1
0
 public void ChangeSkill(ExtraSkill.Skill skill)
 {
     if (skill.Equals(ExtraSkill.Skill.DoubleJump))
     {
         _skillSlot.sprite = _jumpSlot;
     }
     else if (skill.Equals(ExtraSkill.Skill.Run))
     {
         _skillSlot.sprite = _runSlot;
     }
     else
     {
         _skillSlot.sprite = _emptySlot;
     }
 }
Пример #2
0
    public void ChangeCurrentSkill(ExtraSkill.Skill skill)
    {
        _skill = skill;

        if (_skill.Equals(ExtraSkill.Skill.Run))
        {
            _moveAcceleration = 2 * StandardValues.PlayerMoveAcceleration;
            _skillPanel.ChangeSkill(skill);
        }
        else
        {
            _moveAcceleration = StandardValues.PlayerMoveAcceleration;
            _skillPanel.ChangeSkill(skill);
        }

        var timer = FindObjectOfType <Timer>();

        if (timer != null)
        {
            timer.GetComponent <Timer>().reset();
        }
        else
        {
            Instantiate(Resources.Load("Timer"), GameObject.Find("SkillPanel").transform);
        }
    }
Пример #3
0
    private void Update()
    {
        _grounded            = Physics2D.Linecast(transform.position, _groundChecker.position, 1 << LayerMask.NameToLayer("Jumpable") | 1 << LayerMask.NameToLayer("Box"));
        _horizontalMoveInput = CrossPlatformInputManager.GetAxis("Horizontal");
        _verticalMoveInput   = CrossPlatformInputManager.GetAxis("Vertical");
        _jumpPressed         = CrossPlatformInputManager.GetButtonDown("Space");
        _changeWeaponPressed = CrossPlatformInputManager.GetButtonDown("Change");

        _attackPressed  = CrossPlatformInputManager.GetButtonDown("RCtrl");
        _targetDistance = (IsDead) ? Vector2.zero : Vector2.right * Time.deltaTime * _moveAcceleration * _horizontalMoveInput;

        if (_attackPressed && !IsDead)
        {
            Attack(_damage);
        }

        if (!_onLadder)
        {
            _rigidbody.gravityScale = 1;
            if (_horizontalMoveInput != 0)
            {
                _anim.SetBool("isWalking", true);
                _anim.SetFloat("inputX", CrossPlatformInputManager.GetAxisRaw("Horizontal"));
            }
            else
            {
                _anim.SetBool("isWalking", false);
            }
        }
        else
        {
            _rigidbody.gravityScale = 0;
            if (_verticalMoveInput != 0)
            {
                _rigidbody.velocity = new Vector2(0, _climbAcceleration * _verticalMoveInput);
            }
        }

        //check if player is on ground and if space has been pressed
        if (_grounded)
        {
            _anim.SetBool("isFalling", false);
            _anim.SetBool("isJumping", false);
            if (_jumpPressed)
            {
                _grounded = false;
                _anim.SetBool("isJumping", true);
                _canRejump           = _skill.Equals(ExtraSkill.Skill.DoubleJump);
                _rigidbody.velocity += Vector2.up * _jumpAcceleration;
            }
            else if (_anim.GetBool("isJumping"))
            {
                _anim.SetBool("isJumping", false);
            }
        }
        else if (!_grounded)
        {
            if (_jumpPressed && _canRejump)
            {
                _canRejump = false;
                transform.Translate(new Vector3(_targetDistance.x, 0, 0), Space.World);
                _rigidbody.velocity  = new Vector2(_rigidbody.velocity.x, 0);
                _rigidbody.velocity += Vector2.up * _jumpAcceleration;
            }
            else if (_rigidbody.velocity.y < 0)
            {
                _anim.SetBool("isFalling", true);
            }
            else
            {
                _anim.SetBool("isFalling", false);
            }
        }

        if (_changeWeaponPressed)
        {
            ChangeWeapon();
        }
    }