public void RefreshFlyMonster() { List <MonsterDistributionRef> list = ConfigMng.Instance.GetMonsterDistributionRefByScene(curScene); for (int i = 0; i < list.Count; i++) { GameObject myPoint = Instantiate(monsterInstance) as GameObject; myPoint.SetActive(true); myPoint.transform.parent = mapCtrl.transform; myPoint.transform.localScale = Vector3.one; myPoint.transform.localPosition = new Vector3(list[i].position.x * posXRate, list[i].position.z * posYRate, 0); mobPointDic.Add(list[i].monsterId, myPoint); MapItem item = myPoint.GetComponent <MapItem>(); if (item != null) { if (list[i].refreshObjType == 2) { SceneItemDisRef dis = ConfigMng.Instance.GetSceneItemDisRef(list[i].monsterId); if (dis != null) { SceneItemRef S = ConfigMng.Instance.GetSceneItemRef(dis.sceneItemId); if (S != null) { string moName = S.name; item.Init(moName, new Vector3(list[i].position.x, list[i].position.z), list[i].sceneId); } } } else { MonsterRef R = ConfigMng.Instance.GetMonsterRef(list[i].monsterId); if (R != null) { string moName = R.name + "(" + R.lv + "级)"; item.Init(moName, new Vector3(list[i].position.x, list[i].position.z), list[i].sceneId); } } if (item.Obj != null) { UIEventListener.Get(item.Obj).onClick -= OnClickMapItem; UIEventListener.Get(item.Obj).onClick += OnClickMapItem; } } } }
/// <summary> /// 场景物品 /// </summary> public static AssetMng.DownloadID GetSceneItem(int _id, System.Action <GameObject, EResult> _onComplete) { SceneItemRef itemRef = ConfigMng.Instance.GetSceneItemRef(_id); if (itemRef != null) { string[] strs = itemRef.assetName.Split('/'); string resName = strs[strs.Length - 1]; AssetMng.DownloadID downloadID = AssetMng.instance.LoadAsset <GameObject>(AssetMng.GetPathWithExtension(itemRef.assetName, AssetPathType.PersistentDataPath), resName, _onComplete, true); return(downloadID); } else { GameSys.LogError("Unknown type " + _id); _onComplete(null, EResult.NotFound); return(null); } }