FadeOut() public method

public FadeOut ( float fadeTime ) : void
fadeTime float
return void
Esempio n. 1
0
    //

    // Update is called once per frame
    void Update()
    {
        if (Input.GetKeyDown(KeyCode.Alpha1))
        {
            animationController.PlayAnimation(animationAttack01);
            // swordSwipe.StartTrail(0.5f, 0.4f); // Fades the trail in

            swordSwipe.SetTime(0f, 0, 1.0f);
            swordSwipe.StartTrail(0.5f, 0.4f);             // Fades the trail in
            swordSwipe.FadeOut(0.1f);

            // swordSwipe.SetTime(2.0f, 2.5f, 2.0f);


            Debug.Log("-------- 1");
            //swordSwipe.SetTime(tTraillTime, tTimeToTween, tTweenSpeed);
            //swordSwipe.StartTrail(startTimeToTweenTo, startFadeInTime);


            StartCoroutine(GenerateWeaponArc(0.12f, transform.position, Quaternion.Euler(0, 0, -60.0f)));
        }


        if (Input.GetKeyDown(KeyCode.Alpha2))
        {
            animationController.PlayAnimation(animationAttack02);
            //swordSwipe.SetTime(0f, 0, 1.0f);
            //swordSwipe.StartTrail(0.9f, 1.5f); // Fades the trail in
            Debug.Log("-------- 2");
            swordSwipe.SetTime(tTraillTime, tTimeToTween, tTweenSpeed);
            swordSwipe.StartTrail(startTimeToTweenTo, startFadeInTime);


            StartCoroutine(GenerateWeaponArc(0.1f, transform.position, Quaternion.Euler(0, 0, -50.0f)));
            StartCoroutine(GenerateWeaponArc(0.3f, transform.position, Quaternion.Euler(0, 0, 60.0f)));
        }

        if (Input.GetKeyDown(KeyCode.Alpha3))
        {
            animationController.PlayAnimation(animationAttack03);
            //swordSwipe.SetTime(2f, 3f, 1.0f);
            //swordSwipe.StartTrail(0.5f, 1.5f); // Fades the trail in
            // swordSwipe.FadeOut(0.5f);
            Debug.Log("-------- 3");
            swordSwipe.SetTime(tTraillTime, tTimeToTween, tTweenSpeed);
            swordSwipe.StartTrail(startTimeToTweenTo, startFadeInTime);

            StartCoroutine(GenerateWeaponArc(0.2f, transform.position, Quaternion.Euler(0, 0, 65.0f)));
        }
    }
Esempio n. 2
0
    //
    #endregion
    // -------------------------------------------------------------------------------------------------------------------
    #region Update
    //
    protected void Update()
    {
        t = Mathf.Clamp(Time.deltaTime * timeScale, 0, 0.066f);
        //
        animationController.SetDeltaTime(t);          // Sets the delta time that the animationController uses.
        //
        //
        //  This is just some sample code to show you how you can use the animation controller component along with the trails
        //
        thinkTime -= t;
        if (thinkTime < 0)
        {
            switch (thinkState)
            {
            case 0:
                animationController.CrossfadeAnimation(animationIdle, 0.2f);
                thinkState++;
                thinkTime = 1.5f;
                break;

            case 1:
                // START ATTACK 1
                animationController.CrossfadeAnimation(animationAttack1Anticipation, 0.1f);
                thinkState++;
                thinkTime   = 0.3f;
                facingAngle = -180 + Random.value * 360;

                break;

            case 2:
                animationController.PlayAnimation(animationAttack1);
                thinkTime = 0.2f;
                thinkState++;
                rightSwipe.StartTrail(0.5f, 0.4f);                 // Fades the trail in
                facingAngle += -40 + Random.value * 80;
                break;

            case 3:
                thinkState++;
                thinkTime = 0.3f;
                rightSwipe.FadeOut(0.5f);                 // Fades the trail out
                break;

            case 4:
                // BACK TO IDLE
                animationController.CrossfadeAnimation(animationIdle, 0.2f);
                thinkState++;
                thinkTime = 0.3f;
                rightSwipe.ClearTrail();                 // Forces the trail to clear
                break;

            case 5:
                // START ATTACK 2
                animationController.CrossfadeAnimation(animationAttack2Anticipation, 0.1f);
                thinkState++;
                thinkTime   = 0.3f;
                facingAngle = -180 + Random.value * 360;

                break;

            case 6:
                animationController.PlayAnimation(animationAttack2);
                thinkState++;
                thinkTime = 0.2f;
                leftSwipe.StartTrail(0.5f, 0.4f);                  // Fades the trail in
                facingAngle += -40 + Random.value * 80;

                break;

            case 7:
                thinkState++;
                thinkTime = 0.3f;
                leftSwipe.FadeOut(0.5f);                 // Fades the trail out
                break;

            case 8:
                // BACK TO IDLE
                animationController.CrossfadeAnimation(animationIdle, 0.2f);
                thinkState++;
                thinkTime = 0.3f;
                leftSwipe.ClearTrail();                 // Forces the trail to clear
                break;

            case 9:
                // START THE SPIN ATTACK
                animationController.CrossfadeAnimation(animationAttack1Anticipation, 0.1f);
                thinkState++;
                thinkTime   = 0.3f;
                facingAngle = -180 + Random.value * 360;

                break;

            case 10:
                animationController.CrossfadeAnimation(animationWhirlwind, 0.2f);
                thinkState++;
                thinkTime = 2.8f;
                leftSwipe.StartTrail(0.9f, 1.4f);                 // Fades both trais in
                rightSwipe.StartTrail(0.9f, 1.4f);
                break;

            case 11:
                // Checking for a specific place in the animation from which to start the next animation
                //
                if (Mathf.Repeat(animationWhirlwind.normalizedTime, 1) < 0.93f + t * 1f && Mathf.Repeat(animationWhirlwind.normalizedTime, 1) > 0.93f - t * 1.2f)
                {
                    animationController.CrossfadeAnimation(animationAttack3, 0.05f * animationWhirlwind.length);
                    thinkState++;
                    thinkTime = 0.6f;
                }
                break;

            case 12:
                thinkState++;
                leftSwipe.FadeOut(0.4f);                 // Fades both trails out
                rightSwipe.FadeOut(0.4f);
                thinkTime = 0.6f;
                break;

            case 13:
                // BACK TO IDLE (for a second)
                animationController.CrossfadeAnimation(animationIdle, 0.2f);
                thinkState++;
                thinkTime = 1f;
                leftSwipe.ClearTrail();                  // Forces both trails to clear
                rightSwipe.ClearTrail();
                break;

            default:
                thinkState = 0;
                break;
            }
        }
        //
        // ** THIS IS A REALLY TERRIBLE EXAMPLE OF THE CHARACTER MOVING ... (It moves forward when executing a attack)
        if (thinkState == 3 || thinkState == 7)
        {
            transform.position += transform.TransformDirection(Vector3.forward) * t * 3;
        }
        else if (thinkState == 11 || thinkState == 10)
        {
            transform.position += transform.TransformDirection(Vector3.forward) * t * 0.5f;
        }
        //
        // This rotates the character a based on "facingAngle". It's an experiment to show that the animationController works
        transform.eulerAngles = new Vector3(transform.eulerAngles.x, Mathf.LerpAngle(transform.eulerAngles.y, facingAngle, 12 * t), transform.eulerAngles.z);
    }