Esempio n. 1
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;
        }
Esempio n. 2
0
        public override void Enter(clsGroundAtom refGroundAtom)
        {
            typRoute route = RouteUtils.planStraightLineRoute(new DPoint(refGroundAtom.curr_X, refGroundAtom.curr_Y),
                                                              new DPoint(triggerAtom.curr_X, triggerAtom.curr_Y), "help_other");

            refGroundAtom.currentRoute = route;
            refGroundAtom.resetMovementData();
        }
Esempio n. 3
0
        public override void Enter(clsGroundAtom refGroundAtom)
        {
            typRoute route = RouteUtils.planStraightLineRoute(new DPoint(refGroundAtom.curr_X, refGroundAtom.curr_Y),
                                                              new DPoint(targetPosition.x, targetPosition.y), "go_away_from_building");

            refGroundAtom.currentRoute = route;
            refGroundAtom.resetMovementData();
            refGroundAtom.earthquakeEndedEventHandler += earthquakeEndedExitingEventHandler;
        }
Esempio n. 4
0
        public override void Enter(clsGroundAtom refGroundAtom)
        {
            // go towards trigger in a straight line
            typRoute route = RouteUtils.planStraightLineRoute(new DPoint(refGroundAtom.curr_X, refGroundAtom.curr_Y),
                                                              new DPoint(triggerAtom.curr_X, triggerAtom.curr_Y), "curiosity");

            refGroundAtom.currentRoute = route;
            refGroundAtom.resetMovementData();
        }
Esempio n. 5
0
        public async override void Enter(clsGroundAtom refGroundAtom)
        {
            refGroundAtom.currentSpeed = refActivityMovement.Speed;
            //  refGroundAtom.currentRoute = new typRoute(refActivityMovement.RouteActivity);

            // Yinon Douchan: Modified next line to plan route from route_x and route_y instead of curr_x and curr_y
            typRoute R = await refGroundAtom.m_GameObject.m_GameManager.refTerrain.CreateRoute(refGroundAtom.X_Route, refGroundAtom.Y_Route, refActivityMovement.ReferencePoint.x, refActivityMovement.ReferencePoint.y, refActivityMovement.RouteActivity.RouteGuid);

            // -----------------------------------------------------------------------------------
            refGroundAtom.currentRoute = R;


            // refGroundAtom.SetRoute(refActivityMovement.RouteActivity);
            base.Enter(refGroundAtom);
        }
Esempio n. 6
0
        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;
        }
Esempio n. 7
0
        public override void Enter(clsGroundAtom refGroundAtom)
        {
            refGroundAtom.currentSpeed = refActivityMovement.Speed;

            // YD: randomly choose a route to follow
            typRoute R = refGroundAtom.m_GameObject.travelRoutes[refGroundAtom.currentStartWaypoint, refGroundAtom.currentEndWaypoint];

            refGroundAtom.currentRoute           = R;
            refGroundAtom.currentRegularActivity = refActivityMovement;

            // YD: subscribe to event handlers
            refGroundAtom.earthquakeStartedEventHandler += earthquakeStartedDefaultEventHandler;
            refGroundAtom.earthquakeEndedEventHandler   += earthquakeEndedDefaultEventHandler;
            refGroundAtom.forcesHaveArrivedEventHandler += forcesHaveArrivedDefaultEventHandler;
            refGroundAtom.deathEventHandler             += deathDefaultEventHandler;
            refGroundAtom.incapacitationEventHandler    += incapacitationDefaultEventHandler;
        }
Esempio n. 8
0
        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);
        }
Esempio n. 9
0
        // 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));
        }
Esempio n. 10
0
        // 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);
        }
Esempio n. 11
0
        // 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);
        }
Esempio n. 12
0
        // 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;
        }
Esempio n. 13
0
        public static typRoute planRouteByShortestPath(DPoint source, DPoint dest, String routeName)
        {
            typRoute route = new typRoute();

            return route;
        }
Esempio n. 14
0
        public static typRoute planRouteByShortestPath(DPoint source, DPoint dest, String routeName)
        {
            typRoute route = new typRoute();

            return(route);
        }