本文整理汇总了C#中ParticleSystem.AddParticle方法的典型用法代码示例。如果您正苦于以下问题:C# ParticleSystem.AddParticle方法的具体用法?C# ParticleSystem.AddParticle怎么用?C# ParticleSystem.AddParticle使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ParticleSystem
的用法示例。
在下文中一共展示了ParticleSystem.AddParticle方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Update
public void Update(ParticleSystem particleSystem, float dt)
{
var velocityField = particleSystem.GetOrCreateField(ParticleFields.Velocity);
// No more than 1000 particles
if (particleSystem.ParticleCount < 1000)
{
var particle = particleSystem.AddParticle();
// Default random velocity, going upward
particle.Set(velocityField, new Vector3((float)rand.NextDouble() * 30.0f - 15.0f, (float)rand.NextDouble() * 30.0f - 15.0f, (float)rand.NextDouble() * 50.0f));
}
}
示例2: UpdateAmmo
public void UpdateAmmo(GameTime gameTime, ScreenManager ScreenManager, ParticleSystem explosionParticles, Ship enemy, List<Building> buildings)
{
// Update bullets
for (int i = bullets.Count - 1; i >= 0; i--)
{
bullets[i].Update(gameTime);
if (bullets[i].position.Y < 0)
{
bullets.RemoveAt(i);
break;
}
// Collision with enemy
if (bullets[i].bulletSphere.Intersects(enemy.boundingSphere))
{
bullets.RemoveAt(i);
enemy.life -= 5.0f;
enemy.vibrationLeft = enemy.vibrationRight = 0.6f;
break;
}
}
// Update missiles
for (int i = missiles.Count - 1; i >= 0; i--)
{
// Update missile
missiles[i].Update(gameTime);
// Hit ground
if (missiles[i].position.Y < 0)
{
ScreenManager.Sound.PlayMissileExplosion(missiles[i].position, Position);
ScreenManager.Sound.PlayMissileExplosion(missiles[i].position, enemy.Position);
explosionParticles.AddParticle(missiles[i].position, new Vector3(0, 0, 0));
missiles.RemoveAt(i);
break;
}
// Hit enemy
if (missiles[i].missileSphere.Intersects(enemy.boundingSphere))
{
ScreenManager.Sound.PlayMissileExplosion(missiles[i].position, Position);
ScreenManager.Sound.PlayMissileExplosion(missiles[i].position, enemy.Position);
explosionParticles.AddParticle(missiles[i].position, new Vector3(0, 0, 0));
enemy.life -= 30.0f;
enemy.vibrationLeft = enemy.vibrationRight = 1.0f;
missiles.RemoveAt(i);
break;
}
for (int j = buildings.Count - 1; j >= 0; j--)
{
if (missiles[i].missileSphere.Intersects(buildings[j].boundingBox))
{
ScreenManager.Sound.PlayMissileExplosion(missiles[i].position, Position);
ScreenManager.Sound.PlayMissileExplosion(missiles[i].position, enemy.Position);
explosionParticles.AddParticle(missiles[i].position, new Vector3(0, 0, 0));
missiles.RemoveAt(i);
break;
}
}
}
DeleteDeadBullet();
DeleteDeadMissile();
}
示例3: PogoZombie
// public Tpl_PogoZombie()
// : base(typeof(PogoZombie), "e_pz")
//{
// _hp = 3;
// _speed = 2.4f;
// _jumpForce = 25;
// _appearanceRate = 30;
//}
public PogoZombie()
: base()
{
m_jumpForce = Globals.Random.Next(-JumpForceInterval, JumpForceInterval + 1) + JumpForce;
m_sprite = new Sprite(Globals.TheGame, TextureLibrary.GetSpriteSheet("zombie_pogo", 1, 8), Transform);
m_sprite.Origin = new Vector2(0.5f, 1.0f);
m_physics = new PhysicsComponent(Globals.TheGame, Transform);
m_loot = Loot.GenerateLoot(12);
m_currentFrame = 0;
ObjectState.BeginAction = delegate()
{
m_sprite.SetFrame(m_currentFrame);
};
ObjectState.StandbyAction = delegate()
{
m_sprite.SetFrame(m_currentFrame + 1);
};
ObjectState.DestroyAction = delegate()
{
m_destructible.ClearHitEvents();
Backpacker.HitPlayerColliders.Remove(m_collider);
};
m_collider = new AABBCollider(this, new AABB(m_sprite));
Backpacker.HitPlayerColliders.Add(m_collider, delegate(Collider other) { m_physics.Throw(10.0f, -10.0f, 0.1f); });
m_destructible = new DestructibleComponent(Transform, m_collider, m_collider.AABB, 4);
m_hitAnimation = new HitAnimation(World.baseEffect);
m_impactBox = new AABB(new Transform(Transform, true), new Vector2(20, 60));
m_impactBox.Transform.Position = new Vector2(5, -54);
m_shurikenReceiver = new ShurikenReceiver(Transform, m_impactBox, 5);
m_measurer = new AABBMeasurer(m_impactBox);
//_projections = new BodyPart[] {
// null,
// new BodyPart(this, new Vector2(0, -65), "bp_basezombiearm"),
// new BodyPart(this, new Vector2(-10, -55), "bp_basezombiearm"),
// new BodyPart(this, new Vector2(15, -75), "bp_basezombiehead"),
//};
//_destroyProjections = new BodyPart[]
//{
// new BodyPart(this, new Vector2(10, -50), "bp_basezombieupperb"),
// new BodyPart(this, new Vector2(10, -50), "bp_pogostick"),
// new BodyPart(this, new Vector2(10, -10), "bp_basezombielowerb")
//};
///
/// Body parts
///
m_bodyParts = new ParticleSystem(Globals.TheGame, 6);
m_head = new BodyPart(TextureLibrary.GetSpriteSheet("bp_basezombiehead"), new Transform(Transform, true));
m_head.Transform.Position = new Vector2(7, -97);
m_bodyParts.AddParticle(m_head);
m_armR = new BodyPart(TextureLibrary.GetSpriteSheet("bp_basezombiearm"), new Transform(Transform, true));
m_armR.Transform.Position = new Vector2(-20, -70);
m_bodyParts.AddParticle(m_armR);
m_lowerB = new BodyPart(TextureLibrary.GetSpriteSheet("bp_basezombielowerb"), new Transform(Transform, true));
m_lowerB.Transform.Position = new Vector2(0, -40);
m_bodyParts.AddParticle(m_lowerB);
m_upperB = new BodyPart(TextureLibrary.GetSpriteSheet("bp_basezombieupperb"), new Transform(Transform, true));
m_upperB.Transform.Position = new Vector2(0, -65);
m_bodyParts.AddParticle(m_upperB);
m_armL = new BodyPart(TextureLibrary.GetSpriteSheet("bp_basezombiearm"), new Transform(Transform, true));
m_armL.Transform.Position = new Vector2(-20, -70);
m_bodyParts.AddParticle(m_armL);
m_pogoStick = new BodyPart(TextureLibrary.GetSpriteSheet("bp_pogostick"), new Transform(Transform, true));
m_pogoStick.Transform.Position = new Vector2(-6, -40);
m_bodyParts.AddParticle(m_pogoStick);
///
///Hit events
///
m_destructible.SetHitEvent(AttackType.Shuriken, OnShurikenHit);
m_destructible.SetHitEvent(AttackType.Slash, OnSliceHit);
///
/// Health events
///
m_destructible.AddHealthEvent(3, false, new MethodAction(delegate()
{
m_currentFrame = 2;
//.........这里部分代码省略.........
示例4: LoadContent
//.........这里部分代码省略.........
4,1),
new ParticleVertex(new Vector3(
(position.X - origin2.X* scale.X* (float)Math.Cos(rotation)-(-origin2.Y+tex2.Height)* scale.Y* (float)Math.Sin(rotation)),
(position.Y -origin2.X* scale.X* (float)Math.Sin(rotation)+(-origin2.Y+tex2.Height)* scale.Y* (float)Math.Cos(rotation)),
0),
Color.Green,
new Vector2(0,1),
Vector2.Zero,
4,1),
new ParticleVertex(new Vector3(
(pos2.X - origin2.X* scale.X * (float)Math.Cos(rotation) + origin2.Y* scale.Y * (float)Math.Sin(rotation)) ,
(pos2.Y - origin2.X* scale.X * (float)Math.Sin(rotation) - origin2.Y* scale.Y * (float)Math.Cos(rotation)),
0),
Color.Green,
new Vector2(0,0),
Vector2.Zero,
4,1),
new ParticleVertex(new Vector3(
(pos2.X + (tex2.Width - origin2.X)* scale.X * (float)Math.Cos(rotation) + origin2.Y* scale.Y * (float)Math.Sin(rotation)),
(pos2.Y + (tex2.Width - origin2.X)* scale.X * (float)Math.Sin(rotation) - origin2.Y* scale.Y * (float)Math.Cos(rotation)),
0),
Color.Green,
new Vector2(1,0),
Vector2.Zero,
4,1),
new ParticleVertex(new Vector3(
(pos2.X + (tex2.Width - origin2.X)* scale.X * (float)Math.Cos(rotation) - (-origin2.Y+tex2.Height)* scale.Y* (float)Math.Sin(rotation)),
(pos2.Y + (tex2.Width - origin2.X)* scale.X * (float)Math.Sin(rotation) + (-origin2.Y+tex2.Height)* scale.Y *(float)Math.Cos(rotation)),
0),
Color.Green,
new Vector2(1,1),
Vector2.Zero,
4,1),
new ParticleVertex(new Vector3(
(pos2.X - origin2.X* scale.X* (float)Math.Cos(rotation)-(-origin2.Y+tex2.Height)* scale.Y* (float)Math.Sin(rotation)),
(pos2.Y -origin2.X* scale.X* (float)Math.Sin(rotation)+(-origin2.Y+tex2.Height)* scale.Y* (float)Math.Cos(rotation)),
0),
Color.Green,
new Vector2(0,1),
Vector2.Zero,
4,1),
new ParticleVertex(new Vector3(
(pos3.X - origin2.X* scale.X * (float)Math.Cos(rotation) + origin2.Y* scale.Y * (float)Math.Sin(rotation)) ,
(pos3.Y - origin2.X* scale.X * (float)Math.Sin(rotation) - origin2.Y* scale.Y * (float)Math.Cos(rotation)),
0),
Color.Green,
new Vector2(0,0),
Vector2.Zero,
4,1),
new ParticleVertex(new Vector3(
(pos3.X + (tex2.Width - origin2.X)* scale.X * (float)Math.Cos(rotation) + origin2.Y* scale.Y * (float)Math.Sin(rotation)),
(pos3.Y + (tex2.Width - origin2.X)* scale.X * (float)Math.Sin(rotation) - origin2.Y* scale.Y * (float)Math.Cos(rotation)),
0),
Color.Green,
new Vector2(1,0),
Vector2.Zero,
4,1),
new ParticleVertex(new Vector3(
(pos3.X + (tex2.Width - origin2.X)* scale.X * (float)Math.Cos(rotation) - (-origin2.Y+tex2.Height)* scale.Y* (float)Math.Sin(rotation)),
(pos3.Y + (tex2.Width - origin2.X)* scale.X * (float)Math.Sin(rotation) + (-origin2.Y+tex2.Height)* scale.Y *(float)Math.Cos(rotation)),
0),
Color.Green,
new Vector2(1,1),
Vector2.Zero,
4,1),
new ParticleVertex(new Vector3(
(pos3.X - origin2.X* scale.X* (float)Math.Cos(rotation)-(-origin2.Y+tex2.Height)* scale.Y* (float)Math.Sin(rotation)),
(pos3.Y -origin2.X* scale.X* (float)Math.Sin(rotation)+(-origin2.Y+tex2.Height)* scale.Y* (float)Math.Cos(rotation)),
0),
Color.Green,
new Vector2(0,1),
Vector2.Zero,
4,1),
};
indices = new int[18] { 0, 1, 2, 0, 2, 3,
4,5,6 ,4,6,7,
8,9,10, 8,10,11};
ps = new ParticleSystem<TestParticle>(this);
for (int i = 0; i < 128; i++)
{
Vector2 dir = RandomVector();
dir.Normalize();
ps.AddParticle(RandomVector(), dir, .04f, 0);
}
}
示例5: FatZombie
public FatZombie()
{
m_physics = new PhysicsComponent(Globals.TheGame, Transform);
m_sprite = new Sprite(Globals.TheGame, TextureLibrary.GetSpriteSheet("zombie_phat", 1, 12), Transform);
m_sprite.Origin = new Vector2(0.5f, 1);
m_loot = Loot.GenerateLoot(12);
ObjectState.BeginAction = delegate() { m_actionManager.StartNew(m_full); };
ObjectState.StandbyAction = delegate() { m_actionManager.Stop(); m_sprite.SetFrame(0); };
ObjectState.DestroyAction = delegate() { m_destructible.ClearHitEvents(); Backpacker.HitPlayerColliders.Remove(m_collider); };
m_collider = new AABBCollider(this, new AABB(m_sprite));
Backpacker.HitPlayerColliders.Add(m_collider, delegate(Collider other) { m_physics.Throw(10.0f, -10.0f, 0.1f); } );
m_destructible = new DestructibleComponent(Transform, m_collider, m_collider.AABB, HP);
m_impactBox = new AABB(new Transform(Transform, true), new Vector2(72, 67));
m_impactBox.Transform.Position = new Vector2(13, -70);
m_shurikenReceiver = new ShurikenReceiver(Transform, m_impactBox, 10);
m_hitAnimation = new HitAnimation(World.baseEffect);
m_measurer = new AABBMeasurer(new AABB(new Transform(Transform, true), new Vector2(50, 50)));
m_full = new SpriteSheetAnimation(m_sprite, 0, 1, 0.7f, -1);
m_noHead1 = new SpriteSheetAnimation(m_sprite, 2, 3, 0.7f, -1);
m_noHead2 = new SpriteSheetAnimation(m_sprite, 4, 5, 0.7f, -1);
m_noRightArm = new SpriteSheetAnimation(m_sprite, 6, 7, 0.7f, -1);
m_noLeftArm = new SpriteSheetAnimation(m_sprite, 8, 9, 0.7f, -1);
m_noShoulders = new SpriteSheetAnimation(m_sprite, 10, 11, 0.7f, -1);
m_actionManager = new SingleActionManager();
m_actionManager.StartNew(m_full);
//_projections = new BodyPart[]
//{
// null,
// new BodyPart(this, new Vector2(0, -55), "bp_fatshoulders"),
// new BodyPart(this, new Vector2(-15, -75), "bp_basezombiearm"),
// new BodyPart(this, new Vector2(-15, -75), "bp_basezombiearm"),
// new BodyPart(this, new Vector2(-30, -100), "bp_fathead2"),
// new BodyPart(this, new Vector2(-30, -115), "bp_fathead1"),
//};
//_destroyProjections = new BodyPart[] {
// new BodyPart(this, new Vector2(0, -45), "bp_fatupperb"),
// new BodyPart(this, new Vector2(0, -10), "bp_fatlowerb"),
//};
m_bodyParts = new ParticleSystem(Globals.TheGame, 7);
m_head1 = new BodyPart(TextureLibrary.GetSpriteSheet("bp_fathead1"), new Transform(Transform, true));
m_head1.Transform.Position = new Vector2(-30, -110);
m_bodyParts.AddParticle(m_head1);
m_head2 = new BodyPart(TextureLibrary.GetSpriteSheet("bp_fathead2"), new Transform(Transform, true));
m_head2.Transform.Position = new Vector2(-30, -100);
m_bodyParts.AddParticle(m_head2);
m_shoulders = new BodyPart(TextureLibrary.GetSpriteSheet("bp_fatshoulders"), new Transform(Transform, true));
m_shoulders.Transform.Position = new Vector2(0, -80);
m_bodyParts.AddParticle(m_shoulders);
m_armL = new BodyPart(TextureLibrary.GetSpriteSheet("bp_basezombiearm"), new Transform(Transform, true));
m_armL.Transform.Position = new Vector2(-15, -75);
m_bodyParts.AddParticle(m_armL);
m_armR = new BodyPart(TextureLibrary.GetSpriteSheet("bp_basezombiearm"), new Transform(Transform, true));
m_armR.Transform.Position = new Vector2(-15, -75);
m_bodyParts.AddParticle(m_armR);
m_upperB = new BodyPart(TextureLibrary.GetSpriteSheet("bp_fatupperb"), new Transform(Transform, true));
m_upperB.Transform.Position = new Vector2(15, -65);
m_bodyParts.AddParticle(m_upperB);
m_lowerB = new BodyPart(TextureLibrary.GetSpriteSheet("bp_fatlowerb"), new Transform(Transform, true));
m_lowerB.Transform.Position = new Vector2(15, -27);
m_bodyParts.AddParticle(m_lowerB);
///
///Hit events
///
m_destructible.SetHitEvent(AttackType.Shuriken, OnShurikenHit);
m_destructible.SetHitEvent(AttackType.Slash, OnSliceHit);
///
/// Health events
///
m_destructible.AddHealthEvent(7, false, new MethodAction(delegate()
{
m_actionManager.StartNew(m_noHead1);
m_head1.Pop(-1.1f, 500, true);
}));
m_destructible.AddHealthEvent(6, false, new MethodAction(delegate()
{
m_actionManager.StartNew(m_noHead2);
m_head2.Pop(-1.1f, 500, true);
}));
m_destructible.AddHealthEvent(5, false, new MethodAction(delegate()
{
m_actionManager.StartNew(m_noRightArm);
m_armR.Pop(-1.1f, 500, true);
}));
//.........这里部分代码省略.........
示例6: BasicZombie
public BasicZombie()
: base()
{
m_physics = new PhysicsComponent(Globals.TheGame, Transform);
m_sprite = new Sprite(Globals.TheGame, TextureLibrary.GetSpriteSheet("zombie_base", 1, 8), Transform);
m_sprite.Origin = new Vector2(0.5f, 1.0f);
m_loot = Loot.GenerateLoot(4);
ObjectState.BeginAction = delegate()
{
m_actionManager.StartNew(m_full);
};
ObjectState.StandbyAction = delegate()
{
m_actionManager.Stop();
m_sprite.SetFrame(0);
};
ObjectState.DestroyAction = delegate()
{
m_destructible.ClearHitEvents();
Backpacker.HitPlayerColliders.Remove(m_collider);
};
m_collider = new AABBCollider(this, new AABB(m_sprite));
Backpacker.HitPlayerColliders.Add(m_collider, delegate(Collider other) { m_physics.Throw(10.0f, -10.0f, 0.1f); });
m_destructible = new DestructibleComponent(Transform, m_collider, m_collider.AABB, HP);
m_impactBox = new AABB(new Transform(Transform, true), new Vector2(22, 42));
m_impactBox.Transform.Position = new Vector2(13, -44);
m_measurer = new AABBMeasurer(m_impactBox);
m_shurikenReceiver = new ShurikenReceiver(Transform, m_impactBox, 5);
m_hitAnimation = new HitAnimation(World.baseEffect);
m_full = new SpriteSheetAnimation(m_sprite, 0, 1, 0.5f, -1);
m_noHead = new SpriteSheetAnimation(m_sprite, 2, 3, 0.5f, -1);
m_noLeftArm = new SpriteSheetAnimation(m_sprite, 4, 5, 0.5f, -1);
m_noRightArm = new SpriteSheetAnimation(m_sprite, 6, 7, 0.5f, -1);
m_actionManager = new SingleActionManager();
//Transform headTransform = new Transform(Transform, true
//_projections = new BodyPart[] {
// null,
// new BodyPart(this, new Vector2(0, -65), "bp_basezombiearm"),
// new BodyPart(this, new Vector2(-10, -55), "bp_basezombiearm"),
// new BodyPart(this, new Vector2(15, -75), "bp_basezombiehead"),
// new BodyPart(this, new Vector2(10, -50), "bp_basezombieupperb"),
// new BodyPart(this, new Vector2(10, -10), "bp_basezombielowerb")
//};
///
/// Body Parts
///
m_bodyParts = new ParticleSystem(Globals.TheGame, 5);
m_head = new BodyPart(TextureLibrary.GetSpriteSheet("bp_basezombiehead"), new Transform(Transform, true));
m_head.Transform.Position = new Vector2(5, -50);
m_bodyParts.AddParticle(m_head);
m_armL = new BodyPart(TextureLibrary.GetSpriteSheet("bp_basezombiearm"), new Transform(Transform, true));
m_armL.Transform.Position = new Vector2(5, -30);
m_bodyParts.AddParticle(m_armL);
m_armR = new BodyPart(TextureLibrary.GetSpriteSheet("bp_basezombiearm"), new Transform(Transform, true));
m_armR.Transform.Position = new Vector2(-5, -30);
m_bodyParts.AddParticle(m_armR);
m_upperB = new BodyPart(TextureLibrary.GetSpriteSheet("bp_basezombieupperb"), new Transform(Transform, true));
m_upperB.Transform.Position = new Vector2(0, -30);
m_bodyParts.AddParticle(m_upperB);
m_lowerB = new BodyPart(TextureLibrary.GetSpriteSheet("bp_basezombielowerb"), new Transform(Transform, true));
m_lowerB.Transform.Position = new Vector2(0, -10);
m_bodyParts.AddParticle(m_lowerB);
///
///Hit events
///
m_destructible.SetHitEvent(AttackType.Shuriken, OnShurikenHit);
m_destructible.SetHitEvent(AttackType.Slash, OnSliceHit);
///
/// Health events
///
m_destructible.AddHealthEvent(3, false, new MethodAction(delegate()
{
m_actionManager.StartNew(m_noHead);
m_head.Pop(-1.1f, 500, true);
}));
m_destructible.AddHealthEvent(2, false, new MethodAction(delegate()
{
m_actionManager.StartNew(m_noLeftArm);
m_armL.Pop(-1.1f, 500, true);
}));
m_destructible.AddHealthEvent(1, false, new MethodAction(delegate()
{
m_actionManager.StartNew(m_noRightArm);
m_armR.Pop(-1.1f, 500, true);
}));
m_destructible.AddHealthEvent(0, false, new MethodAction(delegate()
//.........这里部分代码省略.........
示例7: EmitParticle
protected void EmitParticle(ParticleSystem particleSystem, Particle particle)
{
particleSystem.AddParticle(particle);
}