Пример #1
0
    static public bool LoadAsset(EFFECT_ID ID, AssetLoader.AssetLoadCallback CallBack, ParamData paramData)
    {
        // id to name
        string AssetsName = GlobalInstanceFunction.Instance.GetAssetsName((int)ID, AssetLoader.EAssetType.ASSET_EFFECT);

        if (!GlobalInstanceFunction.Instance.IsValidName(AssetsName))
        {
            return(false);
        }

        string[]      depFiles = EffectDepedenceData.GetRefAssets(AssetsName);
        EffectLoadReq info     = new EffectLoadReq();

        info.name_     = AssetsName;
        info.callback_ = CallBack;
        info.pdata_    = paramData;
        if (depFiles != null)
        {
            info.status_ = new Dictionary <string, EffectDepLoader.EffectDepStatus>();
            EffectDepLoader.EffectDepStatus[] refStatus = EffectDepLoader.Instance.LoadAtlas(depFiles);
            for (int i = 0; i < depFiles.Length; ++i)
            {
                info.status_.Add(depFiles[i], refStatus[i]);
            }
            if (!LoadCheck(info))
            {
                loadLst.Add(info);
            }
        }
        else
        {
            if (pdRefDic_.ContainsKey(AssetsName))
            {
                if (pdRefDic_[AssetsName].hasBundle)
                {
                    CallBack(pdRefDic_[AssetsName].Open(), paramData);
                }
                else
                {
                    pdRefDic_[AssetsName].Set(CallBack, paramData);
                    AssetLoader.LoadAssetBundle(AssetsName, AssetLoader.EAssetType.ASSET_EFFECT, LoadEffectCallback, paramData);
                }
            }
            else
            {
                EffectBundleRef bundleRef = new EffectBundleRef();
                bundleRef.Set(CallBack, paramData);
                pdRefDic_.Add(AssetsName, bundleRef);
                pdRef4For_.Add(bundleRef);
                AssetLoader.LoadAssetBundle(AssetsName, AssetLoader.EAssetType.ASSET_EFFECT, LoadEffectCallback, paramData);
            }
        }

        return(true);
    }
Пример #2
0
    static bool LoadCheck(EffectLoadReq info)
    {
        bool canLoadUI = true;

        foreach (AtlasLoader.AtlasStatus st in info.status_.Values)
        {
            if (st != AtlasLoader.AtlasStatus.AS_Loaded)
            {
                canLoadUI = false;
                break;
            }
        }
        if (canLoadUI)
        {
            if (pdRefDic_.ContainsKey(info.name_))
            {
                if (pdRefDic_[info.name_].hasBundle)
                {
                    info.callback_(pdRefDic_[info.name_].Open(), info.pdata_);
                }
                else
                {
                    pdRefDic_[info.name_].Set(info.callback_, info.pdata_);
                    //AssetLoader.LoadAssetBundle(info.name_, AssetLoader.EAssetType.ASSET_PLAYER, LoadEffectCallback, info.pdata_);
                }
            }
            else
            {
                EffectBundleRef bundleRef = new EffectBundleRef();
                bundleRef.Set(info.callback_, info.pdata_);
                pdRefDic_.Add(info.name_, bundleRef);
                pdRef4For_.Add(bundleRef);
                AssetLoader.LoadAssetBundle(info.name_, AssetLoader.EAssetType.ASSET_EFFECT, LoadEffectCallback, info.pdata_);
            }
        }
        return(canLoadUI);
    }