Exemplo n.º 1
0
 public void DeliverDamage(float dmg)
 {
     if (actor.IsAlive())
     {
         actor.ApplyDamage(dmg);
         if (!actor.IsAlive())
         {
             Kill();
             GameObject.Find("GameManager").GetComponent <GameManager>().LoseWave();
         }
         sliderHealth.value = actor.GetHealthPercentage();
         textHealth.text    = (actor.GetHealthPercentage() * 100.0f).ToString("##0.#") + "%";
         if (actor.HasShield())
         {
             goShieldBar.SetActive(true);
             if (!IsShieldOn())
             {
                 shieldGain.Play();
             }
             ToggleShield(true);
             sliderShield.value = actor.GetShieldPercentage();
         }
         else
         {
             goShieldBar.SetActive(false);
             if (IsShieldOn())
             {
                 shieldLose.Play();
             }
             ToggleShield(false);
             actor.RemoveShield();
         }
     }
 }
Exemplo n.º 2
0
 public void DeliverDamage(float dmg, int hitBy)
 {
     if ( hitBy != -1 ) { lastHitBy = hitBy; }
     if ( actor.IsAlive() ) {
         actor.ApplyDamage(dmg);
         if ( !actor.IsAlive() ) {
             Kill();
             GameObject.Find("GameManager").GetComponent<GameManager>().PlayerKills(transform.root.gameObject, isBoss, scoreWorth, hitBy);
         } else {
             if ( hasShield && !actor.HasShield() ) {
                 if ( shield.enabled ) {
                     shield.enabled = false;
                     flareLose.Play();
                     source.PlayOneShot(shieldLoseSound, 1.0f);
                     StartCoroutine(ReloadShield());
                 }
             }
             if ( isBoss ) {
                 slBoss.value = actor.GetHealthPercentage();
             }
         }
     }
 }