示例#1
0
        public Task Start(EntertainmentLayer layer, Func <TimeSpan> waitTime, RGBColor?color, CancellationToken cancellationToken)
        {
            var center = EffectSettings.LocationCenter;

            var tentacles = layer.GroupBy(x => (int)((x.LightLocation.Angle(center.X, center.Y) / 3.6 / 2))).OrderBy(x => x.Key);

            var grouped = tentacles.ChunkByGroupNumber(3).Select(x => x.SelectMany(l => l));

            return(grouped.SetRandomColor(cancellationToken, IteratorEffectMode.AllIndividual, IteratorEffectMode.All, waitTime));
        }
示例#2
0
        public Task Start(EntertainmentLayer layer, Func <TimeSpan> waitTime, RGBColor?color, CancellationToken cancellationToken)
        {
            if (!color.HasValue)
            {
                color = RGBColor.Random();
            }

            var fronToBack = layer.GroupBy(x => (int)(((x.LightLocation.Y + 1) / 2) * 50)).ToList();

            Func <TimeSpan> customWaitMS = () => TimeSpan.FromMilliseconds((waitTime().TotalMilliseconds * 2) / fronToBack.Count);

            return(fronToBack.FlashQuick(cancellationToken, color, IteratorEffectMode.Bounce, IteratorEffectMode.All, waitTime: customWaitMS));
        }
示例#3
0
        public Task Start(EntertainmentLayer layer, Func <TimeSpan> waitTime, RGBColor?color, CancellationToken cancellationToken)
        {
            //Non repeating effects should not run on baselayer
            if (layer.IsBaseLayer)
            {
                return(Task.CompletedTask);
            }

            if (!color.HasValue)
            {
                color = RGBColor.Random();
            }

            Func <TimeSpan> customWaitMS = () => TimeSpan.FromMilliseconds((waitTime().TotalMilliseconds * 4) / layer.Count);

            var fronToBack = layer.GroupBy(x => (int)(((x.LightLocation.Y + 1) / 2) * 50)).OrderBy(x => x.Key).Reverse();

            return(fronToBack.FlashQuick(cancellationToken, color, IteratorEffectMode.Single, IteratorEffectMode.RandomOrdered, waitTime: customWaitMS));
        }
        public async Task Start(EntertainmentLayer layer, Func <TimeSpan> waitTime, RGBColor?color, CancellationToken cancellationToken)
        {
            var center = EffectSettings.LocationCenter;

            var tentacles = layer.GroupBy(x => (int)((x.LightLocation.Angle(center.X, center.Y) / 3.6 / 3))).OrderBy(x => x.Key);

            var grouped = tentacles.ChunkByGroupNumber(2).Select(x => x.SelectMany(l => l));

            while (!cancellationToken.IsCancellationRequested)
            {
                CancellationTokenSource tempCancel = new CancellationTokenSource();

                foreach (var group in grouped)
                {
                    var nextColor = RGBColor.Random();
                    group.To2DGroup().FlashQuick(cancellationToken, null, IteratorEffectMode.All, IteratorEffectMode.All, waitTime, transitionTimeOff: waitTime, duration: waitTime());
                    await Task.Delay(waitTime(), cancellationToken);
                }

                tempCancel.Cancel();
            }
        }