Esempio n. 1
0
 private void DeserializeScore()
 {
     if (File.Exists(m_saveFilePath))
     {
         m_lastGameScore = JsonUtility.FromJson <SerializableScores>(File.ReadAllText(m_saveFilePath));
     }
 }
Esempio n. 2
0
    public SerializableScores AsSerializable()
    {
        SerializableScores ss = new SerializableScores();

        ss.scoresArray = this.ScoresList.ToArray();

        return(ss);
    }
Esempio n. 3
0
    private void SerializeScore()
    {
        SerializableScores s = new SerializableScores();

        s.m_score       = m_currentGameScore;
        s.m_elapsedTime = m_elapsedTime;
        s.m_shotNumber  = m_shotNumber;

        string jsonScore = JsonUtility.ToJson(s);

        if (!File.Exists(m_saveFilePath))
        {
            File.Create(m_saveFilePath).Dispose();
        }

        File.WriteAllText(m_saveFilePath, jsonScore);
    }
Esempio n. 4
0
    private void Awake()
    {
        if (m_instance == null)     //first opening of menu
        {
            m_instance = this;
            DontDestroyOnLoad(this);
        }
        else                        //another scene is loaded
        {
            if (m_instance != this) //we only want to keep the original object
            {
                DestroyImmediate(this.gameObject);
            }
        }

        //lazy init here
        m_saveFilePath  = Application.dataPath + "/lastGameSave.json";
        m_lastGameScore = null;
    }
Esempio n. 5
0
 public void Set(SerializableScores ss)
 {
     this.ScoresList = new List <float>(ss.scoresArray);
 }
Esempio n. 6
0
 public Scores(SerializableScores ss)
 {
     Set(ss);
 }
Esempio n. 7
0
    public Scores(int numScores)
    {
        SerializableScores ss = new SerializableScores(numScores);

        Set(ss);
    }