public IHttpActionResult Postwaypoint(waypoint waypoint) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } db.waypoints.Add(waypoint); db.SaveChanges(); return(CreatedAtRoute("DefaultApi", new { id = waypoint.waypoint_id }, waypoint)); }
void assingNodeOpen() { for (int i = 0; i < nodes.Length; i++) { waypoint w = nodes[i].GetComponent <waypoint>(); if (w != null) { nodes[i].gameObject.GetComponent <waypoint>().previousWaypont = (i == 0)? null : nodes[i - 1].GetComponent <waypoint>(); nodes[i].gameObject.GetComponent <waypoint>().nextWaypoint = (i == nodes.Length - 1)? null: nodes[i + 1].GetComponent <waypoint>(); } } }
public void ProcessPayload(string payload) { //string theData = "{\"Items\":" + payload + "}"; print(payload); if (theCall == "all") { processList(payload); return; } payload = payload.Replace("items", "Items"); string theData = payload; waypoint[] datalist = JsonHelper.FromJson <waypoint>(theData); List <waypoint> waypoints = new List <waypoint>(); foreach (waypoint w in datalist) { waypoint wa = new waypoint(); wa.xf = float.Parse(w.x); wa.yf = float.Parse(w.y); wa.zf = float.Parse(w.z); waypoints.Add(wa); } //print (theData); // List<waypoint> waypoints = new List<waypoint>(); /* waypoint wa = new waypoint (); * wa.xf = 0f; * wa.yf = -1.1f; * wa.zf = 0f; * waypoints.Add(wa); * * wa = new waypoint (); * wa.xf = 0f; * wa.yf = -1.1f; * wa.zf = 2.0f; * waypoints.Add(wa); * * * wa = new waypoint (); * wa.xf = 5f; * wa.yf = -1.1f; * wa.zf = 2.0f; * waypoints.Add(wa); */ GameObject.Find("Holder").GetComponent <LocationController> ().processLocations(waypoints); }
// Use this for initialization void Start() { if (startWaypoint != null) { nextWaypoint = startWaypoint; } else { initialize(); } WrongSideOfTheRoad = false; full_stop = false; }
// GET: waypointsM/Delete/5 public ActionResult Delete(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } waypoint waypoint = db.waypoints.Find(id); if (waypoint == null) { return(HttpNotFound()); } return(View(waypoint)); }
public IHttpActionResult Deletewaypoint(int id) { waypoint waypoint = db.waypoints.Find(id); if (waypoint == null) { return(NotFound()); } db.waypoints.Remove(waypoint); db.SaveChanges(); return(Ok(waypoint)); }
public waypoint getPreviousWaypoint() { waypoint previousOne = null; if (transform.parent.GetComponent <waypointStreetManager> () != null) { previousOne = transform.parent.GetComponent <waypointStreetManager> ().getPreviousWaypoint(this); } else if (transform.parent.GetComponent <lane> () != null) // These version is { previousOne = transform.parent.GetComponent <lane> ().getPreviousWaypoint(this); } return(previousOne); }
void removeWaypoint() { waypoint selectedWaypoint = Selection.activeGameObject.GetComponent <waypoint>(); if (selectedWaypoint.nextWaypoint != null) { selectedWaypoint.nextWaypoint.previousWaypont = selectedWaypoint.previousWaypont; } if (selectedWaypoint.previousWaypont != null) { selectedWaypoint.previousWaypont.nextWaypoint = selectedWaypoint.nextWaypoint; Selection.activeGameObject = selectedWaypoint.previousWaypont.gameObject; } DestroyImmediate(selectedWaypoint.gameObject); }
public IHttpActionResult Getwaypoint(int id) { waypoint waypoint = db.waypoints.Find(id); var s = db.waypoints.Where(x => x.van_id == id); if (waypoint == null) { return(NotFound()); } // return Ok(waypoint); return(Json(s)); }
public waypoint getNextWaypoint() { waypoint nextOne = null; if (transform.parent.GetComponent <waypointStreetManager> () != null) { nextOne = transform.parent.GetComponent <waypointStreetManager> ().getNextWaypoint(this); } else if (transform.parent.GetComponent <lane> () != null) { nextOne = transform.parent.GetComponent <lane> ().getNextWaypoint(this); } return(nextOne); }
public waypoint getNextLane(waypoint currentWaypoint) { if (NextDirectionA != null && NextDirectionB != null) { waypoint returnCandidateA = NextDirectionA.getClosestWaypoint(currentWaypoint.position); waypoint returnCandidateB = NextDirectionB.getClosestWaypoint(currentWaypoint.position); float optionA = (returnCandidateA.position - currentWaypoint.position).magnitude; float optionB = (returnCandidateB.position - currentWaypoint.position).magnitude; if (optionA < optionB) { return(returnCandidateA); } else if (optionA > optionB) { return(returnCandidateB); } else { Debug.Log("Again we have an equal distance between two candidate next points. This should not be happening. /n Please check your road network and the waypoints"); return(null); } } else if (NextDirectionA != null && NextDirectionB == null) { waypoint returnCandidate = NextDirectionA.getClosestWaypoint(currentWaypoint.position); if ((returnCandidate.position - currentWaypoint.position).magnitude > 20f) // If the distance is bigger then 20 meters we assume that there is a mistake { Debug.Log("The closest option for a way point was more then 20 Meters away. We return NULL to stop the car!"); returnCandidate = null; } return(returnCandidate); } else if (NextDirectionA == null && NextDirectionB != null) { waypoint returnCandidate = NextDirectionB.getClosestWaypoint(currentWaypoint.position); if ((returnCandidate.position - currentWaypoint.position).magnitude > 20f) { Debug.Log("The closest option for a way point was more then 20 Meters away. We return NULL to stop the car!"); returnCandidate = null; } return(returnCandidate); } else { return(null); } }
void start_enemy(waypoint way) { if (index < path.Count) { Transform ways = path[index]; transform.position = Vector2.MoveTowards(transform.position, ways.position, way.get_speed() * Time.deltaTime); if (transform.position == ways.position) { index++; } } if (transform.position == path[path.Count - 1].position) { Destroy(this.gameObject); } }
bool moveToNextWaypoint() { previousWaypoint = nextWaypoint; nextWaypoint = previousWaypoint.getNextWaypoint(); if (nextWaypoint == null) { return(false); } else { // Debug.Log("Getting new speed info"); transform.GetComponent <AIInput>().desiredSpeed = nextWaypoint.getWaypointSpeed(); // Debug.Log("Getting new speed info" + nextWaypoint.getWaypointSpeed()); return(true); } }
public static double calculateTravelingTimeToNextWaypoint(waypoint currentWp, waypoint nextWp, float speed) { double metpersec = 0.27777777777778; double power = 2.0; double cartX = Convert.ToDouble(nextWp.pose.pose.position.x - currentWp.pose.pose.position.x); double cartY = Convert.ToDouble(nextWp.pose.pose.position.y - currentWp.pose.pose.position.y); double cartZ = Convert.ToDouble(nextWp.pose.pose.position.z - currentWp.pose.pose.position.z); double xyzRes = Math.Pow(cartX, power) + Math.Pow(cartY, power) + Math.Pow(cartZ, power); double distanceInMeters = Math.Sqrt(xyzRes); double timeInSeconds = distanceInMeters / (metpersec * speed); double millieSeconds = timeInSeconds * 1000; return(millieSeconds); }
public waypoint getclosestPointOnLane(int laneNum, int laneDirection, Vector3 currentWaypoint) { waypoint returnWaypoint = null; bool success = false; foreach (lane ln in lanes) { if (ln.laneNumber == laneNum && ln.myDirection == laneDirection) { returnWaypoint = ln.getClosestWaypoint(currentWaypoint); success = true; break; } } return(returnWaypoint); }
public void Update() { if (currentWaypoint != null) { Vector3 dir = currentWaypoint.transform.position - transform.position; dir.Normalize(); transform.position = Vector3.MoveTowards(transform.position, currentWaypoint.transform.position, speed * Time.deltaTime); if (currentWaypoint.transform.position == transform.position) { currentWaypoint = nextWaypoint; } } else { currentWaypoint = nextWaypoint; } }
public void goGhost() { //move onthe wrong side of the road forward... //Debug.Log("Befor: "+ nextWaypoint.position.ToString()); WrongSideOfTheRoad = !WrongSideOfTheRoad; waypoint temp = nextWaypoint; nextWaypoint = nextWaypoint.transform.parent.GetComponent <waypointStreetManager>().ReturnMirrorWaypoint(nextWaypoint, WrongSideOfTheRoad); //Debug.Log("After: "+ nextWaypoint.position.ToString()); moveToNextWaypoint(); transform.GetComponent <AIInput>().Move(nextWaypoint.position); previousWaypoint = temp; //A trigger to retrieve the mirrored image //set the direction to revers //B get the next way point }
public static int calculateTimeTravelingBetweenWaypoints(lane laneIn, waypoint currenWaypoint) { double timeToTravel = 0; for (int i = 0; i < laneIn.waypoints.Length - 1; i++) { if (i == 0) { timeToTravel = timeToTravel + calculateTravelingTimeToNextWaypoint(currenWaypoint, laneIn.waypoints[i], laneIn.waypoints[i].twist.twist.linear.x); } else { timeToTravel = timeToTravel + calculateTravelingTimeToNextWaypoint(laneIn.waypoints[i], laneIn.waypoints[i + 1], laneIn.waypoints[i].twist.twist.linear.x); } } return((int)timeToTravel); }
public void init(int _tile_id, COLOR _color, ROW _row, COL _col) { color = _color; row = _row; col = _col; tile_id = _tile_id; //GENERATE WAYPOINTS ID wp_tl = new waypoint(tile_id * 5 + 0, this); wp_tr = new waypoint(tile_id * 5 + 1, this); wp_bl = new waypoint(tile_id * 5 + 2, this); wp_br = new waypoint(tile_id * 5 + 3, this); wp_center = new waypoint(tile_id * 5 + 3, this); //CALC POSTIONS FOR EACH WP wp_center.pos_x = this.gameObject.transform.position.x; wp_center.pos_y = this.gameObject.transform.position.z; }
public waypoint ReturnMirrorWaypoint(waypoint originalWaypoint, bool ghostDriver) { if (DirectionA.Contains(originalWaypoint)) { float distance = (DirectionB[0].position - originalWaypoint.position).magnitude; int counter = 0; int i = 0; foreach (waypoint wp in DirectionB) { float NewDistance = (wp.position - originalWaypoint.position).magnitude; if (distance > NewDistance) { distance = NewDistance; counter = i; } i++; } return(DirectionB[counter]); } else if (DirectionB.Contains(originalWaypoint)) { float distance = (DirectionA[0].position - originalWaypoint.position).magnitude; int counter = 0; int i = 0; foreach (waypoint wp in DirectionA) { float NewDistance = (wp.position - originalWaypoint.position).magnitude; if (distance > NewDistance) { distance = NewDistance; counter = i; } i++; } return(DirectionA[counter]); } else { Debug.Log("This should not be happening! The waypoint does not belong to this street"); return(null); } Debug.Log("This should not happen. something is wrong with the foreach loop"); //I know this is very dirty!// fixing it that it compiles return(null); }
public void deploybase(GameObject select) { if (stage.getphase() == 1 && stage.getbase() > 0) { GameObject agrid = GameObject.Find("grid"); Grid map = agrid.GetComponent <Grid>(); GameObject[] allwaypoints = GameObject.FindGameObjectsWithTag("waypoint"); waypoint[] waypoints = new waypoint[allwaypoints.Length]; for (int i = 0; i < waypoints.Length; i++) { waypoints[i] = allwaypoints[i].GetComponent <waypoint>(); waypoints[i].allbranch.Clear(); } foreach (var item in map.map) { if (item.havebase == true) { item.Placer.SetActive(false); } foreach (var item2 in waypoints) { if (item2.start == item.position || item2.final == item.position) { item.Placer.SetActive(false); } } } foreach (var item in map.map) { foreach (var item2 in waypoints) { if (item2.groundpath) { if (item2.checker(item.Placer) <= 0) { item.Placer.SetActive(false); } } } } currenttower = select; allplacer.SetActive(true); } }
public void initialize() { // Debug.Log ("uninitialized street waypoint target. Automatic init attempted"); RaycastHit hit; //Debug.DrawRay (transform.position , -transform.up); if (Physics.Raycast(transform.position, -transform.up, out hit, 50)) { // Debug.DrawLine (transform.position, hit.point); if (hit.transform.GetComponent <waypointStreetManagerV2> () != null) { //Debug.Break (); Vector3 forward = new Vector3(transform.forward.x, 0, transform.forward.z).normalized; //lane lane=hit.transform.GetComponent<waypointStreetManagerV2> ().getForwardLane(forward); nextWaypoint = hit.transform.GetComponent <waypointStreetManagerV2> ().getClosestWaypoint(transform.position); moveToNextWaypoint(); // we need a direction and the clossesd point will not help us with that. if (!fullStop) { transform.GetComponent <AIInput> ().startTheCar(); // tell the car controller to start again } transform.GetComponent <AIInput> ().Move(nextWaypoint.position); // and then to move } else { Debug.Log("I am not standing on a waypoint Street ManagerV2. Automatic Init Failed. Where should I move?" + transform.name); } } else { transform.GetComponent <AIInput> ().stopTheCar(); Debug.Log("I am not standing on anything. Automatic Init Failed. Where should I move?"); //Debug.Log ("What we hit was called:" +hit.transform.name); } /// This function needs to A-calculate direction vectors for each lane(by looking at the first and last waypoint object in the list(maybe this should run in the waypoint class)) /// B-compare them to the vehicles forward direction or velocity /// C- Based on that pick a road side /// and D- retrieve the neareast way point /// E- update so that not th nearest way point is the next but the nexzt one in that direction }
// Update is called once per frame void Update() { if (Input.GetMouseButtonDown(0) || Input.GetKeyUp(KeyCode.PageDown)) { Advance(); } else if (Input.GetMouseButtonDown(1) || Input.GetKeyUp(KeyCode.PageUp)) { Return(); } if (position < waypoints.Count) { waypoint wp = waypoints[position]; float distance = Vector3.Distance(transform.position, wp.transform.position); //waypoint previous = getPrevious(); //previous.fadeOut(fadeSpeed / distance); if (distance > 0.5) { if (current != null) { current.fadeOut(fadeSpeed); } // Add fade transition here wp.fadeIn(fadeSpeed); transform.rotation = Quaternion.Lerp(transform.rotation, wp.transform.rotation, speed / distance * Time.deltaTime); Vector3 direction = (wp.transform.position - transform.position).normalized; Vector3 velocity = direction * speed * Time.deltaTime; transform.position += velocity; } else { transform.position = wp.transform.position; } current = wp; } }
void createWaypoint() { GameObject waypointObject = new GameObject("waypoint " + waypointRoot.childCount, typeof(waypoint)); waypointObject.transform.SetParent(waypointRoot, false); waypoint waypoint = waypointObject.GetComponent <waypoint>(); if (waypointRoot.childCount > 1) { waypoint.previousWaypont = waypointRoot.GetChild(waypointRoot.childCount - 2).GetComponent <waypoint>(); waypoint.previousWaypont.nextWaypoint = waypoint; waypoint.transform.position = waypoint.previousWaypont.transform.position; waypoint.transform.forward = waypoint.previousWaypont.transform.forward; } Selection.activeGameObject = waypoint.gameObject; }
public static void Main(string[] args) { try { { var waypoint = new waypoint(); waypoint.set_tag("test.transform.example.1.c#"); waypoints wp = new waypoints(); var synapse_subscriber = new data_processors.synapse_client <data_processors.waypoints>("10.16.10.127"); var synapse_publisher = new data_processors.synapse_client <data_processors.waypoints>("10.16.10.127"); ReaderWriterLockSlim rwl = new ReaderWriterLockSlim(); synapse_subscriber.subscribe(rwl, new type_factory(), //"test.betfair.contests.au", "test.sim.*.*", data_processors.synapse_client_utils.timestamp(new DateTime(2015, 1, 1)), 0, // until data_processors.synapse_client_utils.timespan(new TimeSpan(20, 0, 0)), // delayed delivery tolerance true); uint i = 0; for (var msg_wrapper = synapse_subscriber.next(7000); msg_wrapper != null; msg_wrapper = synapse_subscriber.next(5000)) { if (msg_wrapper.type_name == "ContestsType" && msg_wrapper.non_delta_seen == true) { var now = DateTime.UtcNow; waypoint.set_timestamp(data_processors.federated_serialisation.utils.EncodeDateTime(now)); wp.set_from((waypoints)msg_wrapper.waypoints); wp.add_path_element(waypoint); var written_bytes = synapse_publisher.publish(msg_wrapper.amqp.routing_key + ".transformation_test_c_sharp", (ContestsType)((thrift_contests_type)msg_wrapper.msg).output_msg, wp, (i++ % 100 == 0 ? false : true), null, 0, synapse_client_utils.timestamp(now)); Console.WriteLine("republished message of " + written_bytes + " bytes"); } } synapse_subscriber.close(); synapse_publisher.close(); Console.WriteLine("bye bye"); } } catch (Exception e) { Console.WriteLine("oops " + e.Message); } }
/*(random generation)waypoint functions*/ private waypoint createWaypoint(int positionX, int positionY, mapGfx mapGfx, waypoint connectWith, int identification) { GameObject newWaypoint = new GameObject("waypoint " + identification); waypoint waypoint = newWaypoint.AddComponent <waypoint>(); BoxCollider2D boxCollider2D = newWaypoint.AddComponent <BoxCollider2D>(); boxCollider2D.size = new Vector2(0.32f, 0.32f); newWaypoint.transform.position = new Vector3(positionX, positionY); mapGfx.addGameObject(newWaypoint, "waypoint"); if (connectWith != null) { connectWith.nextwaypoint = waypoint; } return(waypoint); }
bool moveToNextWaypoint() { previousWaypoint = nextWaypoint; if (WrongSideOfTheRoad) { nextWaypoint = previousWaypoint.getPreviousWaypoint(); } else { nextWaypoint = previousWaypoint.getNextWaypoint(); } if (nextWaypoint == null) { return(false); } else { return(true); } }
public waypoint getFirstRelevant(waypoint lastWaypoint) /// this has to be changed so we look at the closest point not the one ina specific road... // This is because we do not know the rotation of a certain piece of road ... moving from A to B to A just because its rotated needs to be possible... // This is easier fixed in code and not in design ... we only have to points possible any whay ... this is whay end points are a good idea! { float DistanceToA = (DirectionA[0].position - lastWaypoint.position).magnitude; float DistanceToB = (DirectionB[0].position - lastWaypoint.position).magnitude; if (DistanceToA < DistanceToB) { return(DirectionA[0]); } else if (DistanceToA > DistanceToB) { return(DirectionB[0]); } else { Debug.Log("You need to check your sceneary the is an ambigues road connection"); return(DirectionA[0]); } }
public IEnumerator movetofrontline() { for (int i = 0; i < allenemy.Count; i++) { if (allenemy[i].GetComponent <enemy>().readytodeploy == false) { waypoint myenemywaypoint = allenemy[i].GetComponent <enemy>().mywaypoint; float x, z; System.Random rnd = new System.Random(); x = rnd.Next(myenemywaypoint.MinvanguardX, myenemywaypoint.MaxvanguardX); z = rnd.Next(myenemywaypoint.MinvanguardY, myenemywaypoint.MaxvanguardY); Vector3 vanguardpoint = allenemy[i].GetComponent <enemy>().mywaypoint.vanguardpoint.position; allenemy[i].transform.position = vanguardpoint + new Vector3(x, 0, z); allenemy[i].transform.position = new Vector3(allenemy[i].transform.position.x, allenemy[i].GetComponent <enemy>().Y, allenemy[i].transform.position.z); allenemy[i].GetComponent <enemy>().readytodeploy = true; allenemy[i].transform.SetParent(null); allenemy[i].GetComponent <BoxCollider>().enabled = true; yield return(new WaitForSeconds(2.0f)); } } deploycomplete = true; }
public void initiate(int mapSize, int pathLengthReduktion) { _maxPathLength = ((mapSize / 2) * (mapSize - 2)) + (mapSize / 2 - 1); _minPathLength = _maxPathLength / 2; _targetPathLength = _maxPathLength - pathLengthReduktion; _pathLengthReduktion = pathLengthReduktion; _actualPathLength = 0; _spawnX = 0; _spawnY = 0; _baseX = Random.Range(1, mapSize - 1); _baseY = Random.Range(1, mapSize - 1); if (_pathList == null) { _pathList = new List <Path>(); } _pathList.Clear(); _startWaypoint = null; }