Esempio n. 1
0
        public int fuelUsage; // %

        public Trip(Location o, Location d, WarpFactor warp)
        {
            speed     = GetSpeed(warp);
            distance  = GetDistance(o, d);
            duration  = (int)Math.Round(((double)distance / speed) * 365.0);
            fuelUsage = (int)Math.Round(((double)warp / 10.0) * distance);
        }
Esempio n. 2
0
        /// <summary>
        /// Save: Serialize this Waypoint to an <see cref="XmlElement"/>.
        /// </summary>
        /// <param name="xmldoc">The parent <see cref="XmlDocument"/>.</param>
        /// <returns>An <see cref="XmlElement"/> representation of the Waypoint.</returns>
        public XmlElement ToXml(XmlDocument xmldoc)
        {
            XmlElement xmlelWaypoint = xmldoc.CreateElement("Waypoint");

            Global.SaveData(xmldoc, xmlelWaypoint, "Destination", Destination);

            if (Position != null)
            {
                xmlelWaypoint.AppendChild(Position.ToXml(xmldoc, "Position"));
            }

            Global.SaveData(xmldoc, xmlelWaypoint, "WarpFactor", WarpFactor.ToString(System.Globalization.CultureInfo.InvariantCulture));
            xmlelWaypoint.AppendChild(Task.ToXml(xmldoc));

            return(xmlelWaypoint);
        }
Esempio n. 3
0
        public void FlyToPlanet(Location newLocation, WarpFactor warp)
        {
            Trip myTrip = new Trip(CurrentLocation, newLocation, warp);

            if (myTrip.fuelUsage > 100 || FuelLevel < myTrip.fuelUsage)
            {
                throw new InsuficientFuelException();
            }
            else if (LifeSpan - myTrip.duration < 0)
            {
                throw new AgeOutException();
            }

            CurrentLocation = newLocation;
            LifeSpan       -= myTrip.duration;
            FuelLevel      -= myTrip.fuelUsage;
        }
Esempio n. 4
0
 public static int GetSpeed(WarpFactor warp)
 => (int)Math.Round(Math.Pow((double)warp, 10 / 3.0));                      // only good for warp <=9
Esempio n. 5
0
 public void FlyToPlanet(Planet destination, WarpFactor warp) => FlyToPlanet(destination.MyLocation, warp);