Ejemplo n.º 1
0
    public void HyperDash(ref PlayerState playerState, ref float coolDownTimer, ref bool playerHyperDashing, Vector3 attackDirection,
                          float moveHorizontal, float moveVertical)
    {
        switch (hyperDashState)
        {
        case HyperDashState.Ready:
            //Activate slow motion if we initiated Hyper Dash
            if (!(timeManager.SlowMotionActive()))
            {
                timeManager.ActivateSlowMotion();
            }

            //If player has picked all positions to Hyper Dash to
            if (donePickingPositions)
            {
                //Set up hyper dash information
                hyperDashState = HyperDashState.HyperDashing;
                timer          = hyperDashTime;
                //DetermineAttackDirection() -> may need a modified version of this function
                //hyperDashDirection = playerController.GetMousePositionVector ();

                //timeManager.DoSlowMotion ();
                donePickingPositions = false;                 //reset
                //timeManager.DoSlowMotion();
            }
            else
            {
                //Let player move while in slow motion
                //playerController.MovePlayer ();
                //Let player pick attack positions
                PickHyperDashPositions(attackDirection, ref playerState);
            }
            break;

        case HyperDashState.HyperDashing:
            timer -= Time.unscaledDeltaTime;

            //This bool may not be needed
            playerHyperDashing = true;

            //move towards click position
            playerBody.velocity = Vector2.zero;

            if (positionsToDashTo.Count > 0)
            {
                transform.position = Vector3.MoveTowards(transform.position, positionsToDashTo.Peek(),
                                                         dashDistance * Time.unscaledDeltaTime);
            }


            if (timer <= 0f)
            {
                if (positionsToDashTo.Count > 0)
                {
                    positionsToDashTo.Dequeue();
                    timer = hyperDashTime;
                    break;
                }
                hyperDashState = HyperDashState.Cooldown;

                //Window of time that player can chain another dash
                timer = comboWindowTime;
            }
            break;

        case HyperDashState.Cooldown:
            timer -= Time.unscaledDeltaTime;

            timeManager.DeactivateSlowMotion();
            //playerController.MovePlayer ();

            //If Hyper Dashes aren't done, move on to next attack
            if (positionsToDashTo.Count != 0)
            {
                timer          = hyperDashTime;
                hyperDashState = HyperDashState.Ready;
                //playerHyperDashing = false;
                break;
            }

            if (timer <= 0f)
            {
                timer          = 0;
                hyperDashState = HyperDashState.Ready;
                playerState    = PlayerState.Default;
            }

            break;
        } //switch
    }     //HyperDash()