Beispiel #1
0
    void performDash()
    {
        AudioManager.Instance.Play("DashSound");
        currentDistortion = 40.0f;

        dash          = true;
        currentSpeed *= 4;
        dashTrail.StartTrail();
    }
Beispiel #2
0
    private void FixedUpdate()
    {
        if (!dashing && !charging)
        {
            rb.velocity   = direction * speed; //Velocity is the product of the set speed with the raw Axis Input
            currentCharge = 0f;

            if ((deltatime > 0.3f) && (direction != Vector2.zero))
            {
                switch (theme)
                {
                case "ice":
                    source.PlayOneShot(moveSand, 1.0f);
                    break;

                case "grass":
                    source.PlayOneShot(moveGrass, 1.0f);
                    break;

                case "beach":
                    source.PlayOneShot(moveSand, 1.0f);
                    break;

                default:
                    source.PlayOneShot(moveGrass, 1.0f);
                    break;
                }
                deltatime = 0.0f;
            }
            deltatime += Time.deltaTime;
        }
        else if (charging)
        {
            rb.velocity   = direction * speed * dashSlow;               //The Character is slowed,per default by 25%
            currentCharge = currentCharge + (chargeRatePerSecond / 50); //Charge goes up by 0.25 in one Second
            _uiController.DashLevelOne.fillAmount = currentCharge;
            if (currentCharge >= 1 && currentCharge < 2)
            {
                _uiController.DashLevelOne.fillAmount = 1f;
                _uiController.DashLevelTwo.fillAmount = currentCharge - 1f;
            }
            else if (currentCharge >= 2 && currentCharge < 3)
            {
                _uiController.DashLevelTwo.fillAmount   = 1f;
                _uiController.DashLevelTwo.fillAmount   = 1f;
                _uiController.DashLevelThree.fillAmount = currentCharge - 2f;
            }
            else if (currentCharge >= 3) //The Current Charge can not go over 3
            {
                currentCharge = 3;
                _uiController.DashLevelThree.fillAmount = 1f;
                charging = false;
                dashing  = true;
            }
        }
        else if (dashing)
        {
            animator.SetBool("dashing", true);
            if (currentCharge >= 1 && currentCharge < 2)
            {
                Dash(dashMultiplierLevelOne, 1);
            }
            else if (currentCharge >= 2 && currentCharge < 3)
            {
                Dash(dashMultiplierLevelTwo, 2);
            }
            else if (currentCharge == 3)
            {
                Dash(dashMultiplierLevelThree, 3);
            }
            else
            {
                // Break, if charge not big enough
                animator.SetBool("dashing", false);
                animator.SetBool("charging", false);
                dashing       = false;
                currentCharge = 0f;
                _uiController.DashLevelOne.fillAmount   = 0f;
                _uiController.DashLevelTwo.fillAmount   = 0f;
                _uiController.DashLevelThree.fillAmount = 0f;
            }
        }

        if (lastFrameDashing && !dashing)
        {
            _dashTrail.StopTrail();
        }
        if (!lastFrameDashing && dashing)
        {
            _dashTrail.StartTrail();
        }

        lastFrameDashing = dashing;
        lastFrameDashing = dashing;
    }