Example #1
0
    public bool Update(float updateTime)
    {
        // calculate time passed since last update
        _timePassed = updateTime - _updateTime;

        // record time of update
        _updateTime = updateTime;

        if (_updateTime < _startTime)
        {
            // this effect is not ready to trigger yet, exit
            return(false);
        }

        // perform effect!
        bool resolved = Update();

        if (resolved)
        {
            // check for cycling effects
            if (_cycles != DONT_CYCLE)
            {
                --_cycles;
                if (_cycles <= 0)
                {
                    _type = EffectType.END;
                }

                // can't cycle end, remove, or destroy types
                if (_type == EffectType.END ||
                    _type == EffectType.REMOVE ||
                    _type == EffectType.DESTROY)
                {
                    _cycles = DONT_CYCLE;
                }
            }

            // when effect finishes
            switch (_type)
            {
            case EffectType.PERSIST:
                break;

            case EffectType.END:                // remove this effect (thereby ending it)
                Remove();
                break;

            case EffectType.REMOVE:             // remove Anime from animator (ending all effects)
                _anime.Remove();
                break;

            case EffectType.DESTROY:            // destroy target GameObject
                _anime.Destroy();
                break;

            case EffectType.CYCLE:
                Cycle();
                break;

            case EffectType.REVERSE:
                Reverse();
                break;
            }

            // if finished cycles then trigger callback
            if (_cycles == DONT_CYCLE)
            {
                TriggerCallback();
            }
        }

        return(resolved);
    }