public List <Landmark> translateLandmark() { int numLocations = GameController.Instance.originalLandmarks.Count; List <Landmark> results = new List <Landmark>(); //Results starts as originals foreach (Landmark l in GameController.Instance.originalLandmarks) { results.Add(l); } List <List <Landmark> > candidates = new List <List <Landmark> >(); float[] costs = new float[numLocations]; for (int i = 0; i < numLocations; i++) { costs[i] = float.MaxValue; } for (int i = 0; i < numLocations; i++) { //Assign 10 similar landmarks for each original candidates.Add(GoogleAPI.Instance.getSimilar(GameController.Instance.originalLandmarks[i])); //Algorithm C - Average Distance between original landmark and previous landmark double prevDistanceOriginal; if (i == 0) { prevDistanceOriginal = LatLong.EstimateGreatCircleDistance(OriginalLocations.Instance.getOriginalStart(), GameController.Instance.originalLandmarks[i].getPosition()); } else { prevDistanceOriginal = LatLong.EstimateGreatCircleDistance(GameController.Instance.originalLandmarks[i].getPosition(), GameController.Instance.originalLandmarks[i - 1].getPosition()); } //Algorithm A - Determine average distance between original landmark and all other original landmarks //double avDistanceOriginal = 0.0; //for (int j = 0; j < numLocations; j++) //{ // avDistanceOriginal += LatLong.EstimateGreatCircleDistance(GameController.Instance.originalLandmarks[i].getPosition(), GameController.Instance.originalLandmarks[j].getPosition()); //} //avDistanceOriginal /= numLocations; for (int j = 0; j < candidates[i].Count; j++) { //Algorithm B -Distance between candidate and starting position compared with distance between original landmark and original starting position //double costB = LatLong.EstimateGreatCircleDistance(candidates[i][j].getPosition(), startPosition) - // LatLong.EstimateGreatCircleDistance(GameController.Instance.originalLandmarks[i].getPosition(), OriginalLocations.Instance.getOriginalStart()); //double avDistanceTranslate = 0.0; //Algorithm A -Determine average distance between candidate and the other locations that have already been set //for (int l = 0; l < i; l++) //{ // avDistanceTranslate += LatLong.EstimateGreatCircleDistance(candidates[i][j].getPosition(), results[l].getPosition()); //} //if (i > 0) // avDistanceTranslate /= i; //Algorithm C - Distance between candidate and previous set location double prevDistanceTranslate; if (i == 0) { prevDistanceTranslate = LatLong.EstimateGreatCircleDistance(startPosition, candidates[i][j].getPosition()); } else { prevDistanceTranslate = LatLong.EstimateGreatCircleDistance(candidates[i][j].getPosition(), results[i - 1].getPosition()); } double costC = prevDistanceTranslate - prevDistanceOriginal; //double costA = avDistanceTranslate - avDistanceOriginal; float cost = Mathf.Abs((float)costC); if (cost < costs[i] && gameSpace.inSpace(candidates[i][j].getPosition()) && !duplicateChecker(candidates[i][j], results)) { results.RemoveAt(i); results.Insert(i, candidates[i][j]); costs[i] = Mathf.Abs((float)cost); } } } return(results); }
void Update() { //Set object as active when all dependencies are collected if (allDeps() && !isCollected && !GameController.Instance.listContains(this)) { GameController.Instance.setActive(this); } //Set object as collected when player enters gamespace if (Translation.Instance != null && Input.location.status == LocationServiceStatus.Running && space.inSpace(GPS.Instance.latLong) && GameController.Instance.listContains(this)) { collected(); } //Control assets display on AR camera ARManager.Instance.displayAsset(this); }