public void Dash()
 {
     dashAbility.Dash(rBody, moveDirection, dashAmount, dashFilter);
 }
Ejemplo n.º 2
0
    //===========UNUSED================
    //May need it if I decide to implement bow and arrow
    //Makes the Player look towards a given point on the world map (like the mouse position)

    /*
     * public void LookTowardsPoint(Vector3 target) {
     *      //Rotate towards target
     *      target = target - transform.position;
     *
     *      float angle = Mathf.Atan2 (target.y, target.x) * Mathf.Rad2Deg;
     *
     *      //transform.rotation = Quaternion.Euler (new Vector3 (0, 0, angle));
     *      transform.rotation = Quaternion.AngleAxis(angle, Vector3.forward);
     *
     * }
     */

    //Handles and updates the Player logic with a state machine
    public void UpdatePlayer()
    {
        //Animator bools
        playerMoving          = false;
        playerDashing         = false;
        playerAttacking       = false;
        playerSprintAttacking = false;

        //Switch Design: Make each Ability class/state take in the playerState
        //  and modify it only when that Ablity action is done executing

        switch (playerState)
        {
        /*
         * case PlayerState.Default:
         *      if (controllerPref == ControllerPreference.KeyboardMouse)
         *              GetKeyboardInput ();
         *      else
         *              GetControllerInput ();
         *
         *      MovePlayer ();
         *      break;
         */

        case PlayerState.Default:
            basicMovement.Idle(ref playerState);
            anim.Play("Idle Direction");
            break;

        case PlayerState.Moving:
            basicMovement.Move(ref playerState);
            anim.Play("Player Movement");
            break;

        case PlayerState.Dashing:
            //Note: Normalize first Dash because Player may be accelerating or slowing down, causing shorter dashes
            dashAbility.Dash(basicMovement.GetLastMove().normalized, ref playerState, ref playerDashing);
            break;

        case PlayerState.Attacking:
            attackAbility.Attack(ref playerState, basicMovement.GetAttackDirection());
            break;

        case PlayerState.ChargedAttacking:
            chargedAttackAbility.ChargeAttack(ref playerState, basicMovement.GetAttackDirection());
            break;

        case PlayerState.SprintAttacking:
            sprintAttackAbility.SprintAttack(ref playerState, basicMovement.GetAttackDirection());
            break;

        case PlayerState.Shielding:
            shieldAbility.Shield(ref playerState);
            break;

        case PlayerState.Grabbing:
            grabAbility.Grab(ref playerState);
            break;

        case PlayerState.DodgeRolling:
            dodgeAbility.DodgeRoll(ref playerState, shieldAbility.GetDodgeRollDirection());
            break;

        case PlayerState.Flinch:
            flinchState.Flinch(ref playerState);
            break;

        case PlayerState.Falling:
            fallState.Fall(ref playerState);
            break;

        case PlayerState.Interacting:
            interactState.Interact(ref playerState);
            break;

        case PlayerState.Dialogue:
            dialogueState.Dialogue(ref playerState);
            break;

        case PlayerState.WarpStrike:
            warpStrikeAbility.WarpStrike(ref playerState, basicMovement.GetAttackDirection());
            break;

        case PlayerState.HyperDashing:
            //if (abilityHyperDash.hyperDashingActive)
            ////////attackDirection = GetMousePositionVector ();
            //abilityHyperDash.HyperDash (ref playerState, ref hyperDashCoolDownTimer, ref playerHyperDashing, attackDirection,
            //	                        moveHorizontal, moveVertical);
            break;
        }         //switch

        //Let the animator know what just happened in this frame (like which way the player was facing
        anim.SetFloat("MoveX", basicMovement.GetLastMove().x);
        anim.SetFloat("MoveY", basicMovement.GetLastMove().y);
        anim.SetBool("PlayerMoving", basicMovement.GetPlayerMoving());
        anim.SetFloat("LastMoveX", basicMovement.GetLastMove().x);
        anim.SetFloat("LastMoveY", basicMovement.GetLastMove().y);
        anim.SetBool("PlayerDashing", playerDashing);
        anim.SetBool("PlayerAttacking", attackAbility.GetPlayerAttacking());
        //anim.SetInteger ("PlayerAttackDirection", (int)playerDirections);
        //anim.SetBool ("PlayerSprinting", playerSprinting);

        //anim.SetInteger ("PlayerAttackDirection", (int)playerDirection);
    }