Esempio n. 1
0
    IEnumerator States(string state)
    {
        switch (state)
        {
        case "Start":
            InvokeState("Idle");
            break;

        case "Exit":
            //Go to the exit position and desactive itself
            posY = ExitPosY;
            yield return(new WaitForSeconds(waitTimeExitState));

            gameObject.SetActive(false);
            break;

        case "Idle":
            bossContainerAnimator.Play(animationIdleLeft);
            //Wait some time
            yield return(new WaitForSeconds(waitTimeIdleState));

            InvokeState("Search");
            break;

        case "Search":
            //Go to the player position
            posX = playerPos.x;
            yield return(new WaitForSeconds(waitTimeSearchState));

            InvokeState("Idle2");
            break;

        case "Idle2":
            //Wait some time
            yield return(new WaitForSeconds(waitTimeIdle2State));

            InvokeState("Search2");
            break;

        case "Search2":
            //Go to player position
            posX = playerPos.x;
            yield return(new WaitForSeconds(waitTimeSearch2State));

            InvokeState("Smash");
            break;

        case "Smash":
            //Smash

            //Play the Smash sound
            fxPlayerAudioSource.clip = hitSound;
            fxPlayerAudioSource.Play();
            bossContainerAnimator.Play(animationSmashLeft);

            yield return(new WaitForSeconds(waitTimeSmashAction[0]));

            //Shake the camera
            lockVirtualCameraAnimator.Play(animationCameraShake);

            //Enable the dash zone if the player is not in the damage zone
            if (!damageZoneScript.IsInZone)
            {
                dashZone.SetActive(true);
            }

            //Apply damages to player
            damageZoneScript.ApplyDamages();
            yield return(new WaitForSeconds(waitTimeSmashAction[1]));

            dashZone.SetActive(false);

            yield return(new WaitForSeconds(waitTimeSmashAction[2]));

            //Restart the State Coroutine
            InvokeState("Idle");
            break;
        }
    }
Esempio n. 2
0
    IEnumerator States(string state)
    {
        switch (state)
        {
        case "Exit":
            //Go to Exit position
            posY = ExitPosY;
            yield return(new WaitForSeconds(waitTimeExitState));

            gameObject.SetActive(false);
            break;

        case "Idle":
            //Wait some time

            yield return(new WaitForSeconds(waitTimeIdleState));

            InvokeState("Search");
            break;

        case "Search":
            //Goto player position
            posY = playerPos.y;
            yield return(new WaitForSeconds(waitTimeSearchState));

            InvokeState("Idle2");
            break;

        case "Idle2":
            //Wait some time
            yield return(new WaitForSeconds(waitTimeIdle2State));

            InvokeState("Search2");
            break;

        case "Search2":
            //Goto player position
            posY = playerPos.y;
            yield return(new WaitForSeconds(waitTimeSearch2State));

            InvokeState("Smash");
            break;

        case "Smash":
            //SMASH! (Clap.)
            bossContainerAnimator.Play(animationClap);
            yield return(new WaitForSeconds(waitTimeClapAction[0]));

            //Play clap sound
            fxPlayerAudioSource.clip = clapSound;
            fxPlayerAudioSource.Play();

            //Shake the camera
            fixedVirtualCameraAnimator.Play(animationCameraShake);

            //Apply Damages
            damageZoneScript.ApplyDamages();

            yield return(new WaitForSeconds(waitTimeClapAction[1]));

            //Restart the sequence
            InvokeState("Idle");
            break;
        }
    }