void OnEnable() { if (iconType != MiniMapElementIconType.Empty) { MiniMapMessageDispatcher.PostElementMessage(MiniMapElementStateType.Create, id, iconType); } }
void LateUpdate() { if (MiniMapView.Instance.elementIconDict.ContainsKey(id) && lastPostion != transform.position) { lastPostion = transform.position; MiniMapMessageDispatcher.PostElementMessage(MiniMapElementStateType.Update, id, transform.position); } }
public void OnDestroy() { MiniMapMessageDispatcher.RemoveElementObserver(MiniMapElementStateType.Update, MoveElementGameObjectListener); MiniMapMessageDispatcher.RemoveElementObserver(MiniMapElementStateType.Create, AddElementDataListener); MiniMapMessageDispatcher.RemoveElementObserver(MiniMapElementStateType.Update, UpdateElementDataListener); MiniMapMessageDispatcher.RemoveElementObserver(MiniMapElementStateType.Destroy, RemoveElementDataListener); }
public void OnCreate() { view = MiniMapView.Instance; elementDataDict = new Dictionary <int, MiniMapElementIconType>(); MiniMapMessageDispatcher.AddElementObserver(MiniMapElementStateType.Update, MoveElementGameObjectListener); MiniMapMessageDispatcher.AddElementObserver(MiniMapElementStateType.Create, AddElementDataListener); MiniMapMessageDispatcher.AddElementObserver(MiniMapElementStateType.Update, UpdateElementDataListener); MiniMapMessageDispatcher.AddElementObserver(MiniMapElementStateType.Destroy, RemoveElementDataListener); }
// Update is called once per frame void Update() { if (Input.GetKeyDown(KeyCode.Alpha1)) { GameObject go = Instantiate(soldierGo) as GameObject; go.transform.parent = goParent; go.transform.localPosition = new Vector3(Random.Range(-15, 15), 0, Random.Range(-15, 15)); lastGo = go; } if (Input.GetKeyDown(KeyCode.Alpha2)) { GameObject go = Instantiate(towerGo) as GameObject; go.transform.parent = goParent; go.transform.localPosition = new Vector3(Random.Range(-15, 15), 0, Random.Range(-15, 15)); lastGo = go; } if (Input.GetKeyDown(KeyCode.Z)) { effectId = MiniMapController.MakeId(); MiniMapMessageDispatcher.PostElementMessage(MiniMapElementStateType.Create, effectId, MiniMapElementIconType.Effect1); MiniMapMessageDispatcher.PostElementMessage(MiniMapElementStateType.Update, effectId, lastGo.transform.position); b = true; } if (Input.GetKeyDown(KeyCode.X)) { MiniMapMessageDispatcher.PostElementMessage(MiniMapElementStateType.Destroy, effectId); effectId = 0; } if (Input.GetKeyDown(KeyCode.C)) { MiniMapMessageDispatcher.PostElementMessage(MiniMapElementStateType.Update, effectId, MiniMapElementIconType.Effect2); } if (Input.GetKeyDown(KeyCode.U)) { lastGo.GetComponent <MiniMapElement>().enabled = !lastGo.GetComponent <MiniMapElement>().enabled; } }
void OnDisable() { lastPostion = Vector2.zero; MiniMapMessageDispatcher.PostElementMessage(MiniMapElementStateType.Destroy, id, MiniMapView.Instance.controller.elementDataDict[id]); }
public void UpdateIcon(MiniMapElementIconType iconType) { this.iconType = iconType; MiniMapMessageDispatcher.PostElementMessage(MiniMapElementStateType.Update, id, iconType); }
public void Init(MiniMapElementIconType iconType) { id = MiniMapController.MakeId(); this.iconType = iconType; MiniMapMessageDispatcher.PostElementMessage(MiniMapElementStateType.Create, id, iconType); }