IEnumerator Coroutine_LoadCursorEffect(Vector3 targetPos, Transform t = null) { GameResPackage.AsyncLoadObjectData data = new GameResPackage.AsyncLoadObjectData(); IEnumerator e = PoolManager.Singleton.Coroutine_Load(GameData.GetEffectPath(cursorEffectName), data); while (true) { e.MoveNext(); if (data.m_isFinish) { break; } yield return(e.Current); } if (data.m_obj != null) { mCursorEffect = data.m_obj as GameObject; if (t == null) { t = MainGame.Singleton.MainObject.transform; } mCursorEffect.transform.parent = t; mCursorEffect.transform.localPosition = new Vector3(targetPos.x, 0f, targetPos.z); mCursorEffect.transform.rotation = new Quaternion(0, 0, 0, 0); mCursorEffect.transform.localScale = Vector3.one; mCursorEffect.SetActive(true); } }
//public IEnumerator LoadAsync(string prefabName, ResPackge.AsyncLoadData data) public IEnumerator Coroutine_Load(string prefabName, GameResPackage.AsyncLoadObjectData data) { //GameResMng resMgr = GameResMng.GetResMng(); //IEnumerator e = resMgr.LoadResourceAsync(GameData.GetPrefabPath(prefabName), data); IEnumerator e = GameResManager.Singleton.LoadResourceAsync(GameData.GetPrefabPath(prefabName), data); bool interrupted = false; //data.AsyncCount++; while (!interrupted) { e.MoveNext(); //if (data.IsFinish) if (data.m_isFinish) { break; } yield return(e.Current); } //data.FinishCount++; //if (!m_isDestroy && data.m_res != null) if (!m_isDestroy && data.m_obj != null) { WindowRoot = GameObject.Instantiate(data.m_obj) as GameObject; WindowRoot.transform.localScale = Vector3.one; //WindowRoot.transform.localPosition = Vector3.zero; OnLoaded(); } }
IEnumerator Coroutine_LoadTeleport(int levelId) { SceneTeleportInfo teleInfo = GameTable.SceneTeleportTableAsset.Lookup(CurRoomInfo.m_teleportData.objId); GameResPackage.AsyncLoadObjectData data = new GameResPackage.AsyncLoadObjectData(); IEnumerator e = PoolManager.Singleton.Coroutine_Load(GameData.GetPrefabPath(teleInfo.prefabName), data); while (true) { e.MoveNext(); if (data.m_isFinish) { break; } yield return(e.Current); } if (data.m_obj != null) { GameObject teleportObj = data.m_obj as GameObject; teleportObj.transform.parent = m_parentObj.transform; LevelTeleportDoor teleport = teleportObj.AddComponent <LevelTeleportDoor>(); teleport.LevelId = levelId; teleport.Target = CurRoomInfo.m_teleportData.target; teleportObj.transform.localPosition = new Vector3(CurRoomInfo.m_teleportData.position.x * blockHeight, 0f, CurRoomInfo.m_teleportData.position.z * blockHeight); CurRoomInfo.m_teleportData.outTelepotrObj = teleportObj; teleportObj.SetActive(true); } }
IEnumerator Coroutine_PlayEffect(string name, float duration, Vector3 pos) { GameResPackage.AsyncLoadObjectData data = new GameResPackage.AsyncLoadObjectData(); IEnumerator e = PoolManager.Singleton.Coroutine_Load(GameData.GetEffectPath(name), data); while (true) { e.MoveNext(); if (data.m_isFinish) { break; } yield return(e.Current); } if (data.m_obj != null) { GameObject obj = data.m_obj as GameObject; obj.transform.position = pos; obj.SetActive(true); yield return(new WaitForSeconds(duration)); if (null != obj) { PoolManager.Singleton.ReleaseObj(obj); } } }
IEnumerator Coroutine_LoadEffect(List <Vector3> posNodeList) { GameResPackage.AsyncLoadObjectData data = new GameResPackage.AsyncLoadObjectData(); IEnumerator e = PoolManager.Singleton.Coroutine_Load(GameData.GetEffectPath("ef-e-choosetarget-E01"), data); while (true) { e.MoveNext(); if (data.m_isFinish) { break; } yield return(e.Current); } if (data.m_obj != null) { foreach (Vector3 pos in posNodeList) { GameObject obj = GameObject.Instantiate(data.m_obj) as GameObject; obj.transform.position = new Vector3(pos.x, 0.1f, pos.z); obj.SetActive(true); objList.Add(obj); } } }
IEnumerator Coroutine_LoadArrow(GameObject obj) { if (!mArrowDataDict.ContainsKey(obj)) { DirectionArrowData arrowData = new DirectionArrowData(); arrowData.mObjArea = obj; arrowData.mActive = true; GameResPackage.AsyncLoadObjectData data = new GameResPackage.AsyncLoadObjectData(); IEnumerator e = PoolManager.Singleton.Coroutine_Load(GameData.GetEffectPath("ef-e-directionpoint-E01"), data); while (true) { e.MoveNext(); if (data.m_isFinish) { break; } yield return(e.Current); } if (data.m_obj != null) { arrowData.mObjArrow = data.m_obj as GameObject; //string prefabName = "Effect/ef-e-directionpoint-E01"; //arrowData.mObjArrow = GameObject.Instantiate(GameData.LoadPrefab<GameObject>(prefabName)) as GameObject; arrowData.mObjArrow.transform.parent = MainGame.Singleton.MainObject.transform; Vector3 vDirection = arrowData.mObjArea.transform.position - ActorManager.Singleton.MainActor.CenterPartWorldPos; vDirection.y = 0.0f; vDirection.Normalize(); arrowData.mObjArrow.transform.localPosition = ActorManager.Singleton.MainActor.CenterPartWorldPos; arrowData.mObjArrow.transform.rotation = Quaternion.LookRotation(vDirection.normalized) * Quaternion.LookRotation(Vector3.forward); arrowData.mObjArrow.transform.localScale = Vector3.one; arrowData.mObjArrow.SetActive(true); mArrowDataDict.Add(obj, arrowData); } } }
// 添加显示模型 void AddModel(CSItem card, GameObject parent) { if (null == card || parent == null) { return; } GameResPackage.AsyncLoadObjectData data = new GameResPackage.AsyncLoadObjectData(); m_modelDataList.Add(data); UIManager.Singleton.AddModel(card.IDInTable, parent, data); }
//协程-加载武器 IEnumerator Coroutine_ArmLoad(Transform parentTrans, string armWeaponName, int armModelID, bool isHideModel, GameResPackage.AsyncLoadPackageData loadData) { ModelInfo modelInfo = GameTable.ModelInfoTableAsset.Lookup(armModelID); if (modelInfo == null) { Debug.Log("ModelInfo load fail, id:" + armModelID); } else { GameResPackage.AsyncLoadObjectData data = new GameResPackage.AsyncLoadObjectData(); IEnumerator e = PoolManager.Singleton.Coroutine_Load(GameData.GetPrefabPath(modelInfo.ModelFile), data, true); while (true) { e.MoveNext(); if (data.m_isFinish) { break; } yield return(e.Current); } if (data.m_obj != null) { GameObject armObj = data.m_obj as GameObject; if (armObj != null) { armObj.layer = parentTrans.gameObject.layer; foreach (Transform t in armObj.transform.GetComponentsInChildren <Transform>()) { t.gameObject.layer = armObj.layer; } armObj.transform.parent = parentTrans; armObj.transform.LocalPositionY(0); armObj.transform.LocalPositionX(0); armObj.transform.LocalPositionZ(0); armObj.transform.LocalScaleX(1); armObj.transform.LocalScaleY(1); armObj.transform.LocalScaleZ(1); armObj.transform.localRotation = Quaternion.Euler(0, 0, 0); armObj.name = armWeaponName; armObj.SetActive(!isHideModel); } } else { Debug.LogError("load obj fail, name:" + modelInfo.ModelFile); } } loadData.m_isFinish = true; }
//协程-异步加载资源 //resName:资源名称、isInst:加载完的资源是否实例化、isAutoActive:是否显示 public IEnumerator Coroutine_Load(string resName, GameResPackage.AsyncLoadObjectData data, bool isAutoActive = false, bool isInst = true) { if (!m_poolDict.ContainsKey(resName)) { GameResPackage.AsyncLoadObjectData asyncData = new GameResPackage.AsyncLoadObjectData(); IEnumerator e = GameResManager.Singleton.LoadResourceAsync(resName, asyncData); while (true) { e.MoveNext(); if (asyncData.m_isFinish) { break; } yield return(e.Current); } if (asyncData.m_obj != null) { GameObjectPool pool = null; if (!m_poolDict.ContainsKey(resName)) { pool = new GameObjectPool(asyncData.m_obj, m_poolRoot); m_poolDict.Add(resName, pool); } else { pool = m_poolDict[resName]; } if (isInst) { data.m_obj = pool.CreateObj(isAutoActive); } else { data.m_obj = pool.SourceResource; } } } else { GameObjectPool pool = m_poolDict[resName]; if (isInst) { data.m_obj = pool.CreateObj(isAutoActive); } else { data.m_obj = pool.SourceResource; } } data.m_isFinish = true; }
IEnumerator Coroutine_LoadObj() { if (null == m_normalObj) { GameResPackage.AsyncLoadObjectData data = new GameResPackage.AsyncLoadObjectData(); IEnumerator e = PoolManager.Singleton.Coroutine_Load(GameData.GetUIPath("UIReduceHp"), data, true); while (true) { e.MoveNext(); if (data.m_isFinish) { break; } yield return(e.Current); } if (data.m_obj != null) { //GameObject prefabObj = GameData.LoadPrefab<GameObject>("UI/UIReduceHp"); m_normalObj = GameObject.Instantiate(data.m_obj) as GameObject;//GameObject.Instantiate(prefabObj) as GameObject; m_normalObj.name = m_normalObj.name + "_" + (++m_count).ToString(); m_normalObj.transform.parent = MainGame.Singleton.MainObject.transform; } } if (null == m_critObj) { GameResPackage.AsyncLoadObjectData data = new GameResPackage.AsyncLoadObjectData(); IEnumerator e = PoolManager.Singleton.Coroutine_Load(GameData.GetUIPath("UIReduceHp_C"), data, true); while (true) { e.MoveNext(); if (data.m_isFinish) { break; } yield return(e.Current); } if (data.m_obj != null) { //GameObject prefabObj = GameData.LoadPrefab<GameObject>("UI/UIReduceHp_C"); m_critObj = GameObject.Instantiate(data.m_obj) as GameObject; //GameObject.Instantiate(prefabObj) as GameObject; m_critObj.name = m_critObj.name + "_" + (++m_count).ToString(); m_critObj.transform.parent = MainGame.Singleton.MainObject.transform; } } }
//创建模型,并播放standby动画,cardID:HeroTableInfo表的id,parentObj:创建的obj的parent public void AddModel(int cardID, GameObject parentObj, GameResPackage.AsyncLoadObjectData data, bool isAutoActive = true) { HeroInfo info = GameTable.HeroInfoTableAsset.Lookup(cardID); if (null == info) { Debug.LogWarning("HeroInfo is null, id:" + cardID); return; } ModelInfo modelInfo = GameTable.ModelInfoTableAsset.Lookup(info.ModelId); if (null == modelInfo) { Debug.LogWarning("ModelInfo is null, id:" + info.ModelId); return; } MainGame.Singleton.StartCoroutine(Coroutine_LoadModel(GameData.GetPrefabPath(modelInfo.ModelFile), info.ModelId, info.WeaponId, parentObj, data, isAutoActive)); }
//同步加载UI //public T LoadUISync<T>(string prefabName, Anchor anchor, bool needManage = true) where T : UIWindow, new() //{ // T ui = new T(); // ui.Load(prefabName); // if (null == ui.WindowRoot) // { // Debug.LogError("Load" + prefabName + "error"); // return null; // } // GameObject anchorObj = GameObject.Find(anchor.ToString() + "Anchor"); // Vector3 pos = ui.WindowRoot.transform.localPosition; // ui.WindowRoot.transform.parent = anchorObj.transform; // ui.WindowRoot.transform.localScale = Vector3.one; // ui.WindowRoot.transform.localPosition = pos; // ui.OnInit(); // ui.AttachEvent(); // if (needManage) // { // m_UIList.Add(ui); // } // return ui; //} //异步加载UI IEnumerator Coroutine_LoadUI <T>(T win, string prefabName) where T : UIWindow, new() { //ResPackge.AsyncLoadData data = new ResPackge.AsyncLoadData(); ///IEnumerator e = win.LoadAsync(prefabName, data); GameResPackage.AsyncLoadObjectData data = new GameResPackage.AsyncLoadObjectData(); IEnumerator e = win.Coroutine_Load(prefabName, data); bool interrupted = false; while (!interrupted) { e.MoveNext(); //if (data.IsFinish) if (data.m_isFinish) { break; } yield return(e.Current); } }
IEnumerator Coroutine_LoadPressGroudEffect(Vector3 targetPos) { GameResPackage.AsyncLoadObjectData data = new GameResPackage.AsyncLoadObjectData(); IEnumerator e = PoolManager.Singleton.Coroutine_Load(GameData.GetEffectPath("ef-e-pressground-E01"), data); while (true) { e.MoveNext(); if (data.m_isFinish) { break; } yield return(e.Current); } if (data.m_obj != null) { mFlagMoveDirection = data.m_obj as GameObject; SetPressGroudEffectPos(targetPos); } }
IEnumerator Coroutine_LoadEffectObj() { GameResPackage.AsyncLoadObjectData data = new GameResPackage.AsyncLoadObjectData(); IEnumerator e = PoolManager.Singleton.Coroutine_Load(GameData.GetEffectPath("ef-e-choosetarget-E01"), data); while (true) { e.MoveNext(); if (data.m_isFinish) { break; } yield return(e.Current); } if (data.m_obj != null) { m_selectedParticle = data.m_obj as GameObject; SetEffectObjPos(); } }
IEnumerator Coroutine_LoadTestRange() {// 显示范围资源 GameResPackage.AsyncLoadObjectData data = new GameResPackage.AsyncLoadObjectData(); IEnumerator e = PoolManager.Singleton.Coroutine_Load(GameData.GetEffectPath("ef-EA"), data); while (true) { e.MoveNext(); if (data.m_isFinish) { break; } yield return(e.Current); } if (data.m_obj != null) { m_objAttackRange = data.m_obj as GameObject; m_objAttackRange.transform.parent = MainObj.transform; m_objAttackRange.transform.localPosition = new Vector3(0f, 0.1f, 0f); m_objAttackRange.transform.localScale = new Vector3(AttackRange * 2, 0f, AttackRange * 2); } data.Reset(); e = PoolManager.Singleton.Coroutine_Load(GameData.GetEffectPath("ef-EW"), data); while (true) { e.MoveNext(); if (data.m_isFinish) { break; } yield return(e.Current); } if (data.m_obj != null) { m_objAlertRange = data.m_obj as GameObject; m_objAlertRange.transform.parent = MainObj.transform; m_objAlertRange.transform.localPosition = new Vector3(0f, 0.1f, 0f); m_objAlertRange.transform.localScale = new Vector3(m_npcInfo.AlertRange * 2, 0f, m_npcInfo.AlertRange * 2); } }
IEnumerator Coroutine_LoadEffectObj() { GameResPackage.AsyncLoadObjectData data = new GameResPackage.AsyncLoadObjectData(); IEnumerator e = PoolManager.Singleton.Coroutine_Load(GameData.GetEffectPath("ef-all-diaoluo-buff-fangyu"), data); while (true) { e.MoveNext(); if (data.m_isFinish) { break; } yield return(e.Current); } if (data.m_obj != null) { mObj = data.m_obj as GameObject; mObj.transform.position += actor.MainPos; mObj.SetActive(true); } }
//协程-加载资源并且回调 IEnumerator Coroutine_LoadCallback(string resName, GameResManager.LoadResourceCallback callback, bool isAutoActive = false, bool isInst = true) { UnityEngine.Object obj = null; GameResPackage.AsyncLoadObjectData data = new GameResPackage.AsyncLoadObjectData(); IEnumerator e = GameResManager.Singleton.LoadResourceAsync(resName, data); while (true) { e.MoveNext(); if (data.m_isFinish) { break; } yield return(e.Current); } if (data.m_obj != null) { GameObjectPool pool = null; if (m_poolDict.ContainsKey(resName)) { pool = m_poolDict[resName]; } else { pool = new GameObjectPool(data.m_obj, m_poolRoot); m_poolDict.Add(resName, pool); } if (isInst) { obj = pool.CreateObj(isAutoActive); } else { obj = pool.SourceResource; } } callback(obj); }
IEnumerator Coroutine_PlayEffect(string effectName, float effectTime, string posByBone, bool isAdhered, Vector3 offset, bool isAddToAttackAction = false) { GameResPackage.AsyncLoadObjectData data = new GameResPackage.AsyncLoadObjectData(); IEnumerator e = PoolManager.Singleton.Coroutine_Load(GameData.GetEffectPath(effectName), data); while (true) { e.MoveNext(); if (data.m_isFinish) { break; } yield return(e.Current); } if (data.m_obj != null) { PlayEffect(data.m_obj as GameObject, effectTime, posByBone, isAdhered, offset); if (isAddToAttackAction) { if (ActionControl.IsActionRunning(ActorAction.ENType.enAttackAction)) { TrapAttackAction action = this.mActionControl.LookupAction(TrapAction.ENType.enAttackAction) as TrapAttackAction; action.AddEffectObj(data.m_obj as GameObject); } } } else { TrapAttackAction action = mActionControl.LookupAction(TrapAttackAction.SGetActionType()) as TrapAttackAction; if (action != null) { Debug.LogWarning("Play effect fail, actorID:" + ID + ",effectName:" + effectName); } else { Debug.LogWarning("Play effect fail, name:" + effectName); } } }
IEnumerator Coroutine_Load(string effectName, float effectTime, string posByBone, bool isAdhered, Vector3 offset) { GameResPackage.AsyncLoadObjectData data = new GameResPackage.AsyncLoadObjectData(); IEnumerator e = PoolManager.Singleton.Coroutine_Load(GameData.GetEffectPath(effectName), data); while (true) { e.MoveNext(); if (data.m_isFinish) { break; } yield return(e.Current); } if (data.m_obj != null) { CurrentActor.PlayEffect(data.m_obj as GameObject, effectTime, posByBone, isAdhered, offset); if (!m_effectList.ContainsKey(effectName)) { m_effectList.Add(effectName, data.m_obj as GameObject); } } }
IEnumerator Coroutine_LoadEffectObj() { GameResPackage.AsyncLoadObjectData data = new GameResPackage.AsyncLoadObjectData(); IEnumerator e = PoolManager.Singleton.Coroutine_Load(GameData.GetEffectPath("ef-all-w1-levelup-E01"), data); while (true) { e.MoveNext(); if (data.m_isFinish) { break; } yield return(e.Current); } if (data.m_obj != null) { mObj = data.m_obj as GameObject; Vector3 vpos = ActorManager.Singleton.MainActor.MainPos; mObj.transform.position = vpos; mObj.transform.parent = MainGame.Singleton.MainObject.transform; mObj.name = "LvlUpEff"; } }
IEnumerator Coroutine_Load() { if (m_obj == null) { GameResPackage.AsyncLoadObjectData data = new GameResPackage.AsyncLoadObjectData(); IEnumerator e = PoolManager.Singleton.Coroutine_Load(GameData.GetUIPath("DropItem"), data, true); while (true) { e.MoveNext(); if (data.m_isFinish) { break; } yield return(e.Current); } m_obj = data.m_obj as GameObject; } IsEnable = true; m_obj.transform.localScale = new UnityEngine.Vector3(0.2f, 0.2f, 0.2f); m_obj.transform.localPosition = new Vector3(m_posX, 0.0f, m_posZ); GameObject item = m_obj.transform.Find("DropItmSupply").gameObject; GameObject name = m_obj.transform.Find("ItemName").gameObject; int nIcnID = 0; string NAME = ""; int color = 1; if (1 == m_type) // ����: װ��(��) { EquipInfo einf = GameTable.EquipTableAsset.LookUpEquipInfoById(mItemID); if (einf != null) { int nMdlInfID = einf.ModelRes; // ���Ҷ�Ӧ��ʾͼ�� ModelInfo MdlInf = GameTable.ModelInfoTableAsset.Lookup(nMdlInfID); if (MdlInf != null) { nIcnID = MdlInf.DropIcon; } } NAME = einf.EquipName; color = einf.EqRank; } else if (2 == m_type) // ����: Buf(��) { BuffInfo bfInfo = GameTable.BuffTableAsset.Lookup(mItemID); if (null != bfInfo) { nIcnID = bfInfo.BuffIcon; } else { Debug.LogWarning("CreateDropObj: LOST Buf ItemID = " + mItemID.ToString()); } NAME = bfInfo.BuffName; } else if (3 == m_type) // ��Ǯ { WorldParamInfo WorldParamList; WorldParamList = GameTable.WorldParamTableAsset.Lookup((int)ENWorldParamIndex.enMoneyDropIcon); nIcnID = WorldParamList.IntTypeValue; NAME = GameTable.StringTableAsset.GetString(ENStringIndex.UIEquipmentBindMoney); } else if (4 == m_type) // ���� { WorldParamInfo WorldParamList; WorldParamList = GameTable.WorldParamTableAsset.Lookup((int)ENWorldParamIndex.enRMBMoneyDropIcon); nIcnID = WorldParamList.IntTypeValue; NAME = GameTable.StringTableAsset.GetString(ENStringIndex.UIEquipmentRMBMoney); } else if (5 == m_type) //��Ӿ� { WorldParamInfo WorldParamList; WorldParamList = GameTable.WorldParamTableAsset.Lookup((int)ENWorldParamIndex.enTeamVolumeDropIcon); nIcnID = WorldParamList.IntTypeValue; //todo ����ַ����� NAME = GameTable.StringTableAsset.GetString(ENStringIndex.TeamVolume); } else { Debug.LogWarning("CreateDropObj: Unknown Type = " + m_type.ToString()); } IconInfo icInf = GameTable.IconTableAsset.Lookup(nIcnID); if (icInf == null) { Debug.LogWarning("CreateDropObj: LOST = " + nIcnID.ToString()); } else { // �����ɼ����� GameResPackage.AsyncLoadObjectData data = new GameResPackage.AsyncLoadObjectData(); IEnumerator e = PoolManager.Singleton.Coroutine_Load(GameData.GetUIAtlasPath(icInf.AtlasName), data, false, false); while (true) { e.MoveNext(); if (data.m_isFinish) { break; } yield return(e.Current); } if (data.m_obj != null) { UIAtlas ua = data.m_obj as UIAtlas; if (ua != null) { UISprite spt = item.GetComponent <UISprite>(); spt.atlas = ua; spt.name = icInf.AtlasName; spt.spriteName = icInf.SpriteName; } } } if (NAME != "") { UILabel label = name.GetComponent <UILabel>(); label.text = NAME; switch (color) { case 1: label.color = Color.white; break; case 2: label.color = Color.green; break; case 3: label.color = Color.blue; break; case 4: label.color = Color.magenta; break; case 5: label.color = Color.yellow; break; default: break; } } PickupDropCallback pdCall = item.GetComponent <PickupDropCallback>(); if (pdCall != null) { pdCall.AttachDropValue(this, mDropID, mItemID); // ��Щ������Ҫͬ���������� } }
IEnumerator Coroutine_Add(RemoteAttackManager.Info info) { //飞行道具 if (string.IsNullOrEmpty(info.m_itemInfo.Item_Name)) { Debug.LogWarning("effect name is null"); } else { GameResPackage.AsyncLoadObjectData data = new GameResPackage.AsyncLoadObjectData(); IEnumerator e = PoolManager.Singleton.Coroutine_Load(GameData.GetEffectPath(info.m_itemInfo.Item_Name), data, true); while (true) { e.MoveNext(); if (data.m_isFinish) { break; } yield return(e.Current); } if (data.m_obj == null) { Debug.LogWarning("load effect obj fail, effect name is " + info.m_itemInfo.Item_Name); } else { info.m_itemObj = data.m_obj as GameObject; //获得脚本 FlyingItemCallback callback = info.m_itemObj.GetComponent <FlyingItemCallback>(); if (callback == null) { //从子中获得脚本 callback = info.m_itemObj.GetComponentInChildren <FlyingItemCallback>(); if (callback == null) {//未获得脚本,添加脚本在collider上 //获得collider Collider c = info.m_itemObj.GetComponent <Collider>(); if (c == null) { //从子中获得collider c = info.m_itemObj.GetComponentInChildren <Collider>(); } if (c != null) { callback = c.transform.gameObject.AddComponent <FlyingItemCallback>(); } else { if (!info.m_itemInfo.IsStretch) {//拉伸道具不使用collider Debug.LogWarning("fly obj is not exist collider, fly obj id = " + info.m_itemInfo.ID); } } } } if (callback != null) { callback.Init(info); } //获得Rigidbody Rigidbody rBody = info.m_itemObj.GetComponent <Rigidbody>(); if (rBody == null) { rBody = info.m_itemObj.GetComponentInChildren <Rigidbody>(); } info.m_rigidbody = rBody; if (!string.IsNullOrEmpty(info.m_itemInfo.Item_BoneName)) {//起始bone info.m_boneT = info.m_srcActor.LookupBone(info.m_srcActor.MainObj.transform, info.m_itemInfo.Item_BoneName); if (info.m_boneT == null) {//没有bone,则出生在CenterCollider if (info.m_srcActor.CenterCollider != null) { info.m_boneT = info.m_srcActor.CenterCollider.transform; } info.m_itemObj.transform.position = info.m_srcActor.RealPos; Debug.LogWarning("lookup bone fail, bone name is " + info.m_itemInfo.Item_BoneName); } else { info.m_itemObj.transform.position = info.m_boneT.position; } } else { if (info.m_targetPos != Vector3.zero) {//没有起始bone,则出生在目标点 info.m_itemObj.transform.position = info.m_targetPos; } else {//没有目标点,则出生在CenterCollider info.m_itemObj.transform.position = info.m_srcActor.RealPos; } if (info.m_srcActor.CenterCollider != null) { info.m_boneT = info.m_srcActor.CenterCollider.transform; } } if (!string.IsNullOrEmpty(info.m_itemInfo.Item_BoneOffset)) { Vector3 pos = info.m_itemObj.transform.position; string[] param = info.m_itemInfo.Item_BoneOffset.Split(new char[1] { ',' }); Vector3 offset = new Vector3(float.Parse(param[0]), float.Parse(param[1]), float.Parse(param[2])); pos = pos + info.m_boneT.rotation * offset; info.m_itemObj.transform.position = pos; } if (info.m_srcPos != Vector3.zero) { info.m_itemObj.transform.position = info.m_srcPos; } if (info.m_itemInfo.Item_MoveSpeed == 0) { Vector3 currentForward = info.m_itemObj.transform.eulerAngles; currentForward.y = info.m_srcActor.MainObj.transform.eulerAngles.y; info.m_itemObj.transform.eulerAngles = currentForward; } info.m_startPos = info.m_itemObj.transform.position; info.m_actorType = info.m_srcActor.Type; if (info.m_actorType != info.m_srcActor.TempType) {//使用更改后的ActorType info.m_actorType = info.m_srcActor.TempType; } info.m_actorCamp = (ENCamp)info.m_srcActor.Camp; if (info.m_actorCamp != info.m_srcActor.TempCamp) { info.m_actorCamp = info.m_srcActor.TempCamp; } if (info.m_itemInfo.IsWarningBeforeItem) { info.m_isHaveWarningEffect = true; //方向 if (info.m_targetPos != Vector3.zero) {//有目标,起始点为道具出生点 if (info.m_itemInfo.Item_IsLockY) { info.m_targetPos.y = info.m_startPos.y; } Vector3 direction = info.m_targetPos - info.m_startPos; direction.Normalize(); info.m_forward = direction; } else {//无目标 info.m_forward = info.m_srcActor.MainObj.transform.forward; } {//预警特效 GameResPackage.AsyncLoadObjectData data2 = new GameResPackage.AsyncLoadObjectData(); e = PoolManager.Singleton.Coroutine_Load(GameData.GetEffectPath(info.m_itemInfo.WarningEffectName), data2, true); while (true) { e.MoveNext(); if (data2.m_isFinish) { break; } yield return(e.Current); } if (data2.m_obj != null) { info.m_objWarningEffect = data2.m_obj as GameObject; info.m_objWarningEffect.transform.localPosition = info.m_targetPos; } } //info.m_objWarningEffect = PoolManager.Singleton.CreateEffectObj(info.m_itemInfo.WarningEffectName); //info.m_objWarningEffect.transform.localPosition = info.m_targetPos; info.m_startTime = Time.time; info.m_itemObj.SetActive(false); } else { //方向 if (info.m_targetPos != Vector3.zero) {//有目标,起始点为collider if (info.m_itemInfo.Item_IsLockY) { info.m_targetPos.y = info.m_startPos.y; } Vector3 direction = info.m_targetPos - info.m_startPos; direction.Normalize(); info.m_forward = direction; } else {//无目标 info.m_forward = info.m_srcActor.MainObj.transform.forward; } } info.m_cameraIsBack = false; if (info.m_itemObj.activeSelf) {//没有预警特效,直接改变焦点 if (info.m_itemInfo.IsChangeCamera) { if (info.m_actorType == ActorType.enMain) { MainGame.Singleton.MainCamera.ChangeFollowTarget(info.m_itemObj, info.m_itemInfo.CC_ChangeTime, info.m_itemInfo.CC_BackTime, false); } } } if (info.m_itemInfo.IsCurveMove) {//曲线移动,设置曲线移动的方向 string[] array = info.m_itemInfo.Item_AddtionalDirection.Split(new char[1] { ',' }); int x = 0, y = 0, z = 0; if (array.Length > 0) { x = int.Parse(array[0]); } if (array.Length > 1) { y = int.Parse(array[1]); } if (array.Length > 2) { z = int.Parse(array[2]); } info.m_curveForward = info.m_forward - new Vector3(x, y, z); //Debug.LogError("old forward:"+info.m_forward.ToString()+",new forward:"+info.m_curveForward.ToString()); } info.m_itemObj.transform.localScale = Vector3.one; if (info.m_itemInfo.IsStretch) {//拉伸-z轴 float d = 0; if (info.m_dstActor != null) { d = ActorTargetManager.GetTargetDistance(info.m_srcActor.MainPos, info.m_dstActor.MainPos); } info.m_duration = d / info.m_itemInfo.ZAxisLongth / info.m_itemInfo.Item_StretchSpeed; //Debug.LogError("remote attack,d:" + d + ",z:" + info.m_itemInfo.ZAxisLongth + ",speed:" + info.m_itemInfo.Item_StretchSpeed); info.m_itemObj.transform.forward = info.m_forward; info.m_itemObj.transform.localScale = new Vector3(0.1f, 0.1f, 0.1f); } info.m_itemObj.SetActive(false); m_infoList.Add(info); } } }
IEnumerator Coroutine_LoadObj() { if (null == m_phyNormalObj) { GameResPackage.AsyncLoadObjectData data = new GameResPackage.AsyncLoadObjectData(); IEnumerator e = PoolManager.Singleton.Coroutine_Load(GameData.GetUIPath("UIPhysicalDamageNum"), data, true); while (true) { e.MoveNext(); if (data.m_isFinish) { break; } yield return(e.Current); } if (data.m_obj != null) { //GameObject prefabObj = GameData.LoadPrefab<GameObject>("UI/UIPhysicalDamageNum"); m_phyNormalObj = data.m_obj as GameObject;//GameObject.Instantiate(prefabObj) as GameObject; m_phyNormalObj.name = m_phyNormalObj.name + "_" + (++m_count).ToString(); m_phyNormalObj.transform.parent = MainGame.Singleton.MainObject.transform; m_phyNormalLabel = m_phyNormalObj.GetComponentInChildren <UILabel>(); m_phyNormalAnim = m_phyNormalObj.GetComponentInChildren <Animation>(); } } if (null == m_phyCritObj) { GameResPackage.AsyncLoadObjectData data = new GameResPackage.AsyncLoadObjectData(); IEnumerator e = PoolManager.Singleton.Coroutine_Load(GameData.GetUIPath("UIPhysicalDamageNum_C"), data, true); while (true) { e.MoveNext(); if (data.m_isFinish) { break; } yield return(e.Current); } if (data.m_obj != null) { //GameObject prefabObj = GameData.LoadPrefab<GameObject>("UI/UIPhysicalDamageNum_C"); m_phyCritObj = data.m_obj as GameObject;//GameObject.Instantiate(prefabObj) as GameObject; m_phyCritObj.name = m_phyCritObj.name + "_" + (++m_count).ToString(); m_phyCritObj.transform.parent = MainGame.Singleton.MainObject.transform; m_phyCritLabel = m_phyCritObj.GetComponentInChildren <UILabel>(); m_phyCritAnim = m_phyCritObj.GetComponentInChildren <Animation>(); } } if (null == m_magNormalObj) { GameResPackage.AsyncLoadObjectData data = new GameResPackage.AsyncLoadObjectData(); IEnumerator e = PoolManager.Singleton.Coroutine_Load(GameData.GetUIPath("UIHealNum"), data, true); while (true) { e.MoveNext(); if (data.m_isFinish) { break; } yield return(e.Current); } if (data.m_obj != null) { //GameObject prefabObj = GameData.LoadPrefab<GameObject>("UI/UIHealNum"); m_magNormalObj = data.m_obj as GameObject;//GameObject.Instantiate(prefabObj) as GameObject; m_magNormalObj.name = m_magNormalObj.name + "_" + (++m_count).ToString(); m_magNormalObj.transform.parent = MainGame.Singleton.MainObject.transform; m_magNormalLabel = m_magNormalObj.GetComponentInChildren <UILabel>(); m_magNormalAnim = m_magNormalObj.GetComponentInChildren <Animation>(); } } if (null == m_magCritObj) { GameResPackage.AsyncLoadObjectData data = new GameResPackage.AsyncLoadObjectData(); IEnumerator e = PoolManager.Singleton.Coroutine_Load(GameData.GetUIPath("UIMagicDamageNum_C"), data, true); while (true) { e.MoveNext(); if (data.m_isFinish) { break; } yield return(e.Current); } if (data.m_obj != null) { //GameObject prefabObj = GameData.LoadPrefab<GameObject>("UI/UIMagicDamageNum_C"); m_magCritObj = data.m_obj as GameObject;//GameObject.Instantiate(prefabObj) as GameObject; m_magCritObj.name = m_magCritObj.name + "_" + (++m_count).ToString(); m_magCritObj.transform.parent = MainGame.Singleton.MainObject.transform; m_magCritLabel = m_magCritObj.GetComponentInChildren <UILabel>(); m_magCritAnim = m_magCritObj.GetComponentInChildren <Animation>(); } } }
// 生成场景资源数据 public IEnumerator BuildSceneResObj(SERoomDataTree sce, GameResPackage.AsyncLoadPackageData loadData, int gateIndex = -1) { string obstacleFileName = "Prefabs/" + m_RoomPrefabName + "-bytes.bytes"; GameResPackage.AsyncLoadObjectData loadData2 = new GameResPackage.AsyncLoadObjectData(); IEnumerator e = PoolManager.Singleton.Coroutine_Load(obstacleFileName, loadData2, false, false); while (true) { e.MoveNext(); if (loadData2.m_isFinish) { break; } yield return(e.Current); } if (loadData2.m_obj != null) { TextAsset asset = loadData2.m_obj as TextAsset; if (asset == null) { Debug.Log("obstacleFileName=" + obstacleFileName); } else { m_obstacleData = new SceneObstacleData(); m_obstacleData.Load(asset.bytes); } } loadData2 = new GameResPackage.AsyncLoadObjectData(); e = PoolManager.Singleton.Coroutine_Load(GameData.GetPrefabPath(m_RoomPrefabName), loadData2, false, false); while (true) { e.MoveNext(); if (loadData2.m_isFinish) { break; } yield return(e.Current); } if (loadData2.m_obj != null) { sce.mRoomObj = loadData2.m_obj as GameObject; } string roomDataName = m_RoomPrefabName + "-data"; loadData2 = new GameResPackage.AsyncLoadObjectData(); e = PoolManager.Singleton.Coroutine_Load(GameData.GetPrefabPath(roomDataName), loadData2, false, false); while (true) { e.MoveNext(); if (loadData2.m_isFinish) { break; } yield return(e.Current); } if (loadData2.m_obj != null) { sce.mRoomData = loadData2.m_obj as GameObject; } sce.mRoomInfoTree = this; // for (int i = 0; i < m_gateList.Count; i++) // { // sce.mGateData[i] = new SEGateData(); // if (null != m_gateList[i].BridgeData) // { // SceneBridgeInfo bridgeInfo = GameTable.SceneBridgeTableAsset.Lookup(m_gateList[i].BridgeData.bridgeObjId); // if (null != bridgeInfo) // { // loadData2 = new GameResPackage.AsyncLoadObjectData(); // e = PoolManager.Singleton.Coroutine_Load(GameData.GetPrefabPath(bridgeInfo.bridgeHeadPrefab), loadData2, false, false); // while (true) // { // e.MoveNext(); // if (loadData2.m_isFinish) // { // break; // } // yield return e.Current; // } // if (loadData2.m_obj != null) // { // sce.mGateData[i].mBridgeHeadObj = loadData2.m_obj as GameObject; // } // loadData2 = new GameResPackage.AsyncLoadObjectData(); // e = PoolManager.Singleton.Coroutine_Load(GameData.GetPrefabPath(bridgeInfo.bridgeBodyPrefab), loadData2, false, false); // while (true) // { // e.MoveNext(); // if (loadData2.m_isFinish) // { // break; // } // yield return e.Current; // } // if (loadData2.m_obj != null) // { // sce.mGateData[i].mBridgeBodyObj = loadData2.m_obj as GameObject; // } // loadData2 = new GameResPackage.AsyncLoadObjectData(); // e = PoolManager.Singleton.Coroutine_Load(GameData.GetPrefabPath(bridgeInfo.bridgeTailPrefab), loadData2, false, false); // while (true) // { // e.MoveNext(); // if (loadData2.m_isFinish) // { // break; // } // yield return e.Current; // } // if (loadData2.m_obj != null) // { // sce.mGateData[i].mBridgeTailObj = loadData2.m_obj as GameObject; // } // //sce.mGateData[i].mBridgeHeadObj = GameData.LoadPrefab<GameObject>(bridgeInfo.bridgeHeadPrefab); // //sce.mGateData[i].mBridgeBodyObj = GameData.LoadPrefab<GameObject>(bridgeInfo.bridgeBodyPrefab); // } // sce.mGateData[i].mIsHaveTunnel = true; // sce.mGateData[i].mBridgeCenterLength = m_gateList[i].BridgeData.bridgeCenterLength; // sce.mGateData[i].mNextRoomNode = new SERoomDataTree(); // m_gateList[i].isGateOpen = true; // GameResPackage.AsyncLoadPackageData loadData3 = new GameResPackage.AsyncLoadPackageData(); // IEnumerator e6 = m_gateList[i].BridgeData.nextRoomNode.BuildSceneResObj(sce.mGateData[i].mNextRoomNode, loadData3, (i + 2) % 4);//一共四个门0对应2,1对应3。0+2%4= 2,1+2%4=3,2+2%4=0,3+2%4=1。· // while (true) // { // e6.MoveNext(); // if (loadData3.m_isFinish) // { // break; // } // yield return e6.Current; // } // } // else // {//当该房间的这个门是没有联通出去的路的,但是这个门是另外房间进来的门那这个门要有意义。否则无意义 // if (gateIndex == i) // { // m_gateList[i].isGateOpen = true; // m_gateList[i].gateOpenCondId = ENGateOpenCondType.enNone; // } // else // { // m_gateList[i].isGateOpen = false; // } // } // } loadData.m_isFinish = true; }
//public void Load (string prefabName) //{ // GameObject preObj = GameData.LoadPrefab<GameObject> (prefabName); // if (preObj == null) { // preObj = GameData.Load<GameObject> (prefabName); // } // WindowRoot = GameObject.Instantiate (preObj) as GameObject; // WindowRoot.transform.localScale = new Vector3 (1.0f, 1.0f, 1.0f); //} //public bool TryLoadSync(string prefabName) //{ // GameObject preObj = GameData.LoadPrefab<GameObject>(prefabName); // if (preObj == null) // { // preObj = GameData.Load<GameObject>(prefabName); // } // if (preObj != null) // { // WindowRoot = GameObject.Instantiate(preObj) as GameObject; // WindowRoot.transform.localScale = Vector3.one; // WindowRoot.transform.localPosition = Vector3.zero; // OnLoaded(); // return true; // } // return false; //} //异步加载 public void LoadAsync(string prefabName) { GameResPackage.AsyncLoadObjectData data = new GameResPackage.AsyncLoadObjectData(); MainGame.Singleton.StartCoroutine(Coroutine_Load(prefabName, data)); }
//异步加载资源,filename:Assets/之后的完整路径 public IEnumerator LoadResourceAsync(string filename, GameResPackage.AsyncLoadObjectData data) { if (UsePackage) { string resourcesPath = "Assets/Resources/" + filename; string extendsPath = "Assets/Extends/" + filename; string path = ""; if (AllGameResMap.ContainsKey(resourcesPath.ToLower())) { path = resourcesPath; } else if (AllGameResMap.ContainsKey(extendsPath.ToLower())) { path = extendsPath; } else { int index = resourcesPath.LastIndexOf("/"); if (index > 0) { string dir = resourcesPath.Substring(0, index); //Debug.Log("dir:" + dir); if (AllGameResMap.ContainsKey(dir.ToLower())) { path = dir; } } } if (!string.IsNullOrEmpty(path)) { GameResPackage p = null; AllGameResMap.TryGetValue(path.ToLower(), out p); if (p != null) { UpdateDelayCleanPackageTime(p); IEnumerator e = p.LoadObjectAsync(path.ToLower(), data); while (true) { e.MoveNext(); if (data.m_isFinish) { break; } yield return(e.Current); } //if (data.m_obj != null) //{ // Debug.Log("load res from package succ, filename:" + filename); //} } else { //Debug.LogWarning("load resource fail, package is null, file:" + filename); } } else { //Debug.LogWarning("load resource fail, resource is not exists, file:" + filename); } } #if (UNITY_EDITOR) // 编辑模式下 if (TestAsync) { IEnumerator eSimulate = SimulateWait(); int testcount = 0; while (true) { eSimulate.MoveNext(); testcount++; if (testcount > 1) { break; } yield return(eSimulate.Current); } } if (null == data.m_obj) { data.m_obj = AssetDatabase.LoadMainAssetAtPath("Assets/Extends/" + filename); } if (null == data.m_obj) { data.m_obj = AssetDatabase.LoadMainAssetAtPath("Assets/Resources/" + filename); } #endif if (null == data.m_obj) // 容错: 也许没有打包或用Unity打包 { string szf = filename; // 影射到 Resources/ 目录下 int npos = szf.LastIndexOf('.'); // 去掉扩展名 if (npos > 0) { szf = szf.Substring(0, npos); } data.m_obj = Resources.Load("Extends/" + szf); if (null == data.m_obj) { data.m_obj = Resources.Load(szf); } } if (null == data.m_obj) { Debug.LogWarning("load resource async fail, filename:" + filename); } data.m_isFinish = true; }
//协程-加载模型,并播放standby动画 IEnumerator Coroutine_LoadModel(string prefabName, int modelID, int weaponID, GameObject parentObj, GameResPackage.AsyncLoadObjectData data, bool isAutoActive = true) { IEnumerator e = PoolManager.Singleton.Coroutine_Load(prefabName, data, true); while (true) { e.MoveNext(); if (data.m_isFinish) { break; } yield return(e.Current); } if (null != data.m_obj) { GameObject obj = data.m_obj as GameObject; obj.layer = GameObject.Find("UI Root (2D)").layer; obj.SetActive(true); foreach (Transform t in obj.transform.GetComponentsInChildren <Transform>()) { t.gameObject.layer = obj.layer; } PreAnimationLoad.Singleton.LoadAnimation(obj, modelID, weaponID); Animation MainAnim = obj.GetComponent <Animation>(); if (null != MainAnim) { string mAnimName = ""; ModelInfo info = GameTable.ModelInfoTableAsset.Lookup(modelID); WeaponInfo wInfo = GameTable.WeaponInfoTableAsset.Lookup(weaponID); if (info != null && wInfo != null) { mAnimName = "a-" + info.modelType.ToString() + "-w" + ((int)wInfo.WeaponType).ToString() + "-"; } AnimInfo tempAnimData = GameTable.AnimationTableAsset.Lookup("standby"); if (null != tempAnimData) { mAnimName = mAnimName + tempAnimData.AnimName[UnityEngine.Random.Range(0, tempAnimData.AnimName.Length)]; } AnimationClip clip = MainAnim.GetClip(mAnimName); if (clip != null) { MainAnim.CrossFade(clip.name); } else { Debug.LogWarning("play model animation fail,prefabName:" + prefabName + ",animationName:" + mAnimName); } } obj.transform.parent = parentObj.transform; obj.transform.localPosition = Vector3.zero; obj.transform.localScale = Vector3.one; obj.transform.localRotation = Quaternion.Euler(0, 0, 0); if (weaponID != 0) { GameResPackage.AsyncLoadPackageData data2 = new GameResPackage.AsyncLoadPackageData(); IEnumerator e2 = Coroutine_LoadWeapon(obj, weaponID, data2); while (true) { e2.MoveNext(); if (data2.m_isFinish) { break; } yield return(e2.Current); } } obj.SetActive(isAutoActive); } }
IEnumerator LoadInfo(string name, int type, GameResPackage.AsyncLoadPackageData loadData) { if (type == (int)Type.enEffect) { GameResPackage.AsyncLoadObjectData data = new GameResPackage.AsyncLoadObjectData(); IEnumerator e = PoolManager.Singleton.Coroutine_Load(GameData.GetEffectPath(name), data); while (true) { e.MoveNext(); if (data.m_isFinish) { break; } yield return(e.Current); } //yield return PoolManager.Singleton.LoadEffectWithPool(name); } else { GameResPackage.AsyncLoadObjectData data = new GameResPackage.AsyncLoadObjectData(); IEnumerator e = PoolManager.Singleton.Coroutine_Load(name, data); while (true) { e.MoveNext(); if (data.m_isFinish) { break; } yield return(e.Current); } //yield return PoolManager.Singleton.LoadObjWithoutDir(name, false); } m_cur++; Debug.Log("LoadInfo 更新m_cur " + m_cur + ",name:" + name); m_tempList.Remove(name); if (m_tempList.Count == 0) { // 移除第一个 m_nameList.RemoveAt(0); // 所有资源加载完成 if (m_nameList.Count == 0) { Debug.Log("所有资源加载完成"); if (null != m_finished) { m_finished(); } } else { GameResPackage.AsyncLoadPackageData loadData2 = new GameResPackage.AsyncLoadPackageData(); IEnumerator e = Load(m_nameList[0], 0, loadData2); while (true) { e.MoveNext(); if (loadData2.m_isFinish) { break; } yield return(e.Current); } //MainGame.Singleton.StartCoroutine(Load(m_nameList[0], 0)); } } else { GameResPackage.AsyncLoadPackageData loadData2 = new GameResPackage.AsyncLoadPackageData(); IEnumerator e = LoadInfo(m_tempList[0], 1, loadData2); while (true) { e.MoveNext(); if (loadData2.m_isFinish) { break; } yield return(e.Current); } //MainGame.Singleton.StartCoroutine(LoadInfo(m_tempList[0],1)); } loadData.m_isFinish = true; }
IEnumerator Load(string name, int type, GameResPackage.AsyncLoadPackageData loadData) { if (type == (int)Type.enEffect) { GameResPackage.AsyncLoadObjectData data = new GameResPackage.AsyncLoadObjectData(); IEnumerator e = PoolManager.Singleton.Coroutine_Load(GameData.GetEffectPath(name), data); while (true) { e.MoveNext(); if (data.m_isFinish) { break; } yield return(e.Current); } //yield return PoolManager.Singleton.LoadEffectWithPool(name); } else { GameResPackage.AsyncLoadObjectData data = new GameResPackage.AsyncLoadObjectData(); IEnumerator e = PoolManager.Singleton.Coroutine_Load(name, data); while (true) { e.MoveNext(); if (data.m_isFinish) { break; } yield return(e.Current); } //yield return PoolManager.Singleton.LoadObjWithoutDir(name, false); } m_cur++; Debug.Log("Load 更新 m_cur" + m_cur + ",name:" + name); PreResourceInfo info = null; m_list.TryGetValue(name, out info); m_tempList.Clear(); // 如果没有 子列表资源 if (null == info) { // 移除 m_nameList.RemoveAt(0); // 所有资源加载完成 if (m_nameList.Count == 0) { Debug.Log("所有资源加载完成"); if (null != m_finished) { m_finished(); } } else { //MainGame.Singleton.StartCoroutine(Load(m_nameList[0], (int)Type.enPrefab)); GameResPackage.AsyncLoadPackageData loadData2 = new GameResPackage.AsyncLoadPackageData(); IEnumerator e = Load(m_nameList[0], (int)Type.enPrefab, loadData2); while (true) { e.MoveNext(); if (loadData2.m_isFinish) { break; } yield return(e.Current); } } } else { foreach (KeyValuePair <string, int> item in info.m_list) { m_tempList.Add(item.Key); } if (m_tempList.Count == 0) { // 移除 m_nameList.RemoveAt(0); // 所有资源加载完成 if (m_nameList.Count == 0) { Debug.Log("所有资源加载完成"); if (null != m_finished) { m_finished(); } } else { //MainGame.Singleton.StartCoroutine(Load(m_nameList[0], (int)Type.enPrefab)); GameResPackage.AsyncLoadPackageData loadData2 = new GameResPackage.AsyncLoadPackageData(); IEnumerator e = Load(m_nameList[0], (int)Type.enPrefab, loadData2); while (true) { e.MoveNext(); if (loadData2.m_isFinish) { break; } yield return(e.Current); } } } else { //MainGame.Singleton.StartCoroutine(LoadInfo(m_tempList[0], (int)Type.enEffect)); GameResPackage.AsyncLoadPackageData loadData2 = new GameResPackage.AsyncLoadPackageData(); IEnumerator e = LoadInfo(m_tempList[0], (int)Type.enEffect, loadData2); while (true) { e.MoveNext(); if (loadData2.m_isFinish) { break; } yield return(e.Current); } } loadData.m_isFinish = true; } }
// IEnumerator NewDropItem(GameResPackage.AsyncLoadPackageData loadData, DropItemPerformanceType item, int intParam = 0) { EventItemInfo eventInfo = GameTable.eventItemAsset.LookUp(item.m_intParam); DropItemPerformanceType.Type type = item.m_type; if (eventInfo != null) { type = (DropItemPerformanceType.Type)eventInfo.dropType; } // string objName = ""; switch (type) { case DropItemPerformanceType.Type.enGold: { objName = "Balk/p-b-gold"; break; } case DropItemPerformanceType.Type.enCard: { objName = "Balk/p-b-contract"; //DropItemPerformanceCard cardItem = (DropItemPerformanceCard)item; // 根据不同星级掉落不同 模型 HeroInfo heroInfo = GameTable.HeroInfoTableAsset.Lookup(intParam); if (null != heroInfo) { RarityRelativeInfo rarityInfo = GameTable.RarityRelativeAsset.LookUp(heroInfo.Rarity); if (null != rarityInfo) { ModelInfo modelInfo = GameTable.ModelInfoTableAsset.Lookup(rarityInfo.m_dropItemModelID); if (null != modelInfo) { objName = modelInfo.ModelFile; } } } break; } case DropItemPerformanceType.Type.enKey: { // 钥匙模型 objName = "Balk/p-b-gold"; EventItemInfo eventItemInfo = GameTable.eventItemAsset.LookUp(intParam); if (null != eventItemInfo) { ModelInfo modelInfo = GameTable.ModelInfoTableAsset.Lookup(eventItemInfo.modelId); if (null != modelInfo) { objName = modelInfo.ModelFile; } } break; } } float rotation = 30f; rotation = UnityEngine.Random.Range(0f, 360f); GameResPackage.AsyncLoadObjectData data = new GameResPackage.AsyncLoadObjectData(); IEnumerator e = PoolManager.Singleton.Coroutine_Load(GameData.GetPrefabPath(objName), data); while (true) { e.MoveNext(); if (data.m_isFinish) { break; } yield return(e.Current); } GameObject goldObj = data.m_obj as GameObject; goldObj.transform.parent = MainGame.Singleton.MainObject.transform; goldObj.transform.position = item.m_deadPos; goldObj.SetActive(true); goldObj.transform.localEulerAngles = new Vector3(item.m_eulerAngles.x, item.m_eulerAngles.y + rotation, item.m_eulerAngles.z); int dropIndex = AddDropItem(goldObj); Animation anim = goldObj.transform.Find("gold_body").GetComponent <Animation>(); PickUpCallback pickUpCallback = goldObj.transform.Find("gold_body").GetComponent <PickUpCallback>(); if (null != pickUpCallback) { pickUpCallback.Clear(); pickUpCallback.m_index = dropIndex; } // 随机动画 int animationCount = anim.GetComponent <Animation>().GetClipCount(); int animationIndex = UnityEngine.Random.Range(1, animationCount); int index = 1; foreach (AnimationState state in anim.GetComponent <Animation>()) { if (index == animationIndex) { anim.CrossFade(state.name); break; } index++; } loadData.m_isFinish = true; }