Example #1
0
    private void UpdatePhase2()
    {
        if (roarHatchlingsTimer > roarHatchlingsCooldown && globalTimer > globalCooldown)
        {
            roarHatchlingsTimer = Random.Range(0.0f, 10.0f);
            attacking           = true;
            animator.SetTrigger("RoarHatchlings");

            audioPlayer.clip = roarSound;
            audioPlayer.Play();

            Invoke("ResetAttack", roarHatchlingsClip.length);
        }
        else if (breathTimer > breathCooldown && globalTimer > globalCooldown)
        {
            playerHit   = true;
            breathTimer = Random.Range(0.0f, 5.0f);
            CavePlatformController platform = GetClosestPlatformToPlayer();

            if (platform != null)
            {
                attacking = true;

                audioPlayer.clip = breathSound;
                audioPlayer.PlayDelayed(1.0f);

                if (platform.GetCaveSide() == CaveSide.Left || (platform.GetCaveSide() == CaveSide.Middle && Random.Range(0, 2) == 0))
                {
                    animator.SetTrigger("BreathLeft");
                    Invoke("ResetAttack", breathLeftClip.length / breathSpeedMultiplier);
                }
                else
                {
                    animator.SetTrigger("BreathRight");
                    Invoke("ResetAttack", breathRightClip.length / breathSpeedMultiplier);
                }
            }
        }
        else if (roarRocksTimer > roarRocksCooldown && globalTimer > globalCooldown)
        {
            roarRocksTimer = Random.Range(0.0f, 2.5f);
            attacking      = true;
            animator.SetTrigger("RoarRocks");

            audioPlayer.clip = roarSound;
            audioPlayer.Play();

            Invoke("ResetAttack", roarBouldersClip.length);
        }
        else if (smashTimer > smashCooldown && globalTimer > globalCooldown)
        {
            SmashAttack(false);
        }
        else
        {
            TurnTowardsPlayer(60.0f);
        }
    }