Example #1
0
        public override void Enter(clsGroundAtom refGroundAtom)
        {
            if (routeFromPoint == null)
            {
                // only go to sidewalk
                DPoint source = new DPoint(refGroundAtom.curr_X, refGroundAtom.curr_Y);
                DPoint dest   = new DPoint(pointOnSidewalk.x, pointOnSidewalk.y);
                refGroundAtom.currentRoute = RouteUtils.planStraightLineRoute(source, dest, "GetOnSidewalk_" + refGroundAtom.MyName);
            }
            else
            {
                // go to sidewalk and then to a route from that sidewalk given at routeFromPoint
                List <DPoint> points = new List <DPoint>();
                points.Add(new DPoint(refGroundAtom.curr_X, refGroundAtom.curr_Y));
                points.Add(new DPoint(pointOnSidewalk.x, pointOnSidewalk.y));

                // add all points except first which is the point on the sidewalk
                for (int i = 0; i < routeFromPoint.Points.Count(); i++)
                {
                    points.Add(routeFromPoint.Points.ElementAt(i));;
                }

                refGroundAtom.currentRoute = RouteUtils.createTypRoute(points, "GetOnSidewalk_" + refGroundAtom.MyName);
            }
        }
Example #2
0
        public override void Enter(clsGroundAtom refGroundAtom)
        {
            // plan route to closest barrier
            Barrier closestBarrier = getClosestBarrier(refGroundAtom);
            //refGroundAtom.currentRoute = RouteUtils.planStraightLineRoute(new DPoint(refGroundAtom.curr_X, refGroundAtom.curr_Y),
            //    new DPoint(closestBarrier.x, closestBarrier.y), "GoToBarrier");
            //refGroundAtom.currentRoute = await refGroundAtom.m_GameObject.m_GameManager.refTerrain.createRouteByShortestPathOnly(refGroundAtom.curr_X, refGroundAtom.curr_Y,
            //                             closestBarrier.x, closestBarrier.y);
            PointData closestRouteToBarrier = refGroundAtom.m_GameObject.lookForClosestRouteToBarrier(refGroundAtom, closestBarrier);
            typRoute  closestRoute          = closestRouteToBarrier.route;
            int       routeLength           = closestRoute.arr_legs.Count();

            refGroundAtom.resetMovementData();
            List <DPoint> routePoints = new List <DPoint>();

            routePoints.Add(new DPoint(refGroundAtom.curr_X, refGroundAtom.curr_Y));
            for (int i = closestRouteToBarrier.legNum; i < closestRoute.arr_legs.Count(); i++)
            {
                routePoints.Add(new DPoint(closestRoute.arr_legs[i].FromLongn, closestRoute.arr_legs[i].FromLatn));
            }

            // add last point
            routePoints.Add(new DPoint(closestRoute.arr_legs[routeLength - 1].ToLongn, closestRoute.arr_legs[routeLength - 1].ToLatn));
            typRoute routeFromAtom = RouteUtils.createTypRoute(routePoints, "GoToBarrier");

            refGroundAtom.currentRoute = routeFromAtom;
        }