private void Start() { Creator.OnMarkerPieceWasCreated += OnMarkerPieceWasCreated; POITypeInfo info = Creator.GetTypeInfos()[TypeIDToReactTo]; OnMarkerPieceWasCreated(TypeIDToReactTo, 0, info.NumberOfPieces); }
/// <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(); }