本文整理汇总了C#中EntityCollection.EnqueueDestroy方法的典型用法代码示例。如果您正苦于以下问题:C# EntityCollection.EnqueueDestroy方法的具体用法?C# EntityCollection.EnqueueDestroy怎么用?C# EntityCollection.EnqueueDestroy使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类EntityCollection
的用法示例。
在下文中一共展示了EntityCollection.EnqueueDestroy方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ExecuteImpl
protected override void ExecuteImpl(EntityCollection entities)
{
var bulletP = new Entity("bullet") {
Textured.Instance,
Order2Update.Instance,
new CustomOnEscape(new BoundingBox2(
new Vector2(0, 0),
new Vector2(640, 480)
), (e) => {
entities.EnqueueDestroy(e);
}),
{ Textured.Texture, this.bulletTexture },
{ Properties.DestroysEnemies, true },
{ Properties.Damage, 10.0f },
{
Collidable.Body,
new Body(new ShapePrimitive[] {
new CircleShape(Vector2.Zero, 8)
})
},
};
var basicWeapon = new Entity {
new CustomBulletEmitter((e, weaponOwner) => {
var bullet = bulletP.Create();
bullet.Set(Located.Position, e.Get(Located.Position) + weaponOwner.Get(Located.Position));
bullet.Set(Located.Velocity, e.Get(Located.Velocity));
bullet.Set(Properties.Owner, weaponOwner);
entities.EnqueueSpawn(bullet);
})
};
var weapons = new[] {
basicWeapon.Create("top").Configure((e) => {
e.Set(Located.Position, new Vector2(0, 0));
e.Set(Located.Velocity, new Vector2(7, 0));
}),
basicWeapon.Create("bottom").Configure((e) => {
e.Set(Located.Position, new Vector2(0, 30));
e.Set(Located.Velocity, new Vector2(7, 0));
}),
basicWeapon.Create("center").Configure((e) => {
e.Set(Located.Position, new Vector2(0, 15));
e.Set(Located.Velocity, new Vector2(7, 0));
}),
};
this.weaponConfigs = new[] {
new[] { weapons[2], },
new[] { weapons[0], weapons[1], },
new[] { weapons[0], weapons[1], weapons[2], },
};
}
示例2: ExecuteImpl
protected override void ExecuteImpl(EntityCollection entities)
{
entities.EnqueueSpawn(new Entity("enemy") {
Textured.Instance,
new CustomUpdated((e, gt) => {
e.Update(Properties.Milliseconds, (t) => t + (uint) gt.ElapsedGameTime.TotalMilliseconds);
float d = (float) Math.Sin(e.Get(Properties.Milliseconds) / 1000.0f) * 50;
e.Set(Located.Position, new Vector2(0, d) + new Vector2(500, 100));
}),
new CustomCollidable((e, other) => {
if (other.Get(Properties.DestroysEnemies)) {
entities.EnqueueDestroy(other);
var ownerE = other.Get(Properties.Owner);
Healthed.Damage(e, other.Get(Properties.Damage), ownerE);
}
}),
new CustomKillable((e, killer) => {
entities.EnqueueDestroy(e);
}),
{ Textured.Texture, this.enemyTexture },
{ Located.Position, new Vector2(500, 100) },
{ Healthed.Health, 30.0f },
{ Properties.Points, 50U },
{
Collidable.Body,
new Body(new ShapePrimitive[] {
new CircleShape(Vector2.Zero, 16)
})
},
});
}
示例3: ExecuteImpl
protected override void ExecuteImpl(EntityCollection entities)
{
var shipBulletScript = ShipBulletScript.Instance;
this.Ship = new Entity("ship proto") {
Textured.Instance,
Order2Update.Instance,
VelocityInputed.Instance,
Weaponized.Instance,
new TimedEmitter((e) => {
e.ForEach<Weaponized>((c) => {
c.Emit(e);
});
}),
new CustomCollidable((e, other) => {
if (other.Get(Properties.IsPowerup)) {
entities.EnqueueDestroy(other);
var weaponConfig = e.Get(Weaponized.WeaponConfiguration);
var nextWeaponConfig = shipBulletScript.WeaponConfigs
.SkipWhile((wc) => wc != weaponConfig)
.Skip(1)
.FirstOrDefault();
if (nextWeaponConfig != null) {
e.Set(Weaponized.WeaponConfiguration, nextWeaponConfig);
}
}
}),
{ Textured.Texture, this.shipTexture },
{ Located.Position, new Vector2(30, 30) },
{ Properties.Score, 0U },
{ Weaponized.WeaponConfiguration, shipBulletScript.WeaponConfigs[0] },
{
Collidable.Body,
new Body(new ShapePrimitive[] {
new CircleShape(Vector2.Zero, 32)
})
},
};
}