コード例 #1
0
    public static ScoreboardData LoadScoreboard()
    {
        string path = Application.persistentDataPath + "/scoreboard.xssoftware";

        if (File.Exists(path))
        {
            BinaryFormatter formatter = new BinaryFormatter();
            FileStream      stream    = new FileStream(path, FileMode.Open);

            if (stream.Length != 0)
            {
                ScoreboardData data = formatter.Deserialize(stream) as ScoreboardData;
                stream.Close();

                return(data);
            }
            else
            {
                Debug.Log("Save file not found " + path);
                return(null);
            }
        }
        else
        {
            Debug.Log("Save file not found " + path);
            return(null);
        }
    }
コード例 #2
0
    public static void SaveScoreboard(GameManager gameManager)
    {
        BinaryFormatter formatter = new BinaryFormatter();
        string          path      = Application.persistentDataPath + "/scoreboard.xssoftware";
        FileStream      stream    = new FileStream(path, FileMode.Create);

        ScoreboardData data = new ScoreboardData(gameManager);

        formatter.Serialize(stream, data);
        stream.Close();
    }
コード例 #3
0
 public async Task SetScoreboard(ScoreboardData scoreboardData)
 {
     RaiseEvent(new ScoreboardChanged
     {
         CurrentTime  = scoreboardData.CurrentTime,
         CurrentScore =
             scoreboardData.CurrentScore,
         ScoresByPeriod = scoreboardData.ScoresByPeriod
     });
     await ConfirmEvents();
 }
コード例 #4
0
    public void LoadScoreboard()
    {
        ScoreboardData data = SaveSystem.LoadScoreboard();

        if (data != null)
        {
            for (int i = 0; i < scoreboardSize; i++)
            {
                scoreboard[i] = data.scoreboard[i];
            }
        }
    }
コード例 #5
0
ファイル: LocalScoreboard.cs プロジェクト: misusi/hyperpong
    void WriteData()
    {
        IFormatter binFormatter = new BinaryFormatter();

        try{
            Stream wFile = new FileStream(filepath, FileMode.OpenOrCreate, FileAccess.Write);
            binFormatter.Serialize(wFile, myData);
            Debug.Log("Writing to filepath '" + filepath + "'");
            wFile.Close();
        }
        catch (IOException exc) {
            Debug.Log("Error writing file");
            Debug.LogException(exc);
        }
        catch (SerializationException exc) {
            Debug.Log("Error serializing data");
            Debug.LogException(exc);
            myData = new ScoreboardData();
        }
    }
コード例 #6
0
ファイル: LocalScoreboard.cs プロジェクト: misusi/hyperpong
    void ReadData()
    {
        IFormatter binFormatter = new BinaryFormatter();

        try{
            Stream rFile = new FileStream(filepath, FileMode.Open, FileAccess.Read);
            myData = binFormatter.Deserialize(rFile) as ScoreboardData;
            Debug.Log("Reading from filepath '" + filepath + "'");
            rFile.Close();
        }
        catch (IOException exc) {
            Debug.Log("Error writing file");
            Debug.LogException(exc);
            myData = new ScoreboardData();
        }
        catch (SerializationException exc) {
            Debug.Log("Error serializing data");
            Debug.LogException(exc);
            myData = new ScoreboardData();
        }
    }