예제 #1
0
        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;
        }
예제 #2
0
 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;
 }
예제 #3
0
 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;
 }
예제 #4
0
 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;
 }
예제 #5
0
 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;
 }
예제 #6
0
 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;
 }
예제 #7
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>();
 }
예제 #8
0
 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>();
 }
예제 #9
0
 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;
 }
예제 #10
0
 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.");
     }
 }
예제 #11
0
 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.");
     }
 }
예제 #12
0
        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;
        }
예제 #13
0
        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);
        }
예제 #15
0
 public Dreadnought(string name, int health, int shield, int damage, double fuel, StarSystem location)
     : base(name, health, shield, damage, fuel, location)
 {
 }
예제 #16
0
 public Cruiser(string name, StarSystem location)
     : base(name, DefaultCruiserHealth, DefaultCruiserShield, DefaultCruiserDamage,
           DefaultCruisereFuel, location)
 {
 }
예제 #17
0
 public Dreadnought(string name, StarSystem locatiin)
     : base(name, DreadnoughtHealth, DreadnoughtShields, DreadnoughtDamage, DreadnoughtFuel, locatiin)
 {
 }
예제 #18
0
 public Frigate(string name, StarSystem location)
     : base(name, location, health: 60, shileds: 50, damage: 30, fuel: 220)
 {
     this.ProjectilesFired = 0;
     this.Type = StarshipType.Frigate;
 }
예제 #19
0
 public Dreadnought(string name, StarSystem location)
     : base(name, DefHealth, DefShields, DefDamage, DefFuel, location)
 {
     this.StarshipType = StarshipType.Cruiser;
 }
예제 #20
0
 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)
 {
 }
예제 #24
0
 public Frigate(string name, StarSystem location)
     : base(name, DefaultHealth, DefaultShield, DefaultDamage, DefaultFuel, location)
 {
 }
예제 #25
0
 public Frigate(string name, StarSystem location)
     : this(name, 0, 0, 0, 0, location)
 {
     this.Name = name;
     this.Location = location;
 }
예제 #26
0
 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)
 {
 }
예제 #29
0
 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;
 }
예제 #30
0
 public Cruiser(string name, StarSystem location)
     : base(name, DefaultHealth, DefaultShields, DefaultDamage, DefaultFuel, location)
 {
 }