Beispiel #1
0
        public void LoadMonsterResList(List <int> list, Action <bool> callBack)
        {
            if (list.Count <= 0 && callBack != null)
            {
                callBack(true);
            }
            int count = 0;

            for (int i = 0; i < list.Count; i++)
            {
                var typeID = list[i];
                if (this.prefabDic.ContainsKey("MonsterRes_" + typeID))
                {
                    count++;
                    if (callBack != null && count == list.Count)
                    {
                        callBack(true);
                    }
                    continue;
                }
                string bodyPath = ResPath.GetMonsterBodyResPath(typeID);
                if (bodyPath == string.Empty)
                {
                    Debug.LogError("ResMgr:LoadMonsterResList monster body res id 0, typeID:" + typeID);
                    if (callBack != null)
                    {
                        callBack(false);
                    }
                    return;
                }
                XLuaFramework.ResourceManager.GetInstance().LoadAsset <GameObject>(bodyPath, delegate(UnityEngine.Object[] objs) {
                    if (objs.Length > 0 && (objs[0] as GameObject) != null)
                    {
                        GameObject prefab = objs[0] as GameObject;
                        if (prefab != null)
                        {
                            // Debug.Log("load monster ok : "+"MonsterRes_"+typeID);
                            this.prefabDic["MonsterRes_" + typeID] = prefab;
                            count++;
                            if (callBack != null && count == list.Count)
                            {
                                callBack(true);
                            }
                            return;
                        }
                    }
                    Debug.LogError("ResMgr:LoadMonsterResList cannot find prefab in " + bodyPath);
                    if (callBack != null)
                    {
                        callBack(false);
                    }
                });
            }
        }