public static typRoute planStraightLineRoute(DPoint source, DPoint dest, String routeName) { typRoute route = new typRoute(); route.RouteName = routeName; route.arr_legs = new List<typLegSector>(); typLegSector legSector = new typLegSector(); legSector.FromLongn = source.x; legSector.FromLatn = source.y; legSector.ToLongn = dest.x; legSector.ToLatn = dest.y; legSector.LegDistance = (float)TerrainService.MathEngine.CalcDistance(legSector.FromLongn, legSector.FromLatn, legSector.ToLongn, legSector.ToLatn) / 1000f; route.arr_legs.Add(legSector); return route; }
public static typRoute planStraightLineRoute(DPoint source, DPoint dest, String routeName) { typRoute route = new typRoute(); route.RouteName = routeName; route.arr_legs = new List <typLegSector>(); typLegSector legSector = new typLegSector(); legSector.FromLongn = source.x; legSector.FromLatn = source.y; legSector.ToLongn = dest.x; legSector.ToLatn = dest.y; legSector.LegDistance = (float)TerrainService.MathEngine.CalcDistance(legSector.FromLongn, legSector.FromLatn, legSector.ToLongn, legSector.ToLatn) / 1000f; route.arr_legs.Add(legSector); return(route); }
// convert from typRoute to Route public static Route typRouteToRoute(typRoute typRoute) { Route route = new Route(); List <DPoint> points = new List <DPoint>(); // add starting points of each leg sector foreach (typLegSector legSector in typRoute.arr_legs) { points.Add(new DPoint(legSector.FromLongn, legSector.FromLatn)); } // add destination point from last leg sector typLegSector lastLegSector = typRoute.arr_legs[typRoute.arr_legs.Count() - 1]; points.Add(new DPoint(lastLegSector.ToLongn, lastLegSector.ToLatn)); // create the route return(createRoute(points)); }
// create a typRoute from a list of points public static typRoute createTypRoute(List <DPoint> points, String routeName) { typRoute typRoute = new typRoute(); typRoute.RouteName = routeName; typRoute.arr_legs = new List <typLegSector>(); // construct leg sectors from points for (int i = 0; i < points.Count() - 1; i++) { typLegSector legSector = new typLegSector(); legSector.FromLongn = points.ElementAt(i).x; legSector.FromLatn = points.ElementAt(i).y; legSector.ToLongn = points.ElementAt(i + 1).x; legSector.ToLatn = points.ElementAt(i + 1).y; legSector.LegDistance = (float)TerrainService.MathEngine.CalcDistance(legSector.FromLongn, legSector.FromLatn, legSector.ToLongn, legSector.ToLatn) / 1000f; typRoute.arr_legs.Add(legSector); } return(typRoute); }
public async override void Enter(clsGroundAtom refGroundAtom) { refGroundAtom.currentRoute = await refGroundAtom.m_GameObject.m_GameManager.refTerrain.createRouteByShortestPathOnly(refActivityMovement.RouteActivity.Points.ElementAt(1).x, refActivityMovement.RouteActivity.Points.ElementAt(1).y, refActivityMovement.RouteActivity.Points.ElementAt(2).x, refActivityMovement.RouteActivity.Points.ElementAt(2).y); typLegSector casuatlyToGroundZero = new typLegSector(); casuatlyToGroundZero.FromLongn = refActivityMovement.RouteActivity.Points.ElementAt(0).x; casuatlyToGroundZero.FromLatn = refActivityMovement.RouteActivity.Points.ElementAt(0).y; casuatlyToGroundZero.ToLongn = refActivityMovement.RouteActivity.Points.ElementAt(1).x; casuatlyToGroundZero.ToLatn = refActivityMovement.RouteActivity.Points.ElementAt(1).y; casuatlyToGroundZero.LegDistance = (float)TerrainService.MathEngine.CalcDistance(refActivityMovement.RouteActivity.Points.ElementAt(0).x, refActivityMovement.RouteActivity.Points.ElementAt(0).y, refActivityMovement.RouteActivity.Points.ElementAt(1).x, refActivityMovement.RouteActivity.Points.ElementAt(1).y) / 1000f; refGroundAtom.currentRoute.arr_legs.Insert(0, casuatlyToGroundZero); //refGroundAtom.currentRoute = RoutePlanner.planStraightLineRoute(refActivityMovement.RouteActivity.Points.ElementAt(0), // refActivityMovement.RouteActivity.Points.ElementAt(2), // refActivityMovement.RouteActivity.RouteName); refGroundAtom.currentSpeed = refActivityMovement.Speed; }
// create a typRoute from a list of points public static typRoute createTypRoute(List<DPoint> points, String routeName) { typRoute typRoute = new typRoute(); typRoute.RouteName = routeName; typRoute.arr_legs = new List<typLegSector>(); // construct leg sectors from points for (int i = 0; i < points.Count() - 1; i++) { typLegSector legSector = new typLegSector(); legSector.FromLongn = points.ElementAt(i).x; legSector.FromLatn = points.ElementAt(i).y; legSector.ToLongn = points.ElementAt(i+1).x; legSector.ToLatn = points.ElementAt(i+1).y; legSector.LegDistance = (float)TerrainService.MathEngine.CalcDistance(legSector.FromLongn, legSector.FromLatn, legSector.ToLongn, legSector.ToLatn) / 1000f; typRoute.arr_legs.Add(legSector); } return typRoute; }
public async override void Enter(clsGroundAtom refGroundAtom) { refGroundAtom.currentRoute = await refGroundAtom.m_GameObject.m_GameManager.refTerrain.createRouteByShortestPathOnly(refActivityMovement.RouteActivity.Points.ElementAt(1).x, refActivityMovement.RouteActivity.Points.ElementAt(1).y, refActivityMovement.RouteActivity.Points.ElementAt(2).x, refActivityMovement.RouteActivity.Points.ElementAt(2).y); typLegSector casuatlyToGroundZero = new typLegSector(); casuatlyToGroundZero.FromLongn = refActivityMovement.RouteActivity.Points.ElementAt(0).x; casuatlyToGroundZero.FromLatn = refActivityMovement.RouteActivity.Points.ElementAt(0).y; casuatlyToGroundZero.ToLongn = refActivityMovement.RouteActivity.Points.ElementAt(1).x; casuatlyToGroundZero.ToLatn = refActivityMovement.RouteActivity.Points.ElementAt(1).y; casuatlyToGroundZero.LegDistance = (float)TerrainService.MathEngine.CalcDistance(refActivityMovement.RouteActivity.Points.ElementAt(0).x, refActivityMovement.RouteActivity.Points.ElementAt(0).y, refActivityMovement.RouteActivity.Points.ElementAt(1).x, refActivityMovement.RouteActivity.Points.ElementAt(1).y) / 1000f; refGroundAtom.currentRoute.arr_legs.Insert(0, casuatlyToGroundZero); //refGroundAtom.currentRoute = RoutePlanner.planStraightLineRoute(refActivityMovement.RouteActivity.Points.ElementAt(0), // refActivityMovement.RouteActivity.Points.ElementAt(2), // refActivityMovement.RouteActivity.RouteName); refGroundAtom.currentSpeed = refActivityMovement.Speed; }