public GameState() { int playerFaction = 0; int enemyFaction = 1; var ship = new Ship(this, Vector2.Zero, new KeyboardShipController(this), playerFaction); new PlayerView(this, ship); this.playerShips.Add(ship); for (int i = 0; i < 4; i++) { var x = 2 -1.33f * i; var a = Angle.FromDegrees(90); ship.AddEquipment(new Cannon(this, new Vector2(x, 2), a, GunControlGroup.Left)); ship.AddEquipment(new Cannon(this, new Vector2(x, -2), -a, GunControlGroup.Right)); } var shipFactory = new ShipFactory(this); for (int i = 0; i < 5; i++) { shipFactory.MakeShip(new Vector2(100, -40 + i * 20), enemyFaction, direction:Direction2.FromDegrees(180)); } shipFactory.MakeShip(new Vector2(0, 15), playerFaction, 2, 3); shipFactory.MakeShip(new Vector2(0, -15), playerFaction, 2, 3); }
public void MakeShip(Vector2 position, int faction, int minCannons = 2, int maxCannons = 5, Direction2 direction = default(Direction2)) { var cannons = StaticRandom.Int(minCannons, maxCannons + 1); var s = new Ship(this.game, position, new SimpleEnemyShipController(this.game), faction, 11 - 3f / 2f * cannons, direction, Math.Min(0.4f + 0.1f * cannons, 0.9f) ); for (int j = 0; j < cannons; j++) { var x2 = (j - cannons / 2f + 0.5f) / cannons * 5; var a = Angle.FromDegrees(90); s.AddEquipment(new Cannon(this.game, new Vector2(x2, 2), a, GunControlGroup.Left)); s.AddEquipment(new Cannon(this.game, new Vector2(x2, -2), -a, GunControlGroup.Right)); } }