コード例 #1
0
 // -------------------------------------------------------------------------
 // GameEnd()
 // ゲームエンド処理
 // -------------------------------------------------------------------------
 string GameEnd(){ // デイリーカリキュラム時のゲームエンド
    
        GameObject obj = GameObject.Find ("SoundMaster");
        if (obj != null) {
            SoundMaster script = obj.GetComponent<SoundMaster> ();
            script.PlaySEClr ();
        }

        if (mode == 13) // 復習モードなら
            return "already";

        var ls = new List<strData> ();          // 既存構造体作成

        // スタンプ用保存データ取得
        string DataWork = PlayerPrefs.GetString (SDM.GetStmpName (), "");

        StringReader reader = new StringReader (DataWork);

        if (ls.Count.Equals (0)) {
            while (reader.Peek () > -1) {
                string line = reader.ReadLine ();
                string[] values = line.Split (',');
                if (values [0] != "")
                    ls.Add (new strData (int.Parse (values [0]), int.Parse (values [1]), int.Parse (values [2]), int.Parse (values [3])));
            }
        }

        int listyear = System.DateTime.Now.Year;
        int listmonth = System.DateTime.Now.Month;
        int listday = System.DateTime.Now.Day;
        string sNow = listyear.ToString() + "," + listmonth.ToString("00") + "," + listday.ToString("00") + "," + mode.ToString("00");

        // 比較

        if (ls.Count < 1) {
            return sNow; // 既存がない場合は最新のみを返す
        }

        string swork = "";

        bool exFlg = false;
        bool nwFlg = false;

        string sExi = ""; // 既存データ保存用
        sNow = "";        // 新規データ保存用

        sExi = ls [0].year.ToString () + "," + ls [0].month.ToString ("00") + "," + ls [0].day.ToString ("00") + ","
           + ls [0].mode.ToString ("00");
        sNow =     listyear.ToString() + "," +     listmonth.ToString("00") + "," +     listday.ToString("00") + ","
           +        mode.ToString("00");
        string str_ex = ls [0].year.ToString() + ls [0].month.ToString("00") + ls [0].day.ToString("00") 
        + ls [0].mode.ToString("00");
        string str_nw =    listyear.ToString() +    listmonth.ToString("00") +    listday.ToString("00")
          +        mode.ToString("00");
        int i_ex = int.Parse (str_ex);
        int i_nw = int.Parse (str_nw);
        int i = 0;

        while (true) {
            if (exFlg) {    // 既存終了時
                swork += sNow;
                break;
            }
            if (nwFlg) {    // 新規終了時
                swork += sExi;
                break;
            }
            if (i_ex < i_nw) {  // 既存が小さい時
                swork += sExi + System.Environment.NewLine;
                if (ls.Count > i + 1) {
                    ++i;
                   sExi = ls [i].year.ToString () + "," + ls [i].month.ToString ("00") + "," + ls [i].day.ToString ("00") + ","
                       + ls [i].mode.ToString ("00");
                    str_ex = ls [i].year.ToString() + ls [i].month.ToString("00") + ls [i].day.ToString("00")
                      + ls [i].mode.ToString("00");
                    i_ex = int.Parse (str_ex);
            }  else {
                exFlg = true;
            }
            continue;
        }

        if (i_ex == i_nw) {
            return "already";
        }
        if (i_ex > i_nw) {  // 新規が小さい時
            swork += sNow + System.Environment.NewLine;
            nwFlg = true;
            continue;
        }
          //Debug.Log ("something wrong");
        return "already";
    }

     //Debug.Log ("Save Successfully");
    return swork;
  }
コード例 #2
0
    // Start is called before the first frame update
    void Start()
    {
        SDM = GetComponent <SaveDataManager>();  // SaveDataManager
        // セーブデータ読み込み
        string DataWork = PlayerPrefs.GetString(SDM.GetStmpName(), "");
        // セーブデータ分解
        StringReader reader = new StringReader(DataWork);
        // 今日のデータ
        int    iyear      = System.DateTime.Now.Year;
        int    imonth     = System.DateTime.Now.Month;
        int    iday       = System.DateTime.Now.Day;
        string todaysdata = iyear.ToString() + "," +
                            imonth.ToString("00") + "," +
                            iday.ToString("00");
        // 家庭科
        string strHomeDate;

        // データ比較
        while (reader.Peek() > -1)
        {
            string line = reader.ReadLine();
            // 読み込み後
            strHomeDate = todaysdata + ",1";
            if (todaysdata + ",01" == line)
            {
                Image img = GameObject.Find("1_Button_Effect/Image_Hanamaru").
                            GetComponent <Image>();
                img.enabled = true;
            }
            if (todaysdata + ",02" == line)
            {
                Image img = GameObject.Find("2_Button_Point/Image_Hanamaru").
                            GetComponent <Image>();
                img.enabled = true;
            }
            if (todaysdata + ",03" == line)
            {
                Image img = GameObject.Find("3_Button_Aim/Image_Hanamaru").
                            GetComponent <Image>();
                img.enabled = true;
            }
            if (todaysdata + ",04" == line)
            {
                Image img = GameObject.Find("4_Button_Contents/Image_Hanamaru").
                            GetComponent <Image>();
                img.enabled = true;
            }
            if (todaysdata + ",05" == line)
            {
                Image img = GameObject.Find("5_Button_Family/Image_Hanamaru").
                            GetComponent <Image>();
                img.enabled = true;
            }
            if (todaysdata + ",06" == line)
            {
                Image img = GameObject.Find("6_Button_Life/Image_Hanamaru").
                            GetComponent <Image>();
                img.enabled = true;
            }
            if (todaysdata + ",07" == line)
            {
                Image img = GameObject.Find("7_Button_Food/Image_Hanamaru").
                            GetComponent <Image>();
                img.enabled = true;
            }
            if (todaysdata + ",08" == line)
            {
                Image img = GameObject.Find("8_Button_Wear/Image_Hanamaru").
                            GetComponent <Image>();
                img.enabled = true;
            }
            if (todaysdata + ",09" == line)
            {
                Image img = GameObject.Find("9_Button_Live/Image_Hanamaru").
                            GetComponent <Image>();
                img.enabled = true;
            }
            if (todaysdata + ",10" == line)
            {
                Image img = GameObject.Find("10_Button_Consume/Image_Hanamaru").
                            GetComponent <Image>();
                img.enabled = true;
            }
            if (todaysdata + ",11" == line)
            {
                Image img = GameObject.Find("11_Button_Guide/Image_Hanamaru").
                            GetComponent <Image>();
                img.enabled = true;
            }
            if (todaysdata + ",12" == line)
            {
                Image img = GameObject.Find("12_Button_Practice/Image_Hanamaru").
                            GetComponent <Image>();
                img.enabled = true;
            }
        }
    }
コード例 #3
0
    /// <summary>カレンダーに日付をセット</summary>

    void SetCalendar()

    {
        // ここでスタンプ削除
        Transform children = stmpCanvas.transform.GetComponentInChildren <Transform>();

        foreach (Transform child in children)
        {
            GameObject.Destroy(child.gameObject);
        }

        int day = 1;

        //今月の1日目

        var first = new DateTime(current.Year, current.Month, day);

        MonthText.text = current.Month.ToString() + "月";

        //来月

        var nextMonth = current.AddMonths(1);

        int nextMonthDay = 1;

        //先月

        var prevMonth = current.AddMonths(-1);

        //先月の場合は後ろから数える。

        int prevMonthDay =

            DateTime.DaysInMonth(prevMonth.Year, prevMonth.Month) - (int)first.DayOfWeek + 1;

        // スタンプ用保存データ取得
        string DataWork = PlayerPrefs.GetString(SDM.GetStmpName(), "");

        StringReader reader = new StringReader(DataWork);

        if (ls.Count.Equals(0))
        {
            while (reader.Peek() > -1)
            {
                string   line   = reader.ReadLine();
                string[] values = line.Split(',');
                if (values [0] != "")
                {
                    ls.Add(new strData(int.Parse(values [0]), int.Parse(values [1]), int.Parse(values [2]), int.Parse(values [3])));
                }
            }
        }

        // For Store Review
        if (StoreReviewFlg == false &&
            ((ls.Count == 10) ||
             (ls.Count > 11 && ls.Count % 30 == 0)))
        {
            AskReview();           // ストアレビューをお願いする。
            StoreReviewFlg = true; // 今回はもう表示しない。
        }

        int cnt = 0;

        foreach (var cDay in Days)
        {
            //今月の1日より前のマスには先月の日にちを入れる。
            if (cDay.index <= (int)first.DayOfWeek)
            {
                cDay.dateValue = new DateTime(prevMonth.Year, prevMonth.Month, prevMonthDay);

                // 最低値をとり、データと比較

                for (cnt = 0; cnt < ls.Count; ++cnt)
                {
                    if (!(DateAdjust(cDay.dateValue, ls [cnt])))
                    {
                        break;
                    }
                }

                int stmpcnt = 0;
                while (true)
                {
                    if (ls.Count > cnt)
                    {
                        if (stmpCheck(prevMonth.Year, prevMonth.Month, prevMonthDay, ls [cnt]).Equals(true))
                        {
                            stmpcnt++;
                            cnt = cnt + 1;
                        }
                        else
                        {
                            break;
                        }
                    }
                    else
                    {
                        break;
                    }
                }
                if (stmpcnt > 0)
                {
                    StmpDisp(cDay.transform.position.x, cDay.transform.position.y, stmpcnt);    // スタンプ描画処理
                }
                prevMonthDay++;
            }

            //今月の最終日より後ろのマスには来月の日にちを入れる。

            else if (day > DateTime.DaysInMonth(current.Year, current.Month))

            {
                cDay.dateValue = new DateTime(nextMonth.Year, nextMonth.Month, nextMonthDay);

                int stmpcnt = 0;

                while (true)
                {
                    if (ls.Count > cnt)
                    {
                        if (stmpCheck(nextMonth.Year, nextMonth.Month, nextMonthDay, ls [cnt]).Equals(true))
                        {
                            stmpcnt++;
                            cnt = cnt + 1;
                        }
                        else
                        {
                            break;
                        }
                    }
                    else
                    {
                        break;
                    }
                }
                if (stmpcnt > 0)
                {
                    StmpDisp(cDay.transform.position.x, cDay.transform.position.y, stmpcnt);
                }
                nextMonthDay++;
            }

            //今月の日にちをマスに入れる。

            else

            {
                cDay.dateValue = new DateTime(current.Year, current.Month, day);

                // 最低値をとり、データと比較

                for (cnt = 0; cnt < ls.Count; ++cnt)
                {
                    if (!(DateAdjust(cDay.dateValue, ls [cnt])))
                    {
                        break;
                    }
                }

                int stmpcnt = 0;

                while (true)
                {
                    if (ls.Count > cnt)
                    {
                        if (stmpCheck(current.Year, current.Month, day, ls [cnt]).Equals(true))
                        {
                            stmpcnt++;
                            cnt = cnt + 1;
                        }
                        else
                        {
                            break;
                        }
                    }
                    else
                    {
                        break;
                    }
                }
                if (stmpcnt > 0)
                {
                    StmpDisp(cDay.transform.position.x, cDay.transform.position.y, stmpcnt);
                }

                day++;
            }
        }
    }