コード例 #1
0
        public override void Begin(ILightingController controller, Random random)
        {
            var nextPattern = _patternFactory.GenerateRandom(random);

            if (_currentPattern != null)
            {
                int i = 0;
                while (i < 10 && _currentPattern.GetType() == typeof(PatternClear) && nextPattern.GetType() == typeof(PatternClear))
                {
                    nextPattern = _patternFactory.GenerateRandom(random);
                    i++;
                }

                // TODO : Remove this?
                // NOTE : Temporary implementation to prevent unlit/black colour being used in succession
                if (i >= 9)
                {
                    nextPattern = new PatternRandomSolidColor();
                }
            }

            _currentPattern   = nextPattern;
            _currentTiming    = _timingFactory.GenerateRandom(random);
            _currentAnimation = _animationFactory.GenerateRandom(random);

            _currentPattern.Reset(controller, random);
            var totalSteps = _currentAnimation.Begin(controller, _currentPattern, random);

            _currentTiming.Reset(totalSteps);
        }