public void ParticleRateNoMaxOneMin(int milliseconds, int expectedCreated, int expectedCreated2, bool complete, bool complete2)
        {
            var dt = TimeSpan.FromMilliseconds(milliseconds);

            var totalCreated = 0;
            var totalInvoke  = 0;

            var emitter = new SKConfettiEmitter(100, -1, 1.0);

            emitter.ParticlesCreated += count =>
            {
                totalCreated += count;
                totalInvoke++;
            };

            emitter.Update(dt);

            Assert.Equal(expectedCreated, totalCreated);
            Assert.Equal(1, totalInvoke);
            Assert.Equal(complete, emitter.IsComplete);

            emitter.Update(dt);

            Assert.Equal(expectedCreated2, totalCreated);
            if (complete)
            {
                Assert.Equal(1, totalInvoke);
            }
            else
            {
                Assert.Equal(2, totalInvoke);
            }
            Assert.Equal(complete2, emitter.IsComplete);
        }
        public void ParticleRateLargerMaxBurstRunsOnce(int milliseconds)
        {
            var dt = TimeSpan.FromMilliseconds(milliseconds);

            var totalCreated = 0;
            var totalInvoke  = 0;

            var emitter = new SKConfettiEmitter(100, 200, 0);

            emitter.ParticlesCreated += count =>
            {
                totalCreated += count;
                totalInvoke++;
            };

            emitter.Update(dt);

            Assert.Equal(100, totalCreated);
            Assert.Equal(1, totalInvoke);
            Assert.True(emitter.IsComplete);

            emitter.Update(dt);

            Assert.Equal(100, totalCreated);
            Assert.Equal(1, totalInvoke);
            Assert.True(emitter.IsComplete);
        }
示例#3
0
        public ConfettiPage()
        {
            InitializeComponent();

            Configs = new Dictionary <string, ConfettiConfig>
            {
                ["Top"]    = new ConfettiConfig(),
                ["Center"] = new ConfettiConfig
                {
                    MinSpeed       = 30,
                    MaxSpeed       = 150,
                    Duration       = 0,
                    OnCreateSystem = (i, system) =>
                    {
                        system.Emitter       = SKConfettiEmitter.Burst(100);
                        system.EmitterBounds = SKConfettiEmitterBounds.Center;
                    }
                },
                ["Sides"] = new ConfettiConfig(2)
                {
                    MinSpeed       = 50,
                    MaxSpeed       = 400,
                    Duration       = 0,
                    OnCreateSystem = (i, system) =>
                    {
                        system.Emitter = SKConfettiEmitter.Burst(100);
                        if (i % 2 == 0)
                        {
                            system.EmitterBounds = SKConfettiEmitterBounds.Point(0, Height);
                            system.StartAngle    = -85;
                            system.EndAngle      = -35;
                        }
                        else
                        {
                            system.EmitterBounds = SKConfettiEmitterBounds.Point(Width, Height);
                            system.StartAngle    = 265;
                            system.EndAngle      = 215;
                        }
                    }
                },
            };

            BindingContext = this;
        }