Ejemplo n.º 1
0
        public override void Update(double gameTimeSeconds)
        {
            if (_enabled)
            {
                base.Update(gameTimeSeconds);

                if (_delayFinished)
                {
                    // Check to see if we are in a chain delay, if so, we wait x seconds until we move on to the next chained effect.
                    if (!_inChainDelay)
                    {
                        // Process the effect
                        _activeEffect.Update(gameTimeSeconds);

                        // If the effect finished, we move on to the next effect
                        if (_activeEffect.IsFinished)
                        {
                            foreach (Cell cell in _addedCells)
                            {
                                _activeEffect.ClearCell(cell);
                            }

                            _activeIndex++;

                            if (_activeIndex != Effects.Count)
                            {
                                _activeEffect = Effects[_activeIndex];

                                foreach (Cell cell in _addedCells)
                                {
                                    _activeEffect.AddCell(cell);
                                }

                                // When moving to the next effect, check and see if we have a delay. If so, flag and wait.
                                if (DelayBetweenEffects != 0f)
                                {
                                    _inChainDelay = true;
                                    _timeElapsed  = 0d;
                                }
                            }
                            else
                            {
                                _activeIndex  = -1;
                                _activeEffect = null;

                                IsFinished = true;
                            }
                        }

                        // No effect to process? End this chain, which sets enabled = false.
                        if (_activeEffect == null)
                        {
                            if (!Repeat)
                            {
                                End();
                            }
                            else
                            {
                                _inChainDelay = true;
                                _timeElapsed  = 0d;
                                IsFinished    = false;
                            }
                        }
                    }
                    else
                    {
                        if (_timeElapsed >= DelayBetweenEffects)
                        {
                            _inChainDelay = false;

                            // If we do not have another effect to move on to and repeat is enabled, start over.
                            // We can only do this if the effects have ended with repeat, otherwise End() is called which instantly disables the chain
                            if (_activeEffect == null && Repeat)
                            {
                                Restart();
                            }
                        }
                    }
                }
            }
        }
Ejemplo n.º 2
0
 public override void AddCell(Cell cell)
 {
     _addedCells.Add(cell);
     _activeEffect?.AddCell(cell);
 }