コード例 #1
0
 public LongRangeTower(MapLocation location) : base(location)
 {
 }
コード例 #2
0
 public Tower(MapLocation location)
 {
     _location = location;
 }
コード例 #3
0
ファイル: PowerTower.cs プロジェクト: joeziemba/TowerGame
 public PowerTower(MapLocation location) : base(location)
 {
 }
コード例 #4
0
 public Tower(MapLocation location)
 {
     //if (path.IsOnPath(_location))
     _location = location;
 }
コード例 #5
0
ファイル: Game.cs プロジェクト: menglish78/TreehouseDefense
        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();
        }
コード例 #6
0
 public SniperTower(MapLocation location) : base(location)
 {
 }
コード例 #7
0
 public bool InRangeOf(MapLocation location, int range)
 {
     return(DistanceTo(location) <= range);
 }
コード例 #8
0
 public SharpShooterTower(MapLocation location) : base(location)
 {
 }
コード例 #9
0
ファイル: Map.cs プロジェクト: cyadehn/Treehouse-CSharp
 public bool IsOnPath(MapLocation location) => _path.Contains(location);
コード例 #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;
 }
コード例 #11
0
 public bool InRangeOf(MapLocation location, int range) => DistanceTo(location) <= range;
コード例 #12
0
 public bool IsOnPath(MapLocation mapLocation) => _pathLocations.Contains(mapLocation);
コード例 #13
0
ファイル: Tower.cs プロジェクト: joelamajors/TreehouseCourses
 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
 }