コード例 #1
0
ファイル: SaveManagerClass.cs プロジェクト: EvilKot/UTestGame
    //"Keeps the record count and adds a new records only if they exceed the current ones")]
    public void InsertRecordArray(RecordData[] records)
    {
        RecordData[] savedRecords = GetAllRecords();
        RecordData[] allRecords = new RecordData[savedRecords.Length + records.Length];

        for(int i = 0; i<savedRecords.Length;i++)
            allRecords[i] = savedRecords[i];

        for(int i = savedRecords.Length, j=0; i<allRecords.Length; i++, j++)
            allRecords[i] = records[j];

        allRecords = allRecords.OrderByDescending(r => r.Score).ToArray();

        for(int i = 0; i<RecordCount; i++)  //save only first n elements of sorted array
        {
            PlayerPrefs.SetInt("score" + i, allRecords[i].Score);
            PlayerPrefs.SetString("date" + i, allRecords[i].Date);
        }
    }