// 读取流水账 public void ReadKeyinKeoutRecords() { if (keyinKeoutRecords.Count > 0) keyinKeoutRecords.Clear(); for (int i = 0; i < 20; ++i) { string time = PlayerPrefs.GetString("daybook_time" + i); if (string.IsNullOrEmpty(time)) break; KeyinKeoutRecord record = new KeyinKeoutRecord(); record.time = time; record.keyin = PlayerPrefs.GetInt("daybook_keyin" + i); record.keout = PlayerPrefs.GetInt("daybook_keout" + i); record.toubi = PlayerPrefs.GetInt("daybook_toubi" + i); record.tuibi = PlayerPrefs.GetInt("daybook_tuibi" + i); record.card = PlayerPrefs.GetInt("daybook_card" + i); keyinKeoutRecords.Enqueue(record); } }
public void AppendKeyinKeoutRecords(int keyin, int keout, int receiveCoin, int payCoin, int card) { KeyinKeoutRecord record = new KeyinKeoutRecord(); record.time = Utils.GetSystemTime(); record.keyin = keyin; record.keout = keout; record.toubi = receiveCoin; record.tuibi = payCoin; record.card = card; keyinKeoutRecords.Enqueue(record); while (keyinKeoutRecords.Count > 20) keyinKeoutRecords.Dequeue(); int count = 0; foreach (KeyinKeoutRecord item in keyinKeoutRecords) { PlayerPrefs.SetString("daybook_time" + count, item.time); PlayerPrefs.SetInt("daybook_keyin" + count, item.keyin); PlayerPrefs.SetInt("daybook_keout" + count, item.keout); PlayerPrefs.SetInt("daybook_toubi" + count, item.toubi); PlayerPrefs.SetInt("daybook_tuibi" + count, item.tuibi); PlayerPrefs.SetInt("daybook_card" + count, item.card); ++count; } PlayerPrefs.Save(); }