Exemplo n.º 1
0
    public static void delete(Record record)
    {
        Records history = RecordsManager.GetHistory();

        history.records = history.records.FindAll((obj) => obj.id != record.id);
        PlayerPrefs.SetString("history", JsonUtility.ToJson(history));
    }
Exemplo n.º 2
0
    internal static Records GetReverseHistorySortedByDay()
    {
        Records history = RecordsManager.GetHistory();

        history.records.Sort();
        return(history);
    }
Exemplo n.º 3
0
    public static void save(Record record)
    {
        if (record.id == 0)
        {
            record.id = GetNextId();
        }
        Records history = RecordsManager.GetHistory();

        history.records.Add(record);
        PlayerPrefs.SetString("history", JsonUtility.ToJson(history));
    }
Exemplo n.º 4
0
    public static void update(Record timeRecord)
    {
        Records       history = RecordsManager.GetHistory();
        List <Record> records = history.records.ConvertAll((Record input) =>
        {
            int id = input.id;
            if (id == timeRecord.id)
            {
                return(timeRecord);
            }
            return(input);
        });

        history.records = records;
        RecordsManager.updateHistory(history);
    }
Exemplo n.º 5
0
    internal static Record getLongestSleepRecord()
    {
        Record  longestSleep = null;
        Records records      = RecordsManager.GetHistory();

        foreach (Record record in records.records)
        {
            if (longestSleep == null)
            {
                longestSleep = record;
            }
            else if (getTimeSpan(record) > getTimeSpan(longestSleep))
            {
                longestSleep = record;
            }
        }
        return(longestSleep);
    }
Exemplo n.º 6
0
 public static Record getById(int id)
 {
     return(RecordsManager.GetHistory().records.Find((obj) => obj.id == id));
 }