Пример #1
0
        private static void LoadPrefabObject(PrefabObject o)
        {
            string dllCachePath = Path.Combine(Application.dataPath, "/cache/dll/" + o.Config.i18n.en + o.Guid);
            Dictionary <string, Type> typesInDll = new Dictionary <string, Type>();

            RequestTar request = new RequestTar(o.Resources.Config);

            request.OnFinish += response =>
            {
                string    json      = ((ResponseTar)response).TextData;
                AssetInfo assetInfo = null;

                if (!Helper.LoadAssetInfo(json,
                                          ref assetInfo,
                                          ref _loadCounter,
                                          o))
                {
                    return;
                }

                Helper.LoadResourcesTar(assetInfo, o);

                foreach (string dllName in assetInfo.Assembly)
                {
                    string dllPath = o.Resources.DllPath + "/" + dllName;

                    new RequestTar(dllPath).OnFinish += response1 =>
                    {
                        var byteData = ((ResponseTar)response1).ByteData;

                        LoadAssemby(dllCachePath,
                                    dllName,
                                    ref byteData,
                                    ref typesInDll);
                    };
                }

                Helper.LoadCustomAssetTar(assetInfo,
                                          o,
                                          ref _loadCounter,
                                          typesInDll);
            };

            request.OnError += s => { Helper.ShowErrorLoadObject(o, s); };
        }
Пример #2
0
        public static void LoadScene(int locationId)
        {
            _startLoadingTime = DateTime.Now;

            LocationPrefub location = WorldData.WorldStructure.Locations.GetLocation(locationId);

            if (location == null)
            {
                return;
            }

            string sceneName = location.Name;

            LogManager.GetCurrentClassLogger().Info($"Loading location \"{sceneName}\" from tar file");
            RequestTar requestConfig = new RequestTar(location.Resources.Config);

            requestConfig.OnFinish += responseConfig =>
            {
                SceneData  sceneData  = ((ResponseTar)responseConfig).TextData.JsonDeserialize <SceneData>();
                RequestTar requestTar = new RequestTar(location.Resources.Bundle);

                requestTar.OnFinish += response =>
                {
                    ResponseTar responseTar = (ResponseTar)response;
                    byte[]      bundle      = responseTar.ByteData;

                    RequestLoadSceneFromMemory request =
                        new RequestLoadSceneFromMemory(sceneData.AssetBundleLabel, bundle);

                    request.OnFinish += response1 =>
                    {
                        ResponseAsset responseAsset = (ResponseAsset)response1;
                        string        scenePath     = Path.GetFileNameWithoutExtension(responseAsset.Path);

                        WorldDataListener.Instance.LoadScene(scenePath);
                    };

                    Resources.UnloadUnusedAssets();

                    request.OnError += s => { Helper.ShowErrorLoadScene(); };
                };

                requestTar.OnError += s => { Helper.ShowErrorLoadScene(); };
            };
        }
Пример #3
0
        public static void LoadCustomAssetTar(AssetInfo assetInfo, PrefabObject o, ref GameEntity loadCounter, Dictionary <string, Type> typesInDll)
        {
            string assetName      = assetInfo.AssetName;
            string assetBundleUri = o.Resources.Bundle;

            RequestTar requestAssetData = new RequestTar(assetBundleUri);
            GameEntity entity           = loadCounter;

            requestAssetData.OnFinish += responseData =>
            {
                ResponseTar responseTar = (ResponseTar)responseData;
                var         bundleData  = responseTar.ByteData;

                RequestLoadAssetFromMemory requestAsset =
                    new RequestLoadAssetFromMemory(assetName, bundleData, new object[] { o, assetInfo });
                GameEntity counter = entity;

                requestAsset.OnFinish += response =>
                {
                    CreatePrefabEntity(response, ref counter, o);
                };
            };
        }
Пример #4
0
        public static void CreatePrefabTar(AssetInfo assetInfo, PrefabObject o, ref GameEntity loadCounter)
        {
            string assetName      = assetInfo.AssetName;
            string assetBundleUri = o.Resources.Bundle;


            GameEntity gameEntity    = loadCounter;
            RequestTar requestBundle = new RequestTar(assetBundleUri);

            requestBundle.OnFinish += response =>
            {
                var bundle = ((ResponseTar)response).ByteData;

                RequestLoadAssetFromMemory requestAsset =
                    new RequestLoadAssetFromMemory(assetName, bundle, new object[] { o, assetInfo });
                GameEntity counter = gameEntity;

                requestAsset.OnFinish += response1 => { CreatePrefabEntity(response1, ref counter, o); };

                //ToDo OnError
            };

            //ToDo OnError
        }