public static void PlayUIEffect(EFFECT_ID id, Transform parent = null, Destroy.FinishCallBack finishEvent = null, InstCallBack instCallBack = null) { EffectMgr.UIEffectInfo uiei = new EffectMgr.UIEffectInfo(); uiei.parent_ = parent; uiei.instCallBack_ = instCallBack; uiei.finCallBack_ = finishEvent; uiei.finished_ = false; EffectAssetMgr.LoadAsset(id, (AssetBundle bundle, ParamData data) => { if (bundle.mainAsset == null) { ClientLog.Instance.LogError("Effect bundle is broken. ID : " + id); return; } data.uiEffectInfo_.bundle_ = bundle; Transform tParent = data.uiEffectInfo_.parent_; if (tParent.Equals(ApplicationEntry.Instance.uiRoot.transform)) { EffectMgr.Instance.uiEffectQue_.Enqueue(data.uiEffectInfo_); } else { GameObject effObj = (GameObject)GameObject.Instantiate(bundle.mainAsset); EffectAssetMgr.DeleteAsset(bundle, false); effObj.transform.parent = data.uiEffectInfo_.parent_; effObj.transform.localScale = Vector3.one; if (data.uiEffectInfo_.instCallBack_ != null) { data.uiEffectInfo_.instCallBack_(effObj); } Destroy de = effObj.GetComponent <Destroy>(); if (de == null) { de = effObj.AddComponent <Destroy>(); de.lifetime = 3f; } de.OnPlayFinish += data.uiEffectInfo_.finCallBack_; } }, new ParamData(uiei)); }
public static void PlaySceneEffect(EFFECT_ID id, Vector3 localPos, Transform parent = null, InstCallBack callback = null, bool billboard = false, float offsetY = 0f) { EffectAssetMgr.LoadAsset(id, (AssetBundle bundle, ParamData data) => { if (bundle.mainAsset == null) { ClientLog.Instance.LogError("Effect bundle is broken. ID : " + id); return; } GameObject effObj = (GameObject)GameObject.Instantiate(bundle.mainAsset); EffectAssetMgr.DeleteAsset(bundle, false); effObj.transform.parent = data.tTransform_; effObj.transform.localPosition = new Vector3(localPos.x, localPos.y + offsetY, localPos.z); if (billboard) { effObj.AddComponent <Billboard>(); } if (callback != null) { callback(effObj); } }, new ParamData(parent)); }
void OnQuestUpdate() { InitData(); int currentprocess = 0; if (QuestSystem.IsQuestFinishNpc(NpcId)) { currentprocess = Process_Finish; } else { for (int i = 0; i < Quests.Count; i++) { /*if (QuestSystem.IsQuestFinishNpc(NpcId)) * { * currentprocess = Process_Finish; * break ; * * } * else */ if (QuestSystem.IsQuestAcceptable(Quests[i])) { currentprocess = Process_Accepting; break; } else if (QuestSystem.IsQuestDoing(Quests[i])) { QuestData questData = QuestData.GetData(Quests[i]); if (questData.finishNpcId_ == NpcId) { currentprocess = Process_Doing; break; } } } } if (currentprocess == Process) { return; } Process = currentprocess; switch (Process) { case Process_Doing: EffectAssetMgr.LoadAsset(EFFECT_ID.EFFECT_huiwenhao, LoadAssetBundleCallBack, null); break; case Process_Accepting: EffectAssetMgr.LoadAsset(EFFECT_ID.EFFECT_tanhao, LoadAssetBundleCallBack, null); break; case Process_Finish: EffectAssetMgr.LoadAsset(EFFECT_ID.EFFECT_huangwenhao, LoadAssetBundleCallBack, null); break; default: if (Title != null) { Destroy(Title); } break; } }
public void Update() { if (uiEffectQue_.Count > 0) { UIEffectInfo info = uiEffectQue_.Peek(); if (info.bundle_ == null) { uiEffectQue_.Dequeue(); return; } if (!info.showing_) { GameObject effObj = (GameObject)GameObject.Instantiate(info.bundle_.mainAsset); effObj.transform.parent = info.parent_; effObj.transform.localScale = Vector3.one; if (info.instCallBack_ != null) { info.instCallBack_(effObj); } Destroy de = effObj.GetComponent <Destroy>(); if (de == null) { de = effObj.AddComponent <Destroy>(); de.lifetime = 3f; } de.OnPlayFinish += info.finCallBack_; de.OnPlayFinish += info.Fin; info.showing_ = true; EffectAssetMgr.DeleteAsset(info.bundle_, false); } if (info.finished_) { uiEffectQue_.Dequeue(); //EffectAssetMgr.DeleteAsset(info.bundle_, false); } } //if (loading) //{ // timeoutTimer += Time.deltaTime; // if (timeoutTimer > effectLoadTimeout) // { // timeoutTimer = 0f; // loading = false; // } // return; //} if (requestQue_.Count == 0) { return; } LoadRequest lr = requestQue_.Dequeue(); if (lr != null) { loading = true; EffectAssetMgr.LoadAsset(lr.id_, LoadAssetBundleCallBack, new ParamData(lr)); } }