Ejemplo n.º 1
0
        internal static void LoadFile()
        {
            baseSavePath = baseSavePath.Replace("&DataPath&", Application.dataPath);
            //load file stuffjes
            for (int q = 0; q < (int)SavePaths.AmountOfFileTypes; q++)
            {
                jsonstring = ReadAllText(baseSavePath + (q == 0 ? GetPath(SavePaths.Base) : q == 1 ? GetPath(SavePaths.Player) : GetPath(SavePaths.Settings)) + fileExtention);

                try
                {
                    data = JsonMapper.ToObject(jsonstring);
                    continue;
                }
                catch { }

                try
                {
                    for (int i = 0; i < data.Count; i++)
                    {
                        try
                        {
                            QueueValueObject queuevalobj = new QueueValueObject(GetPathEnum(data[i]["specialPath"].ToString()), data[i]["variableName"].ToString(), (object)data[i]["value"]);
                            continue;
                        }
                        catch
                        {
                            Debug.Log("Save value failed to load");
                        }
                        try
                        {
                            QueueValueObject queuevalobj = new QueueValueObject(GetPathEnum(data[i]["specialPath"].ToString()), data[i]["variableName"].ToString(), (object)data[i]["value"]);
                            hashtable.Add(queuevalobj.variableName, queuevalobj);
                        }
                        catch
                        {
                            Debug.Log("Save value already loaded");
                        }
                    }
                }
                catch { }
            }
        }
Ejemplo n.º 2
0
 /// <summary>
 /// PAS GOED OP, OP HET MOMENT WORDEN DEZE VALUES NOG NIET NAAR EEN BESTAND GESCHREVEN
 /// </summary>
 /// <typeparam name="T"></typeparam>
 /// <param name="variableName"></param>
 /// <param name="value"></param>
 internal static void SaveValue <T>(SavePaths path, string variableName, T value)
 {
     if (!saveFileLoaded)
     {
         LoadFile();
     }
     try
     {
         hashtable.Add(variableName, new QueueValueObject(path, variableName, value));
     }
     catch (ArgumentException e)
     {
         hashtable[variableName] = new QueueValueObject(path, variableName, value);
         Debug.Log(e.ToString());
     }
     WriteTheFile(new List <QueueValueObject>()
     {
         hashtable[variableName]
     });
     Debug.Log(hashtable[variableName]);
 }
Ejemplo n.º 3
0
        internal static void QueueSaveValue <T>(SavePaths path, string variableName, T value)
        {
            bool hasToOverwrite = false;
            int  overwritenum   = 0;

            for (int i = 0; i < queue.Count; i++)
            {
                if (queue[i].variableName == variableName)
                {
                    hasToOverwrite = true;
                    overwritenum   = i;
                    break;
                }
            }
            if (hasToOverwrite)
            {
                queue[overwritenum] = new QueueValueObject(path, variableName, value);
            }
            else
            {
                queue.Add(new QueueValueObject(path, variableName, value));
            }
        }