示例#1
0
        public void LocalVersionGetter(Action <DLLVersion> onLocalVersionGetted)
        {
            if (ILRuntimeScriptSetting.LoadDLLFromStreamingAssetsPath)
            {
                var localJsonFile =
                    StreamingAssetPath.CombinePath(
                        "AssetBundles/{0}/hotfix.json".FillFormat(AssetBundleSettings.GetPlatformForAssetBundles(Application.platform)));

                ObservableWWW.Get(localJsonFile).Subscribe(content =>
                {
                    var localVersion = content.FromJson <DLLVersion>();

                    onLocalVersionGetted(localVersion);
                });
            }
            else
            {
                var localJsonFile =
                    PersistentDataPath.CombinePath(
                        "AssetBundles/{0}/hotfix.json".FillFormat(AssetBundleSettings.GetPlatformForAssetBundles(Application.platform)));

                var localVersion = localJsonFile.LoadJson <DLLVersion>();

                onLocalVersionGetted(localVersion);
            }
        }
示例#2
0
 public void LoadARLevel()
 {
     if (File.Exists(PersistentDataPath.Get() + "/ARLevel.idl"))
     {
         string     cipherText = File.ReadAllText(PersistentDataPath.Get() + "/ARLevel.idl");
         string     str        = Encryptor.Decrypt(cipherText);
         JSONObject jSONObject = new JSONObject(str);
         if (jSONObject.HasField("Blocks"))
         {
             Transform blockContainer = ARBindingManager.Instance.BlockContainer;
             blockContainer.DestroyChildrenImmediate();
             List <JSONObject> list = jSONObject.GetField("Blocks").list;
             foreach (JSONObject item in list)
             {
                 string     text          = item.asString("Type", () => string.Empty);
                 int        num           = item.asInt("Size", () => 0);
                 Vector3    localPosition = new Vector3(item.asFloat("X", () => 0f), item.asFloat("Y", () => 0f), item.asFloat("Z", () => 0f));
                 Quaternion rotation      = ARBindingManager.Instance.World.transform.rotation;
                 GameObject gameObject    = GameObjectExtensions.InstantiateFromResources("Blocks/AR/" + text + "Cube_" + num + "x" + num, Vector3.zero, rotation);
                 Transform  transform     = gameObject.transform;
                 Vector3    one           = Vector3.one;
                 Vector3    localScale    = ARBindingManager.Instance.World.transform.localScale;
                 transform.localScale = one * localScale.x;
                 gameObject.transform.SetParent(blockContainer);
                 gameObject.transform.localPosition = localPosition;
             }
         }
     }
 }
示例#3
0
 public void DebugDeleteARLevel()
 {
     if (File.Exists(PersistentDataPath.Get() + "/ARLevel.idl"))
     {
         ARLevel.Value = null;
         File.Delete(PersistentDataPath.Get() + "/ARLevel.idl");
     }
 }
示例#4
0
    private JSONObject LoadToJSON(string fileName)
    {
        string text = File.ReadAllText(PersistentDataPath.Get() + fileName);

        if (text.Contains("FBPlayers"))
        {
            return(JSONObject.Create(text));
        }
        throw new Exception("Could not find FBPlayers in save file");
    }
示例#5
0
 public void Save(FacebookAPIService service)
 {
     try
     {
         File.WriteAllText(PersistentDataPath.Get() + "/fbData.idl", FacebookDataToJSON(service).ToString());
     }
     catch (IOException)
     {
         SaveLoad.ShowDiskFullDialog();
     }
 }
示例#6
0
 private void SaveBackup(BaseData baseData)
 {
     try
     {
         File.WriteAllText(PersistentDataPath.Get() + "/saveGameBak.idl", Encryptor.Encrypt(DataToJSON(baseData).ToString()));
     }
     catch (IOException)
     {
         ShowDiskFullDialog();
     }
 }
示例#7
0
 public void Save(JSONObject json)
 {
     try
     {
         File.WriteAllText(PersistentDataPath.Get() + "/ARLevel.idl", Encryptor.Encrypt(json.ToString()));
     }
     catch (IOException)
     {
         SaveLoad.ShowDiskFullDialog();
     }
 }
示例#8
0
 private void SaveTournamentRuns(JSONObject json)
 {
     try
     {
         File.WriteAllText(PersistentDataPath.Get() + "/saveHelp.idl", Encryptor.Encrypt(json.ToString()));
     }
     catch (IOException)
     {
         SaveLoad.ShowDiskFullDialog();
     }
 }
示例#9
0
 private void LoadFile(FacebookAPIService service, string fileName)
 {
     if (!File.Exists(PersistentDataPath.Get() + fileName))
     {
         CreateEmptyData(service);
     }
     else
     {
         JSONToFacebookData(LoadToJSON(fileName), service);
     }
 }
示例#10
0
 public void WriteCustomInfo(JSONObject customInfo)
 {
     try
     {
         File.WriteAllText(PersistentDataPath.Get() + "/craftcustominfo.txt", Encryptor.Encrypt(customInfo.ToString()));
     }
     catch (IOException)
     {
         SaveLoad.ShowDiskFullDialog();
     }
 }
示例#11
0
 public void DebugSaveTo(BaseData data, string filename, string reason)
 {
     data.LastSaved   = ServerTimeService.NowTicks();
     data.LastSavedBy = reason;
     try
     {
         File.WriteAllText(PersistentDataPath.Get() + filename, Encryptor.Encrypt(DataToJSON(data).ToString()));
     }
     catch (IOException)
     {
         ShowDiskFullDialog();
     }
 }
示例#12
0
    public static bool SaveTexture2DAsPNG(Texture2D tex, string fileName)
    {
        byte[] bytes = tex.EncodeToPNG();
        string path  = PersistentDataPath.Get() + "/" + fileName;

        try
        {
            File.WriteAllBytes(path, bytes);
        }
        catch (Exception ex)
        {
            UnityEngine.Debug.LogWarning("Caught serializationException: " + ex.Message + " while writing PNG data.");
            return(false);
        }
        return(true);
    }
示例#13
0
        IEnumerator DoDownload()
        {
            var savePath = PersistentDataPath.CombinePath("AssetBundles")
                           .CombinePath(AssetBundleSettings.GetPlatformForAssetBundles(Application.platform));

            savePath.DeleteDirIfExists();
            savePath.CreateDirIfNotExists();

            var fileNames = new string[]
            {
                "Android",
                "Android.manifest",
                "Android.manifest.meta",
                "Android.meta",
                "README.en.md",
                "asset_bindle_config.bin",
                "asset_bindle_config.bin.meta",
                "audio",
                "audio.manifest",
                "audio.manifest.meta",
                "audio.meta",
                "hotfix.dll",
                "hotfix.dll.mdb",
                "hotfix.dll.mdb.meta",
                "hotfix.dll.meta",
                "hotfix.json",
                "hotfix.json.meta",
                "shapes",
                "shapes.manifest",
                "shapes.manifest.meta",
                "shapes.meta",
                "uitetrispanel_prefab",
                "uitetrispanel_prefab.manifest",
                "uitetrispanel_prefab.manifest.meta",
                "uitetrispanel_prefab.meta",
            };

            foreach (var fileName in fileNames)
            {
                var www         = new UnityWebRequest(ServerHost + fileName);
                var persistFile = savePath.CombinePath(fileName);

                www.downloadHandler = new DownloadHandlerFile(persistFile);
                yield return(www.SendWebRequest());
            }
        }
示例#14
0
 private void LoadARLevel(string fileName)
 {
     if (File.Exists(PersistentDataPath.Get() + fileName))
     {
         string     cipherText = File.ReadAllText(PersistentDataPath.Get() + "/ARLevel.idl");
         string     str        = Encryptor.Decrypt(cipherText);
         JSONObject jSONObject = new JSONObject(str);
         int        num        = jSONObject.asInt("Amount", () => 0);
         if (num < 30 || num > 500)
         {
             ARLevel.Value = null;
         }
         else if (jSONObject.HasField("Blocks"))
         {
             List <JSONObject> list = jSONObject.GetField("Blocks").list;
             ARLevel.Value = list;
         }
     }
 }
示例#15
0
    private JSONObject LoadToJSON(string fileName)
    {
        string text  = File.ReadAllText(PersistentDataPath.Get() + fileName);
        string text2 = Encryptor.Decrypt(text);

        if (text2.Contains("PlayerId"))
        {
            return(JSONObject.Create(text2));
        }
        TrackLoadingError(GetPlayerId(text2), new Dictionary <string, object>
        {
            {
                "encrypted",
                text
            },
            {
                "decrypted",
                text2
            }
        });
        throw new Exception("Could not find PlayerId in save file");
    }
示例#16
0
 private void LoadFile(BaseData data, string fileName, bool shouldSaveBackup, Action <BaseData> funcLoadDefault)
 {
     if (!File.Exists(PersistentDataPath.Get() + fileName))
     {
         funcLoadDefault(data);
     }
     else
     {
         try
         {
             JSONToData(LoadToJSON(fileName), data);
             if (shouldSaveBackup)
             {
                 SaveBackup(data);
             }
         }
         catch (Exception)
         {
             funcLoadDefault(data);
         }
     }
 }
示例#17
0
    public static Texture2D LoadPNGAsTexture2D(string fileName, int width, int height)
    {
        Texture2D texture2D = null;
        string    path      = PersistentDataPath.Get() + "/" + fileName;

        if (File.Exists(path))
        {
            byte[] data;
            try
            {
                data = File.ReadAllBytes(path);
            }
            catch (Exception ex)
            {
                UnityEngine.Debug.LogWarning("Caught serializationException: " + ex.Message + " while reading PNG file.");
                return(texture2D);
            }
            texture2D = new Texture2D(width, height);
            texture2D.LoadImage(data);
        }
        return(texture2D);
    }
示例#18
0
    public bool FileExists(string fileName)
    {
        string path = PersistentDataPath.Get() + "/" + fileName;

        return(File.Exists(path));
    }
示例#19
0
 private string GetFilePath(string key)
 {
     return(PersistentDataPath.Get() + "/" + baseDir + "/" + MakeValidFileName(key));
 }