public LongRangeTower(MapLocation location) : base(location) { }
public Tower(MapLocation location) { _location = location; }
public PowerTower(MapLocation location) : base(location) { }
public Tower(MapLocation location) { //if (path.IsOnPath(_location)) _location = location; }
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(); }
public SniperTower(MapLocation location) : base(location) { }
public bool InRangeOf(MapLocation location, int range) { return(DistanceTo(location) <= range); }
public SharpShooterTower(MapLocation location) : base(location) { }
public bool IsOnPath(MapLocation location) => _path.Contains(location);
// 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; }
public bool InRangeOf(MapLocation location, int range) => DistanceTo(location) <= range;
public bool IsOnPath(MapLocation mapLocation) => _pathLocations.Contains(mapLocation);
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 }