예제 #1
0
파일: Emitter.cs 프로젝트: MAL1S/Kursovaya
        public virtual ParticleColorful CreateParticle()
        {
            var particle = new ParticleColorful();

            particle.fromColor = ColorFrom;
            particle.toColor   = ColorTo;
            particle.figure    = figure;
            return(particle);
        }
예제 #2
0
 public ParticleColorful(ParticleColorful particleColorful)
 {
     this.x          = particleColorful.x;
     this.y          = particleColorful.y;
     this.radiusX    = particleColorful.radiusX;
     this.radiusY    = particleColorful.radiusY;
     this.speedX     = particleColorful.speedX;
     this.speedY     = particleColorful.speedY;
     this.life       = particleColorful.life;
     this.fromColor  = particleColorful.fromColor;
     this.toColor    = particleColorful.toColor;
     this.rectHeight = particleColorful.rectHeight;
     this.rectWidth  = particleColorful.rectWidth;
 }
예제 #3
0
파일: MainForm.cs 프로젝트: MAL1S/Kursovaya
 //НАЗАД
 private void backButton_Click(object sender, EventArgs e)
 {
     ifRun = false;
     if (emitter.currentHistoryIndex >= 2)
     {
         //вернуться на значения из списка
         emitter.particles.RemoveRange(0, emitter.particles.Count);
         foreach (ParticleColorful particle in emitter.particlesHistory[emitter.currentHistoryIndex - 1])
         {
             ParticleColorful part = new ParticleColorful(particle);
             part.fromColor = emitter.ColorFrom;
             part.toColor   = emitter.ColorTo;
             part.figure    = emitter.figure;
             emitter.particles.Add(part);
         }
         emitter.currentHistoryIndex--;
     }
 }
예제 #4
0
파일: MainForm.cs 프로젝트: MAL1S/Kursovaya
 //ВПЕРЕД
 private void stepButton_Click(object sender, EventArgs e)
 {
     ifRun = false;
     if (emitter.currentHistoryIndex < emitter.particlesHistory.Count - 1 && emitter.currentHistoryIndex != emitter.MAX_HISTORY_LENGTH)
     {
         //поставить значения дальше по списку
         emitter.particles.RemoveRange(0, emitter.particles.Count);
         foreach (ParticleColorful particle in emitter.particlesHistory[emitter.currentHistoryIndex + 1])
         {
             ParticleColorful part = new ParticleColorful(particle);
             part.fromColor = emitter.ColorFrom;
             part.toColor   = emitter.ColorTo;
             part.figure    = emitter.figure;
             emitter.particles.Add(part);
         }
         emitter.currentHistoryIndex++;
     }
     else
     {
         emitter.tickCount += (emitter.tickRate - emitter.tickCount % emitter.tickRate);
         stepPermission     = true; //тут разрешает сделать один раз updateState
     }
 }
예제 #5
0
파일: Emitter.cs 프로젝트: MAL1S/Kursovaya
        public string figure = "circle"; // показывает, какая сейчас фигура

        public void updateState()
        {
            //зависимость от скорости, выставленной на mainForm
            if (tickCount % tickRate == 0)
            {
                //если надо идти вперед по значениям из списка истории состояний
                if (currentHistoryIndex != MAX_HISTORY_LENGTH && currentHistoryIndex < particlesHistory.Count - 1)
                {
                    //поставить значения дальше по списку
                    particles.RemoveRange(0, particles.Count); //очистка текущего состояния частиц
                    foreach (ParticleColorful particle in particlesHistory[currentHistoryIndex + 1])
                    {
                        ParticleColorful part = new ParticleColorful(particle);
                        part.fromColor = ColorFrom;
                        part.toColor   = ColorTo;
                        part.figure    = figure;
                        particles.Add(part);
                    }
                    currentHistoryIndex++;
                    tickCount++;
                    return;
                }

                int particlesToCreate = ParticlesPerTick;

                foreach (var particle in particles)
                {
                    particle.life--;
                    particle.fromColor = ColorFrom;
                    particle.toColor   = ColorTo;
                    if (particle.life < 0)
                    {
                        resetParticle(particle);
                    }
                    else
                    {
                        particle.speedX += gravitationX;
                        particle.speedY += gravitationY;

                        particle.x += particle.speedX;
                        particle.y += particle.speedY;
                    }
                }

                while (particlesToCreate >= 1)
                {
                    particlesToCreate--;
                    ParticleColorful particle = CreateParticle();
                    resetParticle(particle);
                    particles.Add(particle);
                }

                //если список истории состояний еще не заполнен, то добавить туда список состояний
                if (currentHistoryIndex < MAX_HISTORY_LENGTH)
                {
                    if (currentHistoryIndex >= particlesHistory.Count)
                    {
                        particlesHistory.Add(new List <ParticleColorful>());
                    }
                    foreach (var particle in particles)
                    {
                        ParticleColorful part = createParticleColorful(particle);
                        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 = createParticleColorful(particle);
                        particlesHistory[currentHistoryIndex].Add(part);
                    }
                }
            }
            tickCount++;
            if (tickCount < 0)
            {
                tickCount = 0;
            }
        }