Esempio n. 1
0
 void Update()
 {
     if (constraint)
     {
         if (deathTimer > 0)
         {
             sprite.color = new Color(1, 1, 1, deathTimer / DeathTime);
             deathTimer  -= Time.deltaTime;
             if (deathTimer <= constraint.TimeToUnclamp)
             {
                 constraint.CanClamp = false;
                 if (deathTimer <= 0)
                 {
                     PlayerScript player = Target.GetComponent <PlayerScript>();
                     if (player)
                     {
                         player.SetBossDeath(0);
                     }
                     Destroy(this.gameObject);
                 }
             }
         }
         else if (constraint.isClamped())
         {
             int totalHealth = 0;
             foreach (Damageable EyeHealth in EyeHealths)
             {
                 totalHealth += EyeHealth.Health;
             }
             if (totalHealth == 0)
             {
                 deathTimer = DeathTime;
                 if (claw)
                 {
                     claw.gameObject.SetActive(false);
                 }
                 damager.enabled = false;
             }
             else
             {
                 if (totalHealth <= maxHealth * 2 / 3)
                 {
                     phase = 1;
                     if (claw)
                     {
                         claw.gameObject.SetActive(true);
                     }
                 }
                 if (totalHealth <= maxHealth / 3)
                 {
                     phase = 2;
                 }
                 EyeOpenDelay += Time.deltaTime;
                 if ((phase == 2 && EyeOpenDelay > FastEyeOpenTime) || EyeOpenDelay > EyeOpenTime)
                 {
                     List <BossEyeScript> ActiveEyes = Eyes.FindAll(Unopened);
                     if (ActiveEyes.Count > 0)
                     {
                         BossEyeScript EyeToOpen = ActiveEyes[Mathf.FloorToInt(Random.value * ActiveEyes.Count)];
                         EyeToOpen.Target = Target;
                         EyeToOpen.Open();
                         EyeOpenDelay = 0;
                     }
                 }
             }
         }
     }
 }
Esempio n. 2
0
 private static bool Unopened(BossEyeScript eye)
 {
     return(!eye.IsOpen() && eye.gameObject.activeSelf);
 }