コード例 #1
0
    //------------------------------------------------------------------------------------------
    // InitializeScore
    //------------------------------------------------------------------------------------------
    public void InitializeScore()
    {
        var data = new ScoreUtility.RankingData();

        m_score[0] = data.first;
        m_score[1] = data.second;
        m_score[2] = data.third;

        m_year[0] = data.yearFirst;
        m_year[1] = data.yearSecond;
        m_year[2] = data.yearThird;

        m_month[0] = data.monthFirst;
        m_month[1] = data.monthSecond;
        m_month[2] = data.monthThird;

        m_day[0] = data.dayFirst;
        m_day[1] = data.daySecond;
        m_day[2] = data.dayThird;

        // JSONにシリアライズ
        var json = JsonUtility.ToJson(data);
        // Assetsフォルダに保存する
        var path   = Application.dataPath + Define.SAVE_FILE_PATH;
        var writer = new StreamWriter(path, false);

        writer.WriteLine(json);
        writer.Flush();
        writer.Close();

        for (int i = 0; i < Define.RANKING_LIST_END; i++)
        {
            string date = m_year[i].ToString() + " 年\n" + m_month[i].ToString() + " 月    " + m_day[i].ToString() + " 日";
            m_scoreText[i].text = m_score[i].ToString();
            m_dateText[i].text  = date;
        }
    }
コード例 #2
0
    //------------------------------------------------------------------------------------------
    // RankingCheck
    //------------------------------------------------------------------------------------------
    public void RankingCheck()
    {
        var      data    = new ScoreUtility.RankingData();
        DateTime dateNow = System.DateTime.Now;

        data.first    = m_scoreData[0];
        data.second   = m_scoreData[1];
        data.third    = m_scoreData[2];
        data.newScore = m_score;

        data.yearFirst  = m_year[0];
        data.yearSecond = m_year[1];
        data.yearThird  = m_year[2];

        data.monthFirst  = m_month[0];
        data.monthSecond = m_month[1];
        data.monthThird  = m_month[2];

        data.dayFirst  = m_day[0];
        data.daySecond = m_day[1];
        data.dayThird  = m_day[2];

        if (data.first <= m_score)
        {
            data.third  = data.second;
            data.second = data.first;
            data.first  = m_score;

            data.yearThird  = data.yearSecond;
            data.yearSecond = data.yearFirst;
            data.yearFirst  = dateNow.Year;

            data.monthThird  = data.monthSecond;
            data.monthSecond = data.monthFirst;
            data.monthFirst  = dateNow.Month;

            data.dayThird  = data.daySecond;
            data.daySecond = data.dayFirst;
            data.dayFirst  = dateNow.Day;
        }
        if (data.second <= m_score && data.first > m_score)
        {
            data.third  = data.second;
            data.second = m_score;

            data.yearThird  = data.yearSecond;
            data.yearSecond = dateNow.Year;

            data.monthThird  = data.monthSecond;
            data.monthSecond = dateNow.Month;

            data.dayThird  = data.daySecond;
            data.daySecond = dateNow.Day;
        }
        if (data.third <= m_score && data.second > m_score)
        {
            data.third = m_score;

            data.yearThird = dateNow.Year;

            data.monthThird = dateNow.Month;

            data.dayThird = dateNow.Day;
        }

        // JSONにシリアライズ
        var json = JsonUtility.ToJson(data);
        // Assetsフォルダに保存する
        var path   = Application.dataPath + Define.SAVE_FILE_PATH;
        var writer = new StreamWriter(path, false);

        writer.WriteLine(json);
        writer.Flush();
        writer.Close();
    }