//////////////////////////////////////////////////////////////////////////////////////////////


    // Update is called once per frame
    void FixedUpdate()
    {
        //Thees will check to see if the palyer would like to use abilities/shoot etc

        //Shooting
        if (Input.GetButtonDown("Ability"))
        {
            primaryAbility.Ability(transform.position, _currentDirection, _playerAnimation, _playerRigidBody);
        }

        //Ultimate coroutine
        if (Input.GetButtonDown("UltimateAbility"))
        {
            //Starting the couroutine
            StartCoroutine("ActivateUltimate");
        }


        //Getting the input from the user
        _movement.x = Input.GetAxisRaw("Horizontal");
        _movement.y = Input.GetAxisRaw("Vertical");

        //If the player has moved, run this
        if (_movement.magnitude > 0)
        {
            _currentDirection = _movement;
            _movement.x       = Input.GetAxisRaw("Horizontal");
            _movement.y       = Input.GetAxisRaw("Vertical");
            _playerAnimation.SetFloat("horizontalMovement", _movement.x);
            _playerAnimation.SetFloat("verticalMovement", _movement.y);
            _playerAnimation.SetBool("isMoving", true);
        }


        //Otherwise set the animation variable to false
        else
        {
            _playerAnimation.SetBool("isMoving", false);
        }


        //Calling the movement script
        Movement();



        //Shift input -> Sprint command
        if (Input.GetKey("left shift") && energy > 0 && _movement.magnitude > 0)
        {
            Sprinting();
            energy--; //Lowering the energy value of the player
        }

        //Adding energy if the energy is under 100
        else if (energy < 100)
        {
            energy = energy + 0.1f;
        }

        //e input -> dash ability
        if (Input.GetKey("e") && energy > 20)
        {
            _playerRigidBody.AddForce(_currentDirection * 10000);
            energy -= 20; // This ability removes 20 energy per use
        }
    }
Esempio n. 2
0
    //Ultimate Ability IEnumeration method
    IEnumerator Shooting()
    {
        yield return(new WaitForSeconds(0.05f));

        primaryAbility.Ability(transform.position + currentDirection.normalized, currentDirection, null, null);
    }