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], }, }; }
protected override void ExecuteImpl(EntityCollection entities) { var shipScript = ShipScript.Instance; var player = shipScript.Ship.Create("player") .Configure(new IComponent[] { new CustomKeyboardInputable((e, s) => { e.Set(TimedEmitter.IsEmitting, s.IsKeyDown(Keys.X)); }), new CustomKiller((e, killed) => { uint earnedPoints = killed.Get(Properties.Points); e.Update(Properties.Score, (x) => earnedPoints + x); }), }) .Configure( Collidable.Body, new Body(new ShapePrimitive[] { new CircleShape(Vector2.Zero, 32) }) ) .Configure(Located.Position, new Vector2(50, 50)); entities.EnqueueSpawn(player); entities.EnqueueSpawn(new Entity("ship score display") { Texted.Instance, new CustomUpdated((e, gt) => { // I have a bad feeling about the UI being updated like // other entities. =\ e.Set(Texted.Text, player.Get(Properties.Score).ToString()); }), { Texted.Font, font }, { Texted.Text, "hello world" }, }); }
protected override void ExecuteImpl(EntityCollection entities) { var powerupP = new Entity("powerup") { Textured.Instance, { Textured.Texture, this.powerupTexture }, { Properties.IsPowerup, true }, { Collidable.Body, new Body(new ShapePrimitive[] { new CircleShape(Vector2.Zero, 12) }) }, }; entities.EnqueueSpawn(powerupP.Create().Configure((e) => { e.Set(Located.Position, new Vector2(200, 100)); })); entities.EnqueueSpawn(powerupP.Create().Configure((e) => { e.Set(Located.Position, new Vector2(300, 300)); })); }
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) }) }, }); }