Example #1
0
 public void SetPlayerOnMap(BattleEngine.Player.Player p, Location l)
 {
     this.check_location_bounds (l);
     this.player_locations.Add (p, l);
 }
Example #2
0
 public double DistanceTo(Location point)
 {
     return Math.Sqrt (Math.Pow((this.X - point.X), 2.0) + Math.Pow ((this.Y - point.Y), 2.0));
 }
Example #3
0
 private void check_location_bounds(Location l)
 {
     if (l.X > this.Length)
         throw new ArgumentOutOfRangeException ("Max X is " + this.Length.ToString ());
     if (l.X < 0)
         throw new ArgumentOutOfRangeException ("X can not be less than 0");
     if (l.Y > this.Width)
         throw new ArgumentOutOfRangeException ("Max Y is " + this.Width.ToString ());
     if (l.Y < 0)
         throw new ArgumentOutOfRangeException ("Y can not be less than 0");
 }
Example #4
0
 private void place_players_on_map()
 {
     this.GameMap.ClearPlayers ();
     this.Console.ConsoleWriteLine ("Placing players on map...");
     foreach (BattleEngine.Player.Player p in this.players.Values)
     {
         Location l = new Location (this.RandomEngine.Next (1, this.GameMap.Length+1),
                                    this.RandomEngine.Next (1, this.GameMap.Width+1),
                                    0);
         this.GameMap.SetPlayerOnMap (p, l);
         this.Console.ConsoleWriteLine (string.Format("\"{0}\" is located at {1}", p.Name, l.ToString ()));
     }
 }