Exemplo n.º 1
0
        public void SetOwner(Ship ship)
        {
            if (this.owner != null)
                throw new Exception("Equipment can only be added to a single ship.");

            this.owner = ship;
        }
Exemplo n.º 2
0
        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);
        }
Exemplo n.º 3
0
 public Projectile(GameState game, Ship owner, Vector2 position,
     Vector2 baseVelocity, Direction2 direction, float speed, float lifeTime)
     : base(game)
 {
     this.owner = owner;
     this.position = position;
     this.velocity = baseVelocity + direction.Vector * speed;
     this.deathTime = game.TimeF + lifeTime;
 }
Exemplo n.º 4
0
        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));
            }
        }
Exemplo n.º 5
0
 public void SetShip(Ship ship)
 {
     this.ship = ship;
 }