Beispiel #1
0
 public LongRangeTower(MapLocation location) : base(location)
 {
 }
 public Tower(MapLocation location)
 {
     _location = location;
 }
Beispiel #3
0
 public PowerTower(MapLocation location) : base(location)
 {
 }
Beispiel #4
0
 public Tower(MapLocation location)
 {
     //if (path.IsOnPath(_location))
     _location = location;
 }
Beispiel #5
0
        public static void Main()
        {
            Map map = new Map(8, 5);

            try
            {
                Path path = new Path(
                    new [] {
                    new MapLocation(0, 2, map),
                    new MapLocation(1, 2, map),
                    new MapLocation(2, 2, map),
                    new MapLocation(3, 2, map),
                    new MapLocation(4, 2, map),
                    new MapLocation(5, 2, map),
                    new MapLocation(6, 2, map),
                    new MapLocation(7, 2, map)
                });

                MapLocation location = new MapLocation(0, 2, map);

                if (path.IsOnPath(location))
                {
                    Console.WriteLine(location + " is on the path");
                    return;
                }

                Invader[] invaders =
                {
                    new SheildedInvader(path),
                    new FastInvader(path),
                    new StrongInvader(path),
                    new BasicInvader(path)
                };

                Tower[] towers =
                {
                    new Tower(new MapLocation(1, 3, map)),
                    new Tower(new MapLocation(3, 3, map)),
                    new Tower(new MapLocation(5, 3, map))
                };

                Level level = new Level(invaders)
                {
                    Towers = towers
                };

                bool playerWon = level.Play();

                Console.WriteLine("Player " + (playerWon ? "won" : "lost"));
            }
            catch (OutOfBoundsException ex)
            {
                Console.WriteLine(ex.Message);
            }
            catch (TreehouseDefenseException)
            {
                Console.WriteLine("Unhandled TreehouseDefenseException");
            }
            catch (Exception ex)
            {
                Console.WriteLine("Unhandled Exception: " + ex);
            }

            Console.ReadLine();
        }
Beispiel #6
0
 public SniperTower(MapLocation location) : base(location)
 {
 }
 public bool InRangeOf(MapLocation location, int range)
 {
     return(DistanceTo(location) <= range);
 }
Beispiel #8
0
 public SharpShooterTower(MapLocation location) : base(location)
 {
 }
Beispiel #9
0
 public bool IsOnPath(MapLocation location) => _path.Contains(location);
Beispiel #10
0
 // Builds constructor.
 // Takes one parameter,
 // an object from the class MapLocation.
 // Constructor is called as soon as an
 // object from the class is declared.
 public Tower(MapLocation location)
 {
     // Stores input in the variable _location.
     _location = location;
 }
Beispiel #11
0
 public bool InRangeOf(MapLocation location, int range) => DistanceTo(location) <= range;
Beispiel #12
0
 public bool IsOnPath(MapLocation mapLocation) => _pathLocations.Contains(mapLocation);
Beispiel #13
0
 public Tower(MapLocation location)
 {
     _location = location;
     // maybe add some validation here to make sure that towers can't be placed on paths.
     //there's an example in the map location class
 }