private void goToRegularMovementAfterExitingStructure(clsGroundAtom refGroundAtom) { clsActivityMovement backToNormal = RouteUtils.createActivityAndStart(refGroundAtom, (int)refGroundAtom.currentSpeed, null); clsPolygonOpeningEscapePoint escapePoint = Structure.EscapePoints[exitEdgeNumber]; PointData closestPoint = refGroundAtom.m_GameObject.lookForClosestRegularRoute(refGroundAtom); Route route = RouteUtils.typRouteToRoute(closestPoint.route); List <DPoint> trimmedRoutePoints = new List <DPoint>(); for (int i = closestPoint.legNum; i < route.Points.Count(); i++) { trimmedRoutePoints.Add(route.Points.ElementAt(i)); } route.Points = trimmedRoutePoints; refGroundAtom.currentStartWaypoint = closestPoint.routeIndex1; refGroundAtom.currentEndWaypoint = closestPoint.routeIndex2; refGroundAtom.resetMovementData(); refGroundAtom.currentSpeed = refGroundAtom.baselineSpeed; refGroundAtom.ChangeState(new GET_ON_SIDEWALK(backToNormal, new DPoint(escapePoint.x, escapePoint.y), route)); }
// get back to regular activity private void getBackToRegularMovement(clsGroundAtom refGroundAtom) { clsActivityMovement backToNormal = RouteUtils.createActivityAndStart(refGroundAtom, (int)refGroundAtom.currentSpeed, null); PointData closestPoint = refGroundAtom.m_GameObject.lookForClosestRegularRoute(refGroundAtom); Route route = RouteUtils.typRouteToRoute(closestPoint.route); List <DPoint> trimmedRoute = new List <DPoint>(); for (int i = closestPoint.legNum; i < route.Points.Count(); i++) { trimmedRoute.Add(route.Points.ElementAt(i)); } route.Points = trimmedRoute; refGroundAtom.currentLeg = 1; refGroundAtom.currentStartWaypoint = closestPoint.routeIndex1; refGroundAtom.currentEndWaypoint = closestPoint.routeIndex2; refGroundAtom.resetMovementData(); double distanceFromLastRoutePoint = TerrainService.MathEngine.CalcDistance(refGroundAtom.lastRoutePoint.x, refGroundAtom.lastRoutePoint.y, refGroundAtom.curr_X, refGroundAtom.curr_Y); DPoint pointOnSidewalk; if ((refGroundAtom.lastRoutePoint.x == 0 && refGroundAtom.lastRoutePoint.y == 0) || (distanceFromLastRoutePoint > 5)) { // go to the closest sidewalk pointOnSidewalk = new DPoint(route.Points.ElementAt(0).x, route.Points.ElementAt(0).y); refGroundAtom.lastRoutePoint.x = pointOnSidewalk.x; refGroundAtom.lastRoutePoint.y = pointOnSidewalk.y; } else { // continue from where you were before the earthquake started pointOnSidewalk = refGroundAtom.lastRoutePoint; } refGroundAtom.ChangeState(new GET_ON_SIDEWALK(backToNormal, pointOnSidewalk, route)); }