public void TravelTo(IStarship ship, StarSystem destination) { if (ship.Health <= 0) { throw new ShipException("Ship is destroyed!"); } var startLocation = ship.Location; if (!startLocation.NeighbourStarSystems.ContainsKey(destination)) { throw new LocationOutOfRangeException(string.Format( "Cannot travel directly from {0} to {1}", startLocation.Name, destination.Name)); } if (ship.Location.Name.Equals(destination.Name)) { throw new ShipException(string.Format(Messages.ShipAlreadyInStarSystem, destination.Name)); } double requiredFuel = startLocation.NeighbourStarSystems[destination]; if (ship.Fuel < requiredFuel) { throw new InsufficientFuelException(string.Format( "Not enough fuel to travel to {0} - {1}/{2}", destination.Name, ship.Fuel, requiredFuel)); } ship.Fuel -= requiredFuel; ship.Location = destination; }
public Dreadnought(string name, StarSystem location) : base(name, location) { this.Health = ShipValues.DreadnoughtHealth; this.Shields = ShipValues.DreadnoughtShields; this.Damage = ShipValues.DreadnoughtDamage; this.Fuel = ShipValues.DreadnoughtFuel; }
protected Starship(string name, int health, int shields, int damage, double fuel, StarSystem location) { this.Name = name; this.Health = health; this.Shields = shields; this.Damage = damage; this.Fuel = fuel; }
public Cruiser(string name, StarSystem location) : base(name, location) { this.Health = ShipValues.CruiserHealth; this.Shields = ShipValues.CruiserShields; this.Damage = ShipValues.CruiserDamage; this.Fuel = ShipValues.CruiserFuel; }
protected Ship(string name, int health, int shield, int damage, int fuel, StarSystem location) { this.Name = name; this.Health = health; this.Shields = shield; this.Damage = damage; this.Fuel = fuel; this.Location = location; }
public Frigate(string name, StarSystem location) : base(name, location) { this.Health = ShipValues.FrigateHealth; this.Shields = ShipValues.FrigateShields; this.Damage = ShipValues.FrigateDamage; this.Fuel = ShipValues.FrigateFuel; this.ProjectilesFired = 0; }
protected Starship(string name, StarSystem location, int health, int shileds, int damage, double fuel) { this.Name = name; this.Location = location; this.health = health; this.shields = shileds; this.damage = damage; this.fuel = fuel; this.enhancementsList = new List<Enhancement>(); }
protected Starship(string name, int health, int shields, int damage, double fuel, StarSystem location) { this.Name = name; this.Health = health; this.Shields = shields; this.Damage = damage; this.Fuel = fuel; this.Location = location; this.enhancements = new List<Enhancement>(); }
protected Ship(string name, int health, int shields, int damage, double fuel, StarSystem location) { shipNames = new List<string>(); shipNames.Add(name); enhancementsList = new List<Enhancement>(); Name = name; Health = health; Shields = shields; Damage = damage; Fuel = fuel; Location = location; }
public IStarship CreateShip(StarshipType type, string name, StarSystem location) { switch (type) { case StarshipType.Frigate: return new Frigate(name,location); case StarshipType.Cruiser: return new Cruiser(name, location); case StarshipType.Dreadnought: return new Dreadnought(name, location); default: throw new NotSupportedException("Starship type not supported."); } }
public IStarship CreateShip(StarshipType type, string name, StarSystem location) { switch (type) { case StarshipType.Frigate: // TODO: case StarshipType.Cruiser: // TODO: case StarshipType.Dreadnought: // TODO: default: throw new NotSupportedException("Starship type not supported."); } }
public IStarship CreateShip(StarshipType type, string name, StarSystem location) { IStarship ship; switch (type) { case StarshipType.Frigate: ship = new Frigate(name, location); break; case StarshipType.Cruiser: ship = new Cruiser(name, location); break; case StarshipType.Dreadnought: ship = new Dreadnought(name, location); break; default: throw new NotSupportedException("Starship type not supported."); } Console.WriteLine(Messages.CreatedShip, ship.GetType().Name, ship.Name); return ship; }
public void TravelTo(IStarship ship, StarSystem destination) { var startLocation = ship.Location; if (!startLocation.NeighbourStarSystems.ContainsKey(destination)) { throw new LocationOutOfRangeException(string.Format( "Cannot travel directly from {0} to {1}", startLocation.Name, destination.Name)); } double requiredFuel = startLocation.NeighbourStarSystems[destination]; if (ship.Fuel < requiredFuel) { throw new InsufficientFuelException(string.Format( "Not enough fuel to travel to {0} - {1}/{2}", destination.Name, ship.Fuel, requiredFuel)); } ship.Fuel -= requiredFuel; ship.Location = destination; }
public static void SeedStarSystems(Galaxy galaxy) { var artemisTau = new StarSystem("Artemis-Tau"); var serpentNebula = new StarSystem("Serpent-Nebula"); var hadesGamma = new StarSystem("Hades-Gamma"); var keplerVerge = new StarSystem("Kepler-Verge"); galaxy.StarSystems.Add(artemisTau); galaxy.StarSystems.Add(serpentNebula); galaxy.StarSystems.Add(hadesGamma); galaxy.StarSystems.Add(keplerVerge); artemisTau.NeighbourStarSystems.Add(serpentNebula, 50); artemisTau.NeighbourStarSystems.Add(keplerVerge, 120); serpentNebula.NeighbourStarSystems.Add(artemisTau, 50); serpentNebula.NeighbourStarSystems.Add(hadesGamma, 360); hadesGamma.NeighbourStarSystems.Add(serpentNebula, 360); hadesGamma.NeighbourStarSystems.Add(keplerVerge, 145); keplerVerge.NeighbourStarSystems.Add(hadesGamma, 145); keplerVerge.NeighbourStarSystems.Add(artemisTau, 120); }
public Dreadnought(string name, int health, int shield, int damage, double fuel, StarSystem location) : base(name, health, shield, damage, fuel, location) { }
public Cruiser(string name, StarSystem location) : base(name, DefaultCruiserHealth, DefaultCruiserShield, DefaultCruiserDamage, DefaultCruisereFuel, location) { }
public Dreadnought(string name, StarSystem locatiin) : base(name, DreadnoughtHealth, DreadnoughtShields, DreadnoughtDamage, DreadnoughtFuel, locatiin) { }
public Frigate(string name, StarSystem location) : base(name, location, health: 60, shileds: 50, damage: 30, fuel: 220) { this.ProjectilesFired = 0; this.Type = StarshipType.Frigate; }
public Dreadnought(string name, StarSystem location) : base(name, DefHealth, DefShields, DefDamage, DefFuel, location) { this.StarshipType = StarshipType.Cruiser; }
public Cruiser(string name, StarSystem location) : base(name, location, CruiserInitialHealth, CruiserInitiaShields, CruisereInitiaDamage, CruiserInitiaFuel) { }
public Dreadnought(string name, StarSystem location) : base(name, 200, 300, 150, 700, location) { }
public Cruiser(string name, StarSystem location) : base(name, 100, 100, 50, 300, location) { }
public Dreadnought(string name, int health, int shields, int damage, double fuel, StarSystem locationStarSystem) : base(name, 200, 300, 150, 700, locationStarSystem) { }
public Frigate(string name, StarSystem location) : base(name, DefaultHealth, DefaultShield, DefaultDamage, DefaultFuel, location) { }
public Frigate(string name, StarSystem location) : this(name, 0, 0, 0, 0, location) { this.Name = name; this.Location = location; }
public Dreadnought(string name, StarSystem location) : this(name, 0, 0, 0, 0, location) { this.Name = name; this.Location = location; }
public Cruiser(string name, StarSystem location) : base(name, CruiserHealth, CruiserShields, CruiserDamage, CruiserFuel, location) { }
public Frigate(string name, StarSystem location) : base(name, FrigateHealth, FrigateShields, FrigateDamage, FrigateFuel, location) { }
public Cruiser(string name, int health, int shields, int damage, double fuel, StarSystem location) : base(name, health, shields, damage, fuel, location) { this.Type = StarshipType.Cruiser; }
public Cruiser(string name, StarSystem location) : base(name, DefaultHealth, DefaultShields, DefaultDamage, DefaultFuel, location) { }