Inheritance: MonoBehaviour
Beispiel #1
0
 void UpdateDecomposition()
 {
     if (unit.isDead && !infiniteDecomposition)
     {
         float time = Time.time;
         if (end == 0)
         {
             // Increment end by effectDuration so decomposition can't interrupt it by premature removal.
             float effectDuration = EffectDestroyer.GetEffectLifespan(unit.death.effect.gameObject);
             duration     += effectDuration;
             end           = time + duration;
             animationTime = end;           // Animation starts right after the duration
             end          += animationTime; // Increment by animationTime so the animation has time to play.
         }
         else if (time > end)
         {
             // If decompositionAnimationTime == decompositionEnd, then only this condition will be executed, as that would mean animation time == 0;
             end = 0;
             unit.Kill(DeathType.Remove);
         }
         else if (time > animationTime)
         {
             unit.PlayAnimation(AnimationNames.Remove);
         }
     }
     else if (end != 0)
     {
         end = 0;
     }
 }
Beispiel #2
0
 // Start is called before the first frame update
 void Start()
 {
     instance     = this;
     thisParticle = GetComponent <ParticleSystem>();
     deathTime    = thisParticle.main.duration;
     Destroy(gameObject, deathTime);
 }
Beispiel #3
0
            public void Kill(params DeathType[] deathTypes)
            {
                DeathFlags deathFlags = new DeathFlags(deathTypes);

                if (deathFlags.destroy)
                {
                    Destroy(this.gameObject);
                }

                if (deathFlags.remove)
                {
                    StartCoroutine(Remove(0));
                    return;
                }

                if (canBeRevived == true) // Negate revival
                {
                    canBeRevived = !deathFlags.noRevive;
                }

                if (!isDead)
                {
                    float removalDelay = 0;
                    isDead        = true;
                    HealthCurrent = 0;

                    PlayAnimation(AnimationNames.Death);
                    if (!deathFlags.noEffects)
                    {
                        if (death.effect != null)
                        {
                            Instantiate(death.effect, transform.position, death.effect.rotation);
                            removalDelay += EffectDestroyer.GetEffectLifespan(death.effect.gameObject);
                        }
                    }
                    if (!Decomposes())
                    {
                        StartCoroutine(Remove(removalDelay));
                    }
                    OnDeathTriggers();
                }
            }