Example #1
0
		public Explosion (Vector2 origin,Entity.directions dir, float intensity,float duration, Color color)
		{
			for (int i = 0; i < rand.Next (1, (int)(5 + 2 * intensity)); i++) {
				Particle e = new Particle ((int)origin.X, (int)origin.Y, color, Particle.Sort.Explosion);
				int g = rand.Next (1, 3);
				if (g != 1)
					g = -1;
				switch (dir) {
				case Entity.directions.Down:
					e.velocity = new Vector2 (rand.Next (0, (int)(10 * intensity)) * g, (int)(50 * intensity));
					break;
				case Entity.directions.Up:
					e.velocity = new Vector2 (rand.Next (0, (int)(10 * intensity)) * g, (int)(50 * intensity)*-1);
					break;
				case Entity.directions.Left:
					e.velocity = new Vector2 ((int)(50*intensity)*-1, rand.Next (0, (int)(10 * intensity)) * g);
					break;
				case Entity.directions.Right:
					e.velocity = new Vector2 ((int)(50 * intensity), rand.Next (0, (int)(10 * intensity)) * g);
					break;

				}
				e.life = duration;
				EffectManager.addParticle (e);
			}
		}
Example #2
0
		public static void removeParticle(Particle par1)
		{
			removeEffect (par1.light);
			removeEffect (par1);
		}
Example #3
0
		public override void update ()
		{
			magnetTime -= 1;
			changeTime -= 1;
			if (magnetTime <= 0) 
			{
				if (world.difficulty<15)
					magnetTime = (int)Math.Abs (50 - world.difficulty);
				else
					magnetTime = 20;
				fire ();
			}
				position += 0.03F * velocity;
				velocity -= 0.03F * velocity;
				if (!checkCollision (position))
					shape = new Rectangle ((int)position.X, (int)position.Y, shape.Width, shape.Height);
				else {
					position = new Vector2 (shape.X, shape.Y);
				}
			if (life <= 0)
				life = 0;
			if (life <= 0.5F) {
				alertTime -= 1;
				if (alertTime <= 0) {
					alertTime = (int)(100 * (life+0.2F));
					EffectManager.addLight (new Light ((int)(position.X + boundingboxes [dir].X + boundingboxes [dir].Width / 2), (int)(position.Y + boundingboxes [dir].Y + boundingboxes [dir].Height / 2), 2F, Color.Red));
					EffectManager.addLight (new Light ((int)(position.X + boundingboxes [dir].X + boundingboxes [dir].Width / 2), (int)(position.Y + boundingboxes [dir].Y + boundingboxes [dir].Height / 2), 2F, Color.Red));
					EffectManager.addLight (new Light ((int)(position.X + boundingboxes [dir].X + boundingboxes [dir].Width / 2), (int)(position.Y + boundingboxes [dir].Y + boundingboxes [dir].Height / 2), 2F, Color.Red));
				}
			}

			if (life <= 0.3F) {
				for (int i = 0; i < rand.Next (0,(int)(2+(3*(1-life)))); i++) {
					Particle e = new Particle ((int)(position.X + boundingboxes [dir].X + boundingboxes [dir].Width / 2-2), (int)(position.Y + boundingboxes [dir].Y + boundingboxes [dir].Height / 2-2), Color.Gray, Particle.Sort.Fog);
					e.velocity = new Vector2 (rand.Next (-50, 50), rand.Next (-50, 50));
					EffectManager.addParticle (e);
				}
			}

			if (life <= 0) {
				velocity = Vector2.Zero;
					for (int i = 0; i < rand.Next (0,(int)(2+(3*(1-life)))); i++) {
						Particle e = new Particle ((int)(position.X + boundingboxes [dir].X + boundingboxes [dir].Width / 2-2), (int)(position.Y + boundingboxes [dir].Y + boundingboxes [dir].Height / 2-2), new Color(rand.Next(0,50),rand.Next(0,50),rand.Next(0,50)), Particle.Sort.Fog);
						e.velocity = new Vector2 (rand.Next (-50, 50), rand.Next (-50, 50));
						EffectManager.addParticle (e);
					}
					for (int i = 0; i < rand.Next (4, 10); i++) {
						directions dir = directions.Right;
					switch (rand.Next (1, 5)) {
						case 1:
							dir = directions.Left;
							break;
						case 2:
							dir = directions.Down;
							break;
						case 3:
							dir = directions.Up;
							break;
						}
					new Explosion (new Vector2 (shape.X + shape.Width / 2, shape.Y + shape.Height / 2), dir, 0.5F, 0.5F, Color.DarkOrange);
					}
				Core.playSound (Core.Sounds [1], rand.Next(1,6)/10F);
				deathTime += 1;
				if (deathTime > 50)
					dead = true;
			}
			//TODO: implements explosion on death
		}
Example #4
0
		public static void removeParticle(Particle par1)
		{
			removeLight (par1.light);
			particles.Remove (par1);
		}
Example #5
0
		public static Particle addParticle(Particle  par1)
		{
			particles.Add (par1);
			return par1;
		}