Exemple #1
0
    // Update is called once per frame
    protected virtual void Update()
    {
        List <LivingEffect> tobeRemoveEffects = new List <LivingEffect>();

        //update living objects, count down the life time
        foreach (LivingEffect livingEff in _livingEffects)
        {
            EffectInstance go = livingEff._effect;
            Assertion.Check(go != null);

            EffectInstance eff = go;
            if (eff != null)
            {
                if (eff.LifeTick > 0)
                {
                    //reduce eff life tick
                    eff.LifeTick -= Time.deltaTime;
                }
                else
                {
                    if (eff.DeadTick > 0)
                    {
                        eff.DeadTick -= Time.deltaTime;
                        eff.UpdatePointLight();
                    }
                    else
                    {
                        //recycle back to pool
                        eff.LifeTick = eff._lifeTime;
                        eff.DeadTick = eff._deadTime;
                        eff.FinishEffect(true);
                        eff.myTransform.parent = _myRoot;
                        go.gameObject.SetActive(false);

                        //remove it from living list
                        tobeRemoveEffects.Add(livingEff);
                    }
                }
            }
        }


        //remove living effects
        foreach (LivingEffect livingEff in tobeRemoveEffects)
        {
            _livingEffects.Remove(livingEff);
        }

        tobeRemoveEffects.Clear();
    }