/// <summary> /// /// </summary> /// <param name="world"></param> /// <param name="args">args[0] = center location, args[1] = explosion intensity, args[2] = Entity ent</param> /// <returns></returns> public Entity[] BuildEntityGroup(EntityWorld world, params object[] args) { Vector2 center = (Vector2)args[0]; int intensity = 15; Entity ent = (Entity)args[2]; Vector2 velocity = (Vector2)args[3]; int[] size = new int[4]; for (int i = 1; i < 4; ++i) { size[i] = intensity / (i + 1); float radius = 0; for (int k = 5 - i; k > i; k--) { radius += (float)spriteSheet["splosion" + k.ToString()][0].Width / (k == i + 1 && i == 2 ? 2f : 3f); } radius = ConvertUnits.ToSimUnits(radius); Vector2 offset; double max = Math.PI * 2; double step = (Math.PI * 2) / (double)size[i]; for (double angle = 0; angle < max; angle += step) { offset = new Vector2(radius * (float)Math.Cos(angle), radius * (float)Math.Sin(angle)); world.CreateEntity("Explosion", 0.05f * (i + 1), center + offset, ent, (i + 1), velocity).Refresh(); } } return explosions.ToArray(); }
public TurretTemplate(SpriteSheet spriteSheet, DirectorSystem directorSystem, EntityWorld world) { Turrets.Clear(); _SpriteSheet = spriteSheet; _DirectorSystem = directorSystem; _World = world; }
public Entity[] BuildEntityGroup(EntityWorld world, params object[] args) { const int segmentCount = 20; Entity[] segments = new Entity[segmentCount]; //Make teh bridge segments and bind dem togeder PolygonShape shape = new PolygonShape(1f); shape.SetAsBox(1.0f, 0.125f); Body prevBody = args[0] as Body; for (int i = 0; i < segmentCount; ++i) { Entity segment = world.CreateEntity(); segment.Tag = "segment" + i; Body body = segment.AddComponent<Body>(new Body(world, segment)); body.BodyType = BodyType.Dynamic; body.Position = new Vector2(161f + 2f * i, 0.125f); Fixture fix = body.CreateFixture(shape); fix.Friction = 0.6f; JointFactory.CreateRevoluteJoint(world, prevBody, body, -Vector2.UnitX); segments[i] = segment; prevBody = body; } JointFactory.CreateRevoluteJoint(world, args[0] as Body, prevBody, Vector2.UnitX); return segments; }
public Entity[] BuildEntityGroup(EntityWorld world, params object[] args) { Inventory inv = (args[0] as Entity).GetComponent<Inventory>(); List<Entity> rets = new List<Entity>(); //If the bullet type is not white if (inv.YELLOW > 0) { int shot = 1; SoundManager.Play("Shot" + shot.ToString(), .25f); //Shoot bullets out from base at an even division of the circle * a shot ratio double max = Math.PI * 2; double step = (Math.PI * 2 * ShotRatio) / (Math.Min(inv.YELLOW, MaxShot)); for (double angle = 0; angle < max; angle += step) { Transform fireAt = new Transform(Vector2.Zero, (float)angle); Entity bullet = world.CreateEntity("WhiteBullet3", fireAt); Bullet bb = bullet.GetComponent<Bullet>(); bb.Firer = null; bullet.RemoveComponent<Bullet>(bullet.GetComponent<Bullet>()); bullet.AddComponent<Bullet>(bb); bullet.Refresh(); rets.Add(bullet); } inv.YELLOW = 0; } return rets.ToArray(); }
public Body(EntityWorld world, Entity e) : base(world, e) { //Add transform and velocity e.AddComponent<ITransform>(this); e.AddComponent<IVelocity>(this); e.AddComponent<IDamping>(this); }
public Entity[] BuildEntityGroup(EntityWorld world, params object[] args) { for (int i = 0; i < starNum; ++i) { Entity e = world.CreateEntity("Star"); e.Refresh(); stars.Add(e); } world.CreateEntity("Star", "Lolbig").Refresh(); return stars.ToArray(); }
public static Action<Entity> BigEnemyDeath(Entity e, EntityWorld _World, int points) { return ent => { Vector2 poss = e.GetComponent<ITransform>().Position; _World.CreateEntityGroup("BigExplosion", "Explosions", poss, 10, ent, e.GetComponent<IVelocity>().LinearVelocity); int splodeSound = rbitch.Next(1, 5); SoundManager.Play("Explosion" + splodeSound.ToString()); if (ent is Entity && (ent as Entity).Group != null && ((ent as Entity).Group == "Players" || (ent as Entity).Group == "Structures") && e.HasComponent<Crystal>()) { _World.CreateEntity("Crystal", e.GetComponent<ITransform>().Position, e.GetComponent<Crystal>().Color, e.GetComponent<Crystal>().Amount, e); ScoreSystem.GivePoints(points); _World.CreateEntity("Score", points.ToString(), poss).Refresh(); } }; }
public Entity[] BuildEntityGroup(EntityWorld world, params object[] args) { Entity[] Car = new Entity[3]; //Chassis Car[2] = world.CreateEntity("Chassis", args[0], args[1]); //Back wheel Car[1] = world.CreateEntity("Wheel", args[2], args[3], new Vector2(-1.709f, -0.78f), //pos new CircleShape(0.5f, 0.8f), //shape 0.9f); //friction //Front wheel Car[0] = world.CreateEntity("Wheel", args[2], args[3], new Vector2(1.54f, -0.8f), //pos new CircleShape(0.5f, 1f)); //shape //Now to create the springs. LineJoint _springBack, _springFront; Vector2 axis = new Vector2(0.0f, -1.2f); //front spring _springFront = new LineJoint(Car[2].GetComponent<Body>(), Car[0].GetComponent<Body>(), Car[0].GetComponent<Body>().Position, axis); _springFront.MotorSpeed = 0.0f; _springFront.MaxMotorTorque = 10.0f; _springFront.MotorEnabled = false; _springFront.Frequency = 8.5f; _springFront.DampingRatio = 0.85f; world.AddJoint(_springFront); // back spring with a motor _springBack = new LineJoint(Car[2].GetComponent<Body>(), Car[1].GetComponent<Body>(), Car[1].GetComponent<Body>().Position, axis); _springBack.MotorSpeed = 0.0f; _springBack.MaxMotorTorque = 20.0f; _springBack.MotorEnabled = true; _springBack.Frequency = 5.0f; _springBack.DampingRatio = 0.85f; world.AddJoint(_springBack); //Send it off! return Car; }
/// <summary> /// /// </summary> /// <param name="world"></param> /// <param name="args">args[0] = center location, args[1] = explosion intensity, args[2] = Entity ent</param> /// <returns></returns> public Entity[] BuildEntityGroup(EntityWorld world, params object[] args) { Vector2 center = (Vector2)args[0]; int intensity = (int)args[1]; Entity ent = (Entity)args[2]; Vector2 velocity = (Vector2)args[3]; world.CreateEntityGroup("BigExplosion", "Explosions", center, 15, ent, velocity); double max = Math.PI * 2; double step = (Math.PI * 2) / intensity; for (double angle = 0; angle < max; angle += step) { float radius = 75; radius = ConvertUnits.ToSimUnits(radius); Vector2 offset = new Vector2(radius * (float)Math.Cos(angle), radius * (float)Math.Sin(angle)); offset.Normalize(); offset *= radius; world.CreateEntityGroup("BigExplosion", "Explosions", center + offset, 15, ent, velocity); } return explosions.ToArray(); }
public static Func<Body, bool> CreateKillerGun(Entity ent, Entity origin, Vector2 offs, float shotTime, float shootTime, float nonShot, Sprite s, EntityWorld _World, bool shit) { bool shot = false; float shotttt = 0f; float time = 0f; return (target) => { Body b = ent.GetComponent<Body>(); Body b2 = origin.GetComponent<Body>(); b.RotateTo(Vector2.UnitX); b.Position = b2.Position + offs; if (shot) { if (shotttt > shotTime) { shotttt = 0f; Vector2 offset = ConvertUnits.ToSimUnits(new Vector2(0, 50)); if (shit) offset.X = ConvertUnits.ToSimUnits(6); float rot = (float)Math.PI / 2; Transform fireAt = new Transform(b.Position + offset, rot); SoundManager.Play("Shot1"); _World.CreateEntity("KillerBullet", fireAt).Refresh(); } if (time > shootTime) { time = 0f; shot = false; } } else { if (time > nonShot) { time = 0f; shot = true; } } if (!ent.HasComponent<Slow>()) { shotttt += (float)_World.Delta / 1000; time += (float)_World.Delta / 1000; } return false; }; }
public static Func<Body, bool> CreateWarMachine(Entity ent, float speed, Body bitch, float sideTime, float shootTime, Sprite s, EntityWorld _World) { float shotTime = 0f; float time = 0f; return (target) => { if (time > sideTime) time = 0f; Body b = ent.GetComponent<Body>(); float x = (float)(ConvertUnits.ToSimUnits(ScreenHelper.Viewport.Width / 2) * (Math.Cos(MathHelper.ToRadians(360 / sideTime) * time))); if (shotTime > shootTime) { shotTime = 0f; Vector2 velocity1 = new Vector2(0, 1); velocity1 *= 8f; SoundManager.Play("Shot2"); _World.CreateEntity("ExplosiveBullet", bitch.Position, velocity1, 1, "reddownmissile").Refresh(); } if (!ent.HasComponent<Slow>()) { b.Position = new Vector2(x, b.Position.Y + speed * _World.Delta / 1000); shotTime += (float)_World.Delta / 1000; time += (float)_World.Delta / 1000; } else { handleSlow(ent, _World); } return false; }; }
public static Func<Body, bool> CreateKiller(Entity ent, float speed, float sideTime, EntityWorld world) { float time = 0f; return (target) => { if (time > sideTime) { time = 0f; } Body b = ent.GetComponent<Body>(); float x = (float)(ConvertUnits.ToSimUnits(ScreenHelper.Viewport.Width / 2) * (Math.Cos(MathHelper.ToRadians(360 / sideTime) * time))); if (!ent.HasComponent<Slow>()) { b.Position = new Vector2(x, b.Position.Y + speed * world.Delta / 1000); time += (float)world.Delta / 1000; ent.GetComponent<Children>().CallChildren(b); } else { handleSlow(ent, world); } return false; }; }
public static Func<Body, bool> CreateFlamer(Entity ent, float speed, Body bitch, Sprite s, EntityWorld _World) { int times = 0; return (target) => { ++times; Body b = ent.GetComponent<Body>(); Vector2 distance = target.Position - b.Position; if (distance != Vector2.Zero) distance.Normalize(); distance *= speed; if (target != null && target.LinearVelocity != distance && !ent.HasComponent<Slow>()) { b.LinearVelocity = distance; } if (times % 10 == 0) { int range = s.CurrentRectangle.Width / 2; float posx = -range; Vector2 pos1 = bitch.Position + ConvertUnits.ToSimUnits(new Vector2(posx, 0)); Vector2 pos2 = bitch.Position - ConvertUnits.ToSimUnits(new Vector2(posx, 0)); float x = posx / range; float y = 1; Vector2 velocity1 = new Vector2(x, y); velocity1.Normalize(); velocity1 *= 7; Vector2 velocity2 = new Vector2(-velocity1.X, velocity1.Y); _World.CreateEntity("Fire", pos1, velocity1).Refresh(); _World.CreateEntity("Fire", pos2, velocity2).Refresh(); } return false; }; }
public MookTemplate(SpriteSheet spriteSheet, EntityWorld world) { mooks = 0; _SpriteSheet = spriteSheet; _World = world; }
public GunnerTemplate(SpriteSheet spriteSheet, EntityWorld world) { gunners = 0; _SpriteSheet = spriteSheet; _World = world; }
public PlayerTemplate(EntityWorld world) { this._World = world; }
public ThugTemplate(SpriteSheet spriteSheet, EntityWorld world) { thugs = 0; _SpriteSheet = spriteSheet; _World = world; }
protected DebugView(EntityWorld world) { World = world; }
internal TagManager(EntityWorld world) { this.world = world; }
public SmasherBallTemplate(SpriteSheet spriteSheet, EntityWorld world) { _SpriteSheet = spriteSheet; _World = world; }
private static void handleSlow(Entity ent, EntityWorld _World) { (_World as SpaceWorld).slowSystem.SpawnFrostEffect(ent); Slow slow = ent.GetComponent<Slow>(); slow.Elapsed--; if (slow.Elapsed <= 0) { ent.RemoveComponent<Slow>(slow); } }
public StickTemplate(EntityWorld world) { this._World = world; }
public Entity[] BuildEntityGroup(EntityWorld world, params object[] args) { Rectangle tileSource = (Rectangle)args[1]; int maxWidth = (graphics.Viewport.Width * 2 / tileSource.Width) + 1; int maxHeight = (graphics.Viewport.Height * 2 / tileSource.Height) + 1; Entity[] tiles = new Entity[maxHeight * maxWidth]; //Make all of the tiles for (int i = 0; i < tiles.Length; i++) { int height = i / maxWidth; int width = i - height * maxWidth; tiles[i] = world.CreateEntity(); tiles[i].AddComponent<Sprite>(new Sprite(args[0] as Texture2D, tileSource, Vector2.Zero, 1f, Color.White,0.5f)); tiles[i].AddComponent<ITransform>(new Transform( ConvertUnits.ToSimUnits(new Vector2( width * tileSource.Width - maxWidth * tileSource.Width/2, //Offset width height * tileSource.Height - maxHeight * tileSource.Height / 2)), //Offset height 0f)); tiles[i].Refresh(); } Rectangle treeSource = (Rectangle)args[3]; List<Entity> treeList = new List<Entity>(); for(int y = 0; y <= graphics.Viewport.Height / treeSource.Height + 1; y++) for (int x = 0; ((y == 0 || y == graphics.Viewport.Height / treeSource.Height + 1) ? x < graphics.Viewport.Width / treeSource.Width + 2 : x <1); x++) { Entity e = world.CreateEntity(); //Body Body treeBody = e.AddComponent<Body>(new Body(world, e)); treeBody.BodyType = GameLibrary.Dependencies.Physics.Dynamics.BodyType.Static; FixtureFactory.AttachCircle(ConvertUnits.ToSimUnits(treeSource.Width / 2), 1f, treeBody); treeBody.Position = ConvertUnits.ToSimUnits(new Vector2(x * treeSource.Width, y * treeSource.Height) - new Vector2(graphics.Viewport.Bounds.Center.X, graphics.Viewport.Bounds.Center.Y) + new Vector2(15)); //sprite e.AddComponent<Sprite>(new Sprite(args[2] as Texture2D, treeSource, treeBody, 1f, Color.White, 0.2f)); e.Refresh(); treeList.Add(e); } Random r = new Random(); for (int i = 0; i < 50; i++) { Entity e = world.CreateEntity(); //Body Body treeBody = e.AddComponent<Body>(new Body(world, e)); treeBody.BodyType = GameLibrary.Dependencies.Physics.Dynamics.BodyType.Static; FixtureFactory.AttachCircle(ConvertUnits.ToSimUnits(treeSource.Width / 2), 1f, treeBody); treeBody.Position = ConvertUnits.ToSimUnits(new Vector2(r.Next(0, graphics.Viewport.Width), r.Next(0, graphics.Viewport.Height)) - new Vector2(graphics.Viewport.Bounds.Center.X, graphics.Viewport.Bounds.Center.Y) + new Vector2(15)); //sprite e.AddComponent<Sprite>(new Sprite(args[2] as Texture2D, treeSource, treeBody, 1f, Color.White, 0.2f)); e.Refresh(); treeList.Add(e); } Entity[] Terrain = new Entity[treeList.Count + tiles.Length]; tiles.CopyTo(Terrain, 0); treeList.CopyTo(Terrain, tiles.Length); return Terrain; }
public DestroyerTemplate(SpriteSheet spriteSheet, EntityWorld world) { destroyers = 0; _SpriteSheet = spriteSheet; _World = world; }
public static Func<Body, bool> CreateBigGreen(Entity ent, float speed, float sideTime, float shootTime, float shotTime, float nonShoot, Sprite s, EntityWorld _World) { bool shot = false; float shotttt = 0f; float time = 0f; float ttttime = 0f; return (target) => { if (ttttime > sideTime) { ttttime = 0f; } Body b = ent.GetComponent<Body>(); float x = (float)(ConvertUnits.ToSimUnits(ScreenHelper.Viewport.Width / 2) * (Math.Cos(MathHelper.ToRadians(360 / sideTime) * ttttime))); time += (float)_World.Delta / 1000; if (shot) { if (shotttt > shotTime) { shotttt = 0f; Vector2 offset = ConvertUnits.ToSimUnits(new Vector2(0, 25)); float rot = (float)Math.PI / 2; Transform fireAt = new Transform(b.Position + offset, rot); SoundManager.Play("Shot1"); _World.CreateEntity("BigGreenBullet", fireAt).Refresh(); } if (time > shootTime) { time = 0f; shot = false; } } else { if (time > nonShoot) { time = 0f; shot = true; } } if (!ent.HasComponent<Slow>()) { b.Position = new Vector2(x, b.Position.Y + speed * _World.Delta / 1000); shotttt += (float)_World.Delta / 1000; time += (float)_World.Delta / 1000; ttttime += (float)_World.Delta / 1000; } else { handleSlow(ent, _World); } return false; }; }
public MineTemplate(SpriteSheet spriteSheet, EntityWorld world) { _SpriteSheet = spriteSheet; _World = world; }
internal GroupManager(EntityWorld world) { this.world = world; }
public CannonTemplate(SpriteSheet spriteSheet, EntityWorld world) { cannons = 0; _SpriteSheet = spriteSheet; _World = world; }
protected PhysicsDebugView(EntityWorld world) { World = world; }
public CrystalTemplate(EntityWorld World, SpriteSheet spriteSheet) { crystals = 0; this._World = World; this._SpriteSheet = spriteSheet; }