Exemple #1
0
        /// <summary>
        /// Calculates the air distance from other MapObjectEx
        /// </summary>
        /// <param name="other">Other MapObjectEx instance</param>
        /// <returns>The air distance</returns>
        public double AirDistance(MapObjectEx other)
        {
            int dx = MapObject.GetLocation().Col - other.MapObject.GetLocation().Col;
            int dy = MapObject.GetLocation().Row - other.MapObject.GetLocation().Row;

            // Simple pythtagoras
            return(Math.Sqrt(dx * dx + dy * dy));
        }
Exemple #2
0
 /// <summary>
 /// Creates a new AircraftEx instance, initialize with wrapped Aircraft instance
 /// </summary>
 /// <param name="aircraft">The wrapped Aircraft</param>
 public AircraftEx(Aircraft aircraft)
     : base(aircraft)
 {
     Aircraft         = aircraft;
     CanMove          = true;
     FinalDestination = null;
     IsThreatened     = GetThreateningPirates().Count() > 0;
 }
Exemple #3
0
        /// <summary>
        /// Makes a step towards a destination.
        /// Updates CanMove to false if movement occures
        /// </summary>
        /// <param name="destination">The final destination</param>
        /// <returns>true if movement succeeds, else false</returns>
        public bool HeadTo(MapObjectEx destination)
        {
            // If the pirate cannot move, return false
            if (!CanMove)
            {
                return(false);
            }

            // Cannot move to null destination
            if (destination == null)
            {
                return(false);
            }

            // Cannot move to the current location
            if (Aircraft.Location == destination.MapObject.GetLocation())
            {
                return(false);
            }

            // Get sail options
            List <Location> options = GameManager.CurrentTurn.Game.GetSailOptions(Aircraft, destination.MapObject);

            // If there are no sail options, return false
            if (options == null || options.Count == 0)
            {
                return(false);
            }

            // Currently pick the first option
            Location nextDestination = options[0];

            GameManager.CurrentTurn.Game.SetSail(Aircraft, nextDestination);
            CanMove = false;

            return(true);
        }
Exemple #4
0
 /// <summary>
 /// Checks if a map object is within the attack range of the pirate
 /// </summary>
 /// <param name="target">The attack target</param>
 /// <returns>true if the target is within the range, else false</returns>
 public bool InAttackRange(MapObjectEx target)
 {
     return(Pirate.InAttackRange(target.MapObject));
 }
Exemple #5
0
 /// <summary>
 /// Returns the distance in tiles from other MapObjectEx
 /// </summary>
 /// <param name="other">Other MapObjectEx instance</param>
 /// <returns>The distance in tiles</returns>
 public int Distance(MapObjectEx other)
 {
     return(MapObject.Distance(other.MapObject));
 }