Esempio n. 1
0
 // изменение цвета цастиц,которые попали в область влияние Цветовых областей
 public override void ImpactParticle(ParticleColorful particle)
 {
     if (particle.X >= 0 & particle.X <= width & particle.Y >= YBegin & particle.Y <= YBegin + height)
     {
         particle.FromColor = Color.Red;
     }
     if (particle.X >= width & particle.X <= width * 2 & particle.Y >= YBegin & particle.Y <= YBegin + height)
     {
         particle.FromColor = Color.Orange;
     }
     if (particle.X >= width * 2 & particle.X <= width * 3 & particle.Y >= YBegin & particle.Y <= YBegin + height)
     {
         particle.FromColor = Color.Yellow;
     }
     if (particle.X >= width * 3 & particle.X <= width * 4 & particle.Y >= YBegin & particle.Y <= YBegin + height)
     {
         particle.FromColor = Color.Green;
     }
     if (particle.X >= width * 4 & particle.X <= width * 5 & particle.Y >= YBegin & particle.Y <= YBegin + height)
     {
         particle.FromColor = Color.DodgerBlue;
     }
     if (particle.X >= width * 5 & particle.X <= width * 6 & particle.Y >= YBegin & particle.Y <= YBegin + height)
     {
         particle.FromColor = Color.Blue;
     }
     if (particle.X >= width * 6 & particle.X <= width * 7 & particle.Y >= YBegin & particle.Y <= YBegin + height)
     {
         particle.FromColor = Color.Violet;
     }
 }
Esempio n. 2
0
        public virtual ParticleColorful CreateParticle()
        {
            var particle = new ParticleColorful();

            //создаем новую частицу исходя из формы
            switch (figure)
            {
            case "circle":
            {
                particle = new ParticleCircle();
                break;
            }

            case "square":
            {
                particle = new ParticleSquare();
                break;
            }

            case "star":
            {
                particle = new ParticleStar();
                break;
            }

            case "snowflake":
            {
                particle = new ParticleSnowflake();
                break;
            }
            }
            particle.FromColor = ColorFrom;
            particle.ToColor   = ColorTo;
            return(particle);
        }
Esempio n. 3
0
 public ParticleColorful(ParticleColorful particleColorful)
 {
     this.X         = particleColorful.X;
     this.Y         = particleColorful.Y;
     this.Size      = particleColorful.Size;
     this.SpeedX    = particleColorful.SpeedX;
     this.SpeedY    = particleColorful.SpeedY;
     this.Life      = particleColorful.Life;
     this.FromColor = particleColorful.FromColor;
     this.ToColor   = particleColorful.ToColor;
 }
Esempio n. 4
0
        //клонирование частиц
        public virtual Particle Clone()
        {
            ParticleColorful instanse = (ParticleColorful)Activator.CreateInstance(this.GetType());

            instanse.Size   = this.Size;
            instanse.SpeedX = this.SpeedX;
            instanse.SpeedY = this.SpeedY;
            instanse.X      = this.X;
            instanse.Y      = this.Y;
            instanse.Life   = this.Life;
            return(instanse);
        }
Esempio n. 5
0
        //клонирование
        public override Particle Clone()
        {
            ParticleColorful instanse = (ParticleColorful)Activator.CreateInstance(this.GetType());

            instanse.Size      = this.Size;
            instanse.SpeedX    = this.SpeedX;
            instanse.SpeedY    = this.SpeedY;
            instanse.X         = this.X;
            instanse.Y         = this.Y;
            instanse.Life      = this.Life;
            instanse.FromColor = this.FromColor;
            instanse.ToColor   = this.ToColor;
            return(instanse);
        }
Esempio n. 6
0
 private void StepBack_Click(object sender, EventArgs e)
 {
     ifRun = false;
     if (emitter.currentHistoryIndex >= 1)
     {
         //вернуться на значения из списка
         emitter.particles.RemoveRange(0, emitter.particles.Count);
         foreach (ParticleColorful particle in emitter.particlesHistory[emitter.currentHistoryIndex - 1])
         {
             ParticleColorful part = (ParticleColorful)particle.Clone();
             emitter.particles.Add(part);
         }
         emitter.currentHistoryIndex--;
     }
 }
Esempio n. 7
0
 private void Step_Click(object sender, EventArgs e)
 {
     ifRun = false;
     if (emitter.currentHistoryIndex < emitter.particlesHistory.Count - 1 && emitter.currentHistoryIndex != 19)
     {
         //поставить значения дальше по списку
         emitter.particles.RemoveRange(0, emitter.particles.Count);
         foreach (ParticleColorful particle in emitter.particlesHistory[emitter.currentHistoryIndex + 1])
         {
             ParticleColorful part = (ParticleColorful)particle.Clone();
             emitter.particles.Add(part);
         }
         emitter.currentHistoryIndex++;
     }
     else
     {
         emitter.tickCount += (emitter.tickRate - emitter.tickCount % emitter.tickRate);
         stepPermission     = true;
     }
 }
Esempio n. 8
0
 // абстрактный метод с помощью которого будем изменять состояние частиц
 public abstract void ImpactParticle(ParticleColorful particle);
Esempio n. 9
0
        public string figure;                                    //форма частиц
        public void UpdateState()
        {
            if (tickCount % tickRate == 0)
            {
                int particlesToCreate = ParticlesPerTick;
                int i = 0;

                foreach (var particle in particles)
                {
                    //влияние доп точек(окрашивателей)
                    foreach (var point in impactPoints)
                    {
                        point.ImpactParticle(particle);
                    }

                    particle.Life--;
                    //если частица умерла
                    if (particle.Life < 0)
                    {
                        //если нужно создавать  новые частицы
                        if (ParticlesPerTick != 0)
                        {
                            //то обновляем характеристсики умерших
                            ResetParticle(particle);
                        }
                        //если нет то удаляем упавшую частицу
                        particlesRemove.Add(particle);
                    }
                    else
                    {
                        //если частица жива,то пусть падает дальше
                        particle.SpeedX += gravitationX;
                        particle.SpeedY += gravitationY;

                        particle.X += particle.SpeedX;
                        particle.Y += particle.SpeedY;
                    }
                }
                //очищение списка от лишних частиц
                foreach (var particle in particlesRemove)
                {
                    particles.Remove(particle);
                }
                particlesRemove.Clear();
                //пока нужно создавать новые частицы
                while (particlesToCreate >= 1)
                {
                    particlesToCreate -= 1;
                    //создаем новые
                    var particle = CreateParticle();
                    ResetParticle(particle);
                    particles.Add(particle);
                }
                if (currentHistoryIndex < 39)
                {
                    if (currentHistoryIndex >= particlesHistory.Count)
                    {
                        particlesHistory.Add(new List <ParticleColorful>());
                    }
                    foreach (var particle in particles)
                    {
                        ParticleColorful part = (ParticleColorful)particle.Clone();
                        particlesHistory[currentHistoryIndex].Add(part);
                    }
                    currentHistoryIndex++;
                    ifAdd = true;
                }
                else
                {
                    if (!ifAdd)
                    {
                        particlesHistory.RemoveAt(0);
                    }
                    ifAdd = false;
                    particlesHistory.Add(new List <ParticleColorful>());
                    foreach (var particle in particles)
                    {
                        ParticleColorful part = (ParticleColorful)particle.Clone();
                        particlesHistory[currentHistoryIndex].Add(part);
                    }
                }
            }
            tickCount++;
            if (tickCount < 0)
            {
                tickCount = 0;
            }
        }