コード例 #1
0
ファイル: VehicleWP.cs プロジェクト: UROBBYU/Industry
        /*
         * private void FindWayToRoute()
         * {
         *  if (temp != null)
         *      RouteSetWP.RemoveRoute(temp);
         *
         *  Road from = ExtractRoadFrom(WorldMap.GetTile(Position));
         *  WayPoint fromWP = from.WPContainer.GetClosestWP(Position);
         *
         *  if (Vector3.Dot(Position + transform.right, transform.InverseTransformPoint(fromWP.Position)) < 0)
         *      fromWP = from.WPContainer.GetClosestWPExcept(Position, fromWP);
         *
         *  temp = new RouteWP(RouteCreator.CreatePathToRouteWP(prev, route, route_forward), true);
         *
         *  if (temp == null) { Abort("Path does not exist"); return; }
         *
         *  if (!route.Contains(temp[temp.Count - 1]))
         *  {
         *      Debug.Log("<color=red>WTF temp route does not lead to main route</color>\nTrying to recalculate...");
         *
         *      temp = new RouteWP(RouteCreator.CreatePathToRouteWP(fromWP, route, route_forward), true);
         *
         *      if (!route.Contains(temp[temp.Count - 1]))
         *          Debug.Log("<color=red>RECALCULATION FAILED</color>");
         *  }
         *
         *  RouteSetWP.AddRoute(temp, false);
         *
         *  on_main_route = false;
         *  current_WP = 0;
         *
         *  if (sphereCurr == null)
         *      throw new System.NullReferenceException("sphereCurr");
         *
         *  sphereCurr.SetPosition(fromWP.Position);
         *
         *  temp.HighLight(true, Color.red);
         * }
         */

        private void FindWayToRoute()
        {
            List <WayPoint> newTemp = RouteCreator.CreatePathWP(current, route_forward ? route.endWP : route.startWP, false);

            if (newTemp == null)
            {
                Abort("Path does not exist"); return;
            }

            if (temp != null)
            {
                RouteSet.RemoveRoute(temp);
            }

            temp = new Route(newTemp, true);
            RouteSet.AddRoute(temp, false);

            on_main_route = false;
            current_WP    = 0;

            sphereCurr.SetPosition(current.Position);


            Road curr = ExtractRoadFrom(WorldMap.GetTile(Position));

            tempRoad = GetBack.GetWayToClosest(curr, mainRoad);

            for (int i = 0; i < tempRoad.Count; i++)
            {
                tempRoad[i].SetColor(RoadColor.Red);
            }

            //enabled = false;
        }
コード例 #2
0
ファイル: RoutingManager.cs プロジェクト: UROBBYU/Industry
        private static void ShowPath()
        {
            var roads = RouteCreator.CreatePathWP(from, to);

            if (roads != null)
            {
                last_route = new Route(roads);
                last_route.HighLight(true);
            }
        }