Exemple #1
0
    private IEnumerator LoadDependenciesAsync(XSheet.XPack pack)
    {
        for (int i = 0; i < pack.dependencies.Length; i++)
        {
            XAssetBundleInfo bundleInfo = GetAssetBundleInfo(pack.dependencies[i]);
            if (bundleInfo != null)
            {
                if (!bundleInfo.isDone)
                {
                    XCoroutine.Run(LoadAssetBundleAsync(bundleInfo, false));
                }

                bundleInfo.AddDepended(pack.name);
            }
        }
        for (int i = 0; i < pack.dependencies.Length; i++)
        {
            XAssetBundleInfo bundleInfo = GetAssetBundleInfo(pack.dependencies[i]);
            if (bundleInfo != null)
            {
                while (bundleInfo.isLoading)
                {
                    yield return(null);
                }
            }
        }
    }
Exemple #2
0
    public static void GenerateBulletAsync(bool isPvp, string path, Vector3 position, Vector3 dest, XBulletProperty property,
                                           System.Func <XBulletComponent, Transform, bool> callback, Transform[] hitTargets, System.Action <XBulletComponent> loadDone)
    {
        XCoroutine.Run(Instance.GetBullet(path, delegate(XBulletComponent bullet) {
            if (bullet != null)
            {
                bullet.transform.position = position;
                bullet.transform.rotation = Quaternion.identity;
                if (position.x >= dest.x)
                {
                    bullet.transform.localEulerAngles = new Vector3(0, 180, 0);
                }

                if (isPvp)
                {
                    property.time = Mathf.RoundToInt(Vector3.Distance(position, dest) / property.speed * 1000) * 0.001f;
                }

                bullet.Fire(dest, property, hitTargets, callback);
            }

            if (loadDone != null)
            {
                loadDone(bullet);
            }
        }));
    }
Exemple #3
0
    /// <summary>
    ///
    /// </summary>
    void Reinit()
    {
        XCoroutine.StopAll();

        DG.Tweening.DOTween.KillAll(false);

        XLanguage.Reinit();
    }
Exemple #4
0
    public static void GenerateAsync(GameObject effectPrefab, float time, System.Action <XEffectComponent> callback)
    {
        XCoroutine.Run(Instance.GetEffect(effectPrefab, delegate(XEffectCache effectCache, XEffectComponent effect) {
            if (effect != null)
            {
                effect.Initialize(effect.gameObject, effectCache.prefab, time);
            }

            if (callback != null)
            {
                callback(effect);
            }
        }));
    }
Exemple #5
0
    private void DoGenerateAsync(string effectPath, System.Action <XEffectCache, XEffectComponent> callback)
    {
        XEffectCache effectCache = null;

        TryGetEffectCache(effectPath, out effectCache);

        if (effectCache != null && !effectCache.loading)
        {
            callback(effectCache, GenerateEffect(effectPath, effectCache));
        }
        else
        {
            XCoroutine.Run(GetEffect(effectPath, callback));
        }
    }
Exemple #6
0
    /// <summary>
    ///
    /// </summary>
    /// <param name="bundleInfo"></param>
    /// <param name="loadDependence"></param>
    /// <returns></returns>
    private IEnumerator LoadAssetBundleAsync(XAssetBundleInfo bundleInfo, bool loadDependence = true)
    {
        while (bundleInfo.isLoading)
        {
            yield return(null);
        }

        if (bundleInfo.isDone)
        {
            yield break;
        }

        GLog.Log("XBundleManager.LoadAssetBundleAsync {0}", bundleInfo.url);

        bundleInfo.isLoading = true;
        if (loadDependence)
        {
            yield return(XCoroutine.Run(LoadDependenciesAsync(bundleInfo.pack)));
        }

        string bundleName = bundleInfo.pack.name;
        AssetBundleCreateRequest loader = AssetBundle.LoadFromFileAsync(bundleInfo.url);

        yield return(loader);

        if (!loader.isDone)
        {
            bundleInfo.isLoading = false;
            GLog.LogError("XBundleManager.LoadAssetBundle can't async load bundle: {0} reason: {1}",
                          bundleName, "NOT FOUND!");
        }
        else
        {
            bundleInfo.isLoading = false;
            if (loader.assetBundle != null)
            {
                bundleInfo.bundle = loader.assetBundle;
                bundleInfo.isDone = true;
                GLog.Log("XBundleManager.LoadAssetBundle async load done bundle: {0}", bundleName);
            }
            else
            {
                GLog.LogError("AssetBundleManager.LoadAssetBundle can't async load bundle: {0}", bundleName);
            }
        }
    }
Exemple #7
0
    /// <summary>
    ///
    /// </summary>
    /// <param name="info"></param>
    /// <returns></returns>
    private IEnumerator DoLoadSceneAsync(XSheet.XScene info)
    {
        XAssetBundleInfo bundleInfo = GetAssetBundleInfo(info.bundleName);

        if (!bundleInfo.isDone)
        {
            yield return(XCoroutine.Run(LoadAssetBundleAsync(bundleInfo)));
        }

        if (bundleInfo.isDone)
        {
            bundleInfo.IncRef(Time.time);

            yield return(SceneManager.LoadSceneAsync(info.name));

            bundleInfo.DecRef();
        }
    }
Exemple #8
0
    /// <summary>
    ///
    /// </summary>
    /// <param name="info"></param>
    /// <param name="type"></param>
    /// <param name="callback"></param>
    /// <returns></returns>
    public IEnumerator DoLoadAssetAsync(XSheet.XAssetInfo info, System.Type type, System.Action <Object> callback)
    {
        XAssetBundleInfo bundleInfo = GetAssetBundleInfo(info.bundleName);

        if (!bundleInfo.isDone)
        {
            yield return(XCoroutine.Run(LoadAssetBundleAsync(bundleInfo)));
        }

        if (bundleInfo.isDone)
        {
            bundleInfo.IncRef(Time.time);

            AssetBundleRequest request = null;
            Object             obj     = null;
            if (type == typeof(XBufferAsset))
            {
                request = bundleInfo.bundle.LoadAssetAsync <TextAsset>(System.IO.Path.Combine(assetBasePath, info.fullName));
                yield return(request);

                XBufferAsset asset = ScriptableObject.CreateInstance <XBufferAsset>();
                asset.init((TextAsset)request.asset);
                obj = asset;
            }
            else
            {
                request = bundleInfo.bundle.LoadAssetAsync(System.IO.Path.Combine(assetBasePath, info.fullName), type);
                yield return(request);

                obj = request.asset;
            }

            bundleInfo.DecRef();

            callback(obj);
        }
    }
Exemple #9
0
 public static IEnumerator DoUpdate(Action <Stage, float, string> progressCallback)
 {
     yield return(XCoroutine.Run(XRes.Initialize(progressCallback)));
 }
Exemple #10
0
 private static Coroutine StartCoroutine(IEnumerator em)
 {
     return(XCoroutine.Run(em));
 }
Exemple #11
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="info"></param>
 /// <returns></returns>
 public Coroutine LoadSceneAsync(XSheet.XScene info)
 {
     return(XCoroutine.Run(DoLoadSceneAsync(info)));
 }
Exemple #12
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="info"></param>
 /// <param name="type"></param>
 /// <param name="callback"></param>
 /// <returns></returns>
 public Coroutine LoadAssetAsync(XSheet.XAssetInfo info, System.Type type, System.Action <Object> callback)
 {
     return(XCoroutine.Run(DoLoadAssetAsync(info, type, callback)));
 }
Exemple #13
0
 public void PreloadBulletPrefabs(string[] resList, System.Action <bool> callback)
 {
     XCoroutine.Run(DoPreloadBulletPrefabs(resList, callback));
 }
Exemple #14
0
 /// <summary>
 /// Loads the scene async.
 /// </summary>
 /// <returns>The scene async.</returns>
 /// <param name="name">Name.</param>
 /// <param name="callback">Callback.</param>
 public static Coroutine     LoadSceneAsync(string name, System.Action <bool> callback)
 {
     XBundleManager.Instance.ReleaseSceneCachedBundleOnSceneSwitch();
     return(XCoroutine.Run(DoLoadSceneAsync(name, callback)));
 }