Esempio n. 1
0
        private void FindPath()
        {
            distanceToTarget = 0;
            dots.Clear();

            PathFinder finder = new PathFinder(
                this.vessel.latitude,
                this.vessel.longitude,
                targetLatitude,
                targetLongitude,
                this.vessel.mainBody
                );

            finder.FindPath();
            distanceToTarget = finder.GetDistance();
            if (distanceToTarget > 0)
            {
                pathEncoded = finder.EncodePath();
                dots        = finder.GetDots();
            }
            else
            {
                ScreenMessages.PostScreenMessage("No path found, bye!");
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Find a route to the target using only specified tile types (route on land, water or both)
        /// </summary>
        /// <param name="lat"></param>
        /// <param name="lon"></param>
        /// <param name="tileType"></param>
        /// <returns></returns>
        protected bool FindRoute(double targetLat, double targetLon, TileTypes tileType)
        {
            bool result = false;

            PathFinder pathFinder = new PathFinder(vessel.latitude, vessel.longitude, targetLat, targetLon, vessel.mainBody, tileType);

            pathFinder.FindPath();

            double dist = pathFinder.GetDistance();

            if (dist > 0) // Path found
            {
                targetLatitude    = targetLat;
                targetLongitude   = targetLon;
                distanceToTarget  = dist;
                distanceTravelled = 0;
                path   = PathUtils.HexToWaypoint(pathFinder.path);
                result = true;
            }
            else // Path not found
            {
                result = false;
            }

            return(result);
        }
Esempio n. 3
0
//		[KSPEvent(guiActive = true, guiName = "Toggle utilities")]
//		public void ToggleUtils()
//		{
//			showUtils = !showUtils;
//			Events["CalculateSolar"].active = showUtils;
//			Events["CalculateOther"].active = showUtils;
////			Events["CalculateAverageSpeed"].active = showUtils;
//			Events["CalculatePowerRequirement"].active = showUtils;
//
//			//Clean up previous builds
//			Events["CalculateSolar"].guiActive = true;
//			Events["CalculateOther"].guiActive = true;
//			if (Events["FindPath"] != null)
//			{
//				Events["FindPath"].guiActive = false;
//				Events["FindPath"].active = false;
//			}
//			if (Events["PickTest"] != null)
//			{
//				Events["PickTest"].guiActive = false;
//				Events["PickTest"].active = false;
//			}
//		}

        private void FindPath()
        {
            distanceToTarget = 0;

            PathFinder finder = new PathFinder(
                this.vessel.latitude,
                this.vessel.longitude,
                targetLatitude,
                targetLongitude,
                this.vessel.mainBody
                );

            finder.FindPath();
            distanceToTarget = finder.GetDistance();
            if (distanceToTarget > 0)
            {
                pathEncoded = PathUtils.EncodePath(finder.path);
                BonVoyage.Instance.UpdateWayPoints();
//				wayPoints = PathUtils.DecodePath (pathEncoded, this.vessel.mainBody);
            }
            else
            {
                ScreenMessages.PostScreenMessage("No path found, try some other location!");
            }
        }