Esempio n. 1
0
    //Returns a blank state template for writing to disk
    public CharMemory LoadBlankFile()
    {
        //load in the character list from disk
        string[] charArrayRaw = (Resources.Load("DefaultList") as TextAsset).ToString().Split('\n');

        List <string> rawArray = new List <string>();

        foreach (string item in charArrayRaw)
        {
            if (item.Length > 0 && item != "\r")               // Remove all empty lines
            {
                rawArray.Add(item.Trim((char)13));             //remove stupid invisible characters
            }
        }

        //Put characters and romanji into corresponding vars.
        CharMemory chrm = new CharMemory(rawArray.Count);

        for (int i = 0; i < rawArray.Count; i++)
        {
            string[] cell = rawArray[i].Split(';');
            chrm.hirag[i].character = cell[0];
            chrm.kata[i].character  = cell[1];
            chrm.romanji[i]         = cell[2];
        }

        return(chrm);
    }
Esempio n. 2
0
    public void ResetStats()
    {
        CharMemory newMem = MenuController._singleton.LoadBlankFile();
        string     tosave = JsonUtility.ToJson(newMem);

        System.IO.File.WriteAllText(Application.persistentDataPath + "/saves.json", tosave);

        MenuController._singleton.charMemory = newMem;
    }
Esempio n. 3
0
    //Checks if save file exists. if not, create one fresh file.
    public void LoadSaveFile()
    {
        if (!System.IO.File.Exists(Application.persistentDataPath + "/saves.json"))
        {
            //Create new save file format with katakana + hiragana, then write into the file.
            CharMemory newItem = LoadBlankFile();
            string     tosave  = JsonUtility.ToJson(newItem);
            System.IO.File.WriteAllText(Application.persistentDataPath + "/saves.json", tosave);

            //also sun bian load into charItems
            charMemory = newItem;
        }
        else
        {
            charMemory = JsonUtility.FromJson <CharMemory>(System.IO.File.ReadAllText(Application.persistentDataPath + "/saves.json"));
        }
    }