Example #1
0
    public void Save()
    {
        // save actually
        SaveJSON saveObject = new SaveJSON {
            bestScores = _highscore, bestPlayers = _bestPlayersNames
        };
        string json = JsonUtility.ToJson(saveObject);

        // save to a file
        File.WriteAllText(Application.dataPath + _fileName, json);
    }
Example #2
0
 public void Load()
 {
     if (File.Exists(Application.dataPath + _fileName))
     {
         string   loadString       = File.ReadAllText(Application.dataPath + _fileName);
         SaveJSON loadedSaveObject = JsonUtility.FromJson <SaveJSON>(loadString);
         _highscore        = loadedSaveObject.bestScores;
         _bestPlayersNames = loadedSaveObject.bestPlayers;
     }
     else
     {
         Debug.LogError("File with amount of scores do not exists!");
     }
 }
Example #3
0
    void SaveSpawnPosition()
    {
        GameData myData = new GameData();

        myData.Items.Add(new Data()
        {
            spawnPoint = new Vector3(-4, 2f, 2.89f)
        });
        myData.Items.Add(new Data()
        {
            spawnPoint = new Vector3(-4, 2f, 6.28f)
        });
        SaveJSON.SaveJSONFile(myData);
    }
Example #4
0
        public ICommand ResolveCommand(JObject joCommand)
        {
            ICommand result = null;

            var commandName = JSONUtil.GetCommandName(joCommand);

            if (commandName == null)
            {
                return(null);
            }
            if (commandName == "load-json")
            {
                result = new LoadJSON();
            }
            else if (commandName == "save-json")
            {
                result = new SaveJSON();
            }
            else if (commandName == "prompt")
            {
                result = new PromptCommand();
            }
            else if (commandName == "run-script")
            {
                result = new RunScript();
            }
            else if (commandName == "communicate")
            {
                result = new Communicate();
            }
            else if (commandName == "say")
            {
                result = new Communicate();
            }
            //else if (commandName == "run-rules") { return new RunRules(); }
            else if (commandName == "assert")
            {
                return(new Assert());
            }
            else if (commandName == "store")
            {
                return(new Store());
            }

            return(result);
        }
Example #5
0
    void RecoveryData()
    {
        if (File.Exists(path))
        {
            string json = File.ReadAllText(path);
            Data[] data = JsonHelperItem.FromJson <Data>(json);

            User[] users = new User[1];
            users[0] = new User("Macaco", "*****@*****.**", "nel", DataManager.Profile.MEDIC);

            SaveJSON saveJSON = new SaveJSON(data, users);
            json = JsonHelperItem.ToJson <Data>(data, true);
            string json2 = JsonHelperUser.ToJson <User>(users, true);
            FixJSONSave(json, json2, true);
            //print(json2);

            //dataList = data.OfType<Data>().ToList();
            //FillListMedic(dataList);
        }
        else
        {
            File.WriteAllText(path, "");
        }
    }