/// <summary> /// Called during creation mode to set a new POI marker. /// </summary> /// <param name="PointerTypeID"></param> public void OnCreateNewPOI(int PointerTypeID) { // get info from the info types POITypeInfo info = TypeInfos[PointerTypeID]; uint numPOIOfSameType = 0; foreach (POI currPOI in pointsOfInterest) { if (currPOI.ID == PointerTypeID) { numPOIOfSameType++; } } if (!(numPOIOfSameType < info.NumberOfPieces)) { Debug.Log("Tried to create too many pois of the same type"); return; } numPOIOfSameType++; // instantiate the actual poi object in unity space POI poiObject = Instantiate(POIPrefab); poiObject.transform.SetParent(MapPlane.transform, true); poiObject.SetID(info.ID); poiObject.SetGPSPosition(GPSPos); poiObject.SetName(info.Name + "(" + numPOIOfSameType + ")"); pointsOfInterest.Add(poiObject); if (null != OnMarkerPieceWasCreated) { OnMarkerPieceWasCreated.Invoke(PointerTypeID, numPOIOfSameType, info.NumberOfPieces); } // create a pointer pointing toward the poi object POIPointer pointer = Instantiate(PointerPrefab); pointer.transform.SetParent(this.transform, false); pointer.POIName = poiObject.GetName(); pointer.UnityTarget = poiObject.transform.localPosition; pointer.ID = poiObject.ID; pointer.poiObject = poiObject; Vector2 CurrentPos = MapInfo.instance.GetGPSAsUnityPosition(GPSPos); pointer.OnPlayerPositionChanged(CurrentPos); pointers.Add(pointer); CheckSaveButtonActivation(); }
public int FindWinnerID() { if (pointers.Count < 1) { return(-1); } POIPointer max = pointers[0]; foreach (POIPointer p in pointers) { if (max.VoteCount < p.VoteCount) { max = p; } } return(max.ID); }
public void OnMapInfoLoaded() { Vector3 CurrentPos = MapInfo.instance.GetGPSAsUnityPosition(GPSPosition); foreach (POIInfo poi in MapInfo.instance.GetPointsOfInterest()) { POIPointer pointer = Instantiate(PointerPrefab); pointer.transform.SetParent(this.transform, false); pointer.POIName = poi.Name; pointer.UnityTarget = poi.UnityPosition; pointer.ID = poi.ID; pointer.poiObject = poi.poiObject; pointer.OnPlayerPositionChanged(CurrentPos); pointers.Add(pointer); } MapInfo.instance.RefreshMapCenter(); ShowPOIVoteCounters(false); }
public void LoadPOIsFromSaveFile(List <POISaveInfo> poiInfos) { foreach (POI poi in pointsOfInterest) { Destroy(poi.gameObject); } pointsOfInterest.Clear(); foreach (POIPointer pointer in pointers) { Destroy(pointer.gameObject); } pointers.Clear(); foreach (POISaveInfo info in poiInfos) { // instantiate the actual poi object in unity space POI poiObject = Instantiate(POIPrefab); poiObject.transform.SetParent(MapPlane.transform, true); poiObject.SetID(info.ID); poiObject.SetGPSPosition(new Vector2(info.XGPSPos, info.YGPSPos)); poiObject.SetName(info.Name); pointsOfInterest.Add(poiObject); // create a pointer pointing toward the poi object POIPointer pointer = Instantiate(PointerPrefab); pointer.transform.SetParent(this.transform, false); pointer.POIName = poiObject.GetName(); pointer.UnityTarget = poiObject.transform.localPosition; pointer.ID = poiObject.ID; pointer.poiObject = poiObject; Vector2 CurrentPos = MapInfo.instance.GetGPSAsUnityPosition(GPSPos); pointer.OnPlayerPositionChanged(CurrentPos); pointers.Add(pointer); } }