Beispiel #1
0
    void DataSave()
    {
        try
        {
            Dictionary <string, string> dicJson = new Dictionary <string, string>();
            for (int i = 0; i < StaticMng.Instance._MaximumChapter; i++)
            {
                for (int j = 0; j < StaticMng.Instance._MaximumSector[i]; j++)
                {
                    dicJson.Add("sp_" + i.ToString() + "_" + j.ToString(), StaticMng.Instance._StagePeakCount[i, j].ToString());
                }
            }
            string spdata = JSon.Write(dicJson);
            Dictionary <string, string> achivejson = new Dictionary <string, string>();
            for (int i = 0; i < StaticMng.Instance._MaxAchievementCount; i++)
            {
                achivejson.Add("Achi_NowVal" + i.ToString(), StaticMng.Instance._Achive_NowValue[i].ToString());
                achivejson.Add("Achi_NowInfo" + i.ToString(), StaticMng.Instance._Achive_ClearCheck[i].ToString());
            }
            string achivedata = JSon.Write(achivejson);

            int tempvolume;
            if (StaticMng.Instance._Option_Volume_Bool)
            {
                tempvolume = 1;
            }
            else
            {
                tempvolume = 0;
            }

            string q2 = "update BuskingTest set UserName = '******',Level=" + StaticMng.Instance._Player_Level.ToString() + ",NowExp=" + StaticMng.Instance._Player_NowExp.ToString() + ",Gold=" + StaticMng.Instance._Gold.ToString() + ",DrumLevel = " + StaticMng.Instance._DrumTowerLevel.ToString() + ",GuitarLevel=" + StaticMng.Instance._GuitarTowerLevel.ToString() + ",BassLevel=" + StaticMng.Instance._BassTowerLevel.ToString() + ",KeyBoardLevel=" + StaticMng.Instance._KeyBoardTowerLevel.ToString() + ",Volume=" + tempvolume.ToString() + ",UnlockChapter=" + StaticMng.Instance._UnLock_Chapter.ToString() + ",UnlockSector_1=" + StaticMng.Instance._UnLock_Sector[0].ToString() + ",UnlockSector_2=" + StaticMng.Instance._UnLock_Sector[1].ToString() + ",UnlockSector_3=" + StaticMng.Instance._UnLock_Sector[2].ToString() + ",UnlockSector_4=" + StaticMng.Instance._UnLock_Sector[3].ToString() + ",StagePeak ='" + spdata.ToString() + "',Achievement = '" + achivedata + "',Gem = " + StaticMng.Instance._Gem.ToString() + ",GuitarRank = " + StaticMng.Instance._GuitarTowerRank.ToString() + ",DrumRank = " + StaticMng.Instance._DrumTowerRank.ToString() + ",BassRank = " + StaticMng.Instance._BassTowerRank.ToString() + ",KeyBoardRank = " + StaticMng.Instance._KeyBoardTowerRank.ToString() + ",InfinityGameScore = " + StaticMng.Instance._InfinityGameScore.ToString() + ",IdentityNumber = " + StaticMng.Instance._InfinityScoreIdentity.ToString() + ",InfinityFastValue = " + StaticMng.Instance._Infinity_FastValue.ToString() + " where id='" + StaticMng.Instance._UserId + "';";

            conn.Open();
            MySqlCommand    cmd2    = new MySqlCommand(q2, conn);
            MySqlDataReader reader2 = cmd2.ExecuteReader();
            //Debug.Log("Save");
            conn.Close();
            DataLoad();
        }
        catch (Exception ex)
        {
            Debug.Log(ex);
            conn.Close();
        }
    }
Beispiel #2
0
    void DataInit()
    {
        for (int i = 0; i < StaticMng.Instance._MaxAchievementCount; i++)
        {
            StaticMng.Instance._Achive_ClearCheck.Add(0);
            StaticMng.Instance._Achive_NowValue.Add(0);
        }
        try
        {
            Dictionary <string, string> dicJson = new Dictionary <string, string>();
            for (int i = 0; i < StaticMng.Instance._MaximumChapter; i++)
            {
                for (int j = 0; j < StaticMng.Instance._MaximumSector[i]; j++)
                {
                    dicJson.Add("sp_" + i.ToString() + "_" + j.ToString(), "0");
                }
            }
            string spdata = JSon.Write(dicJson);

            Dictionary <string, string> achivejson = new Dictionary <string, string>();
            for (int i = 0; i < StaticMng.Instance._MaxAchievementCount; i++)
            {
                achivejson.Add("Achi_NowVal" + i.ToString(), "0");
                achivejson.Add("Achi_NowInfo" + i.ToString(), "0");
            }
            string achivedata = JSon.Write(achivejson);

            string q2 = "update BuskingTest set UserName = '******',Level=" + "1" + ",NowExp=" + "0" + ",Gold=" + "0" + ",DrumLevel = " + "1" + ",GuitarLevel=" + "1" + ",BassLevel=" + "1" + ",KeyBoardLevel=" + "1" + ",Volume=" + "1" + ",UnlockChapter=" + "1" + ",UnlockSector_1=" + "1" + ",UnlockSector_2=" + "0" + ",UnlockSector_3=" + "0" + ",UnlockSector_4=" + "0" + ",StagePeak ='" + spdata.ToString() + "',Achievement = '" + achivedata + "',Gem = " + "0" + ",GuitarRank = " + "3" + ",DrumRank = " + "3" + ",BassRank = " + "3" + ",KeyBoardRank = " + "3" + ",InfinityGameScore = " + "0" + ",IdentityNumber = " + "0" + ",InfinityFastValue = " + "1" + " where id='" + StaticMng.Instance._UserId + "';";


            conn.Open();

            MySqlCommand    cmd    = new MySqlCommand(q2, conn);
            MySqlDataReader reader = cmd.ExecuteReader();
            conn.Close();

            DataLoad();
        }
        catch (Exception ex)
        {
            Debug.Log(ex);
        }
        try
        {
            string spdata;
            string achidata;
            string q =
                "select Level,NowExp,Gold,UserName,DrumLevel,GuitarLevel,BassLevel,KeyBoardLevel,Volume,UnlockChapter,UnlockSector_1,UnlockSector_2, UnlockSector_3, UnlockSector_4,StagePeak,Achievement,Gem,GuitarRank,DrumRank,BassRank,KeyBoardRank,InfinityGameScore,IdentityNumber,InfinityFastValue from BuskingTest where ID = '" + StaticMng.Instance._UserId + "' and PW = PASSWORD('" + StaticMng.Instance._UserPW + "');";

            try
            {
                bool         getdata = false;
                MySqlCommand cmd     = new MySqlCommand(q, conn);
                conn.Open();
                MySqlDataReader reader = cmd.ExecuteReader();
                while (reader.Read())
                {
                    getdata = true;
                    StaticMng.Instance._Player_Level       = int.Parse(reader[0].ToString());
                    StaticMng.Instance._Player_NowExp      = int.Parse(reader[1].ToString());
                    StaticMng.Instance._Gold               = int.Parse(reader[2].ToString());
                    StaticMng.Instance._UserName           = reader[3].ToString();
                    StaticMng.Instance._DrumTowerLevel     = int.Parse(reader[4].ToString());
                    StaticMng.Instance._GuitarTowerLevel   = int.Parse(reader[5].ToString());
                    StaticMng.Instance._BassTowerLevel     = int.Parse(reader[6].ToString());
                    StaticMng.Instance._KeyBoardTowerLevel = int.Parse(reader[7].ToString());
                    StaticMng.Instance._Option_Volume      = float.Parse(reader[8].ToString());
                    if (StaticMng.Instance._Option_Volume == 1)
                    {
                        StaticMng.Instance._Option_Volume_Bool = true;
                    }
                    else
                    {
                        StaticMng.Instance._Option_Volume_Bool = false;
                    }
                    StaticMng.Instance._UnLock_Chapter   = int.Parse(reader[9].ToString());
                    StaticMng.Instance._UnLock_Sector[0] = int.Parse(reader[10].ToString());
                    StaticMng.Instance._UnLock_Sector[1] = int.Parse(reader[11].ToString());
                    StaticMng.Instance._UnLock_Sector[2] = int.Parse(reader[12].ToString());
                    StaticMng.Instance._UnLock_Sector[3] = int.Parse(reader[13].ToString());
                    spdata   = reader[14].ToString();
                    achidata = reader[15].ToString();
                    StaticMng.Instance._Gem                   = int.Parse(reader[16].ToString());
                    StaticMng.Instance._GuitarTowerRank       = int.Parse(reader[17].ToString());
                    StaticMng.Instance._DrumTowerRank         = int.Parse(reader[18].ToString());
                    StaticMng.Instance._BassTowerRank         = int.Parse(reader[19].ToString());
                    StaticMng.Instance._KeyBoardTowerRank     = int.Parse(reader[20].ToString());
                    StaticMng.Instance._InfinityGameScore     = int.Parse(reader[21].ToString());
                    StaticMng.Instance._InfinityScoreIdentity = int.Parse(reader[22].ToString());
                    StaticMng.Instance._Infinity_FastValue    = int.Parse(reader[23].ToString());

                    Dictionary <string, string> json = new Dictionary <string, string>();
                    json = JSon.Read(spdata);
                    for (int i = 0; i < StaticMng.Instance._MaximumChapter; i++)
                    {
                        for (int j = 0; j < StaticMng.Instance._MaximumSector[i]; j++)
                        {
                            StaticMng.Instance._StagePeakCount[i, j] = int.Parse(json["sp_" + i.ToString() + "_" + j.ToString()]);
                        }
                    }

                    Dictionary <string, string> achijson = new Dictionary <string, string>();
                    achijson = JSon.Read(achidata);
                    for (int i = 0; i < StaticMng.Instance._MaxAchievementCount; i++)
                    {
                        StaticMng.Instance._Achive_NowValue[i]   = int.Parse(achijson["Achi_NowVal" + i.ToString()]);
                        StaticMng.Instance._Achive_ClearCheck[i] = int.Parse(achijson["Achi_NowInfo" + i.ToString()]);
                        //Debug.Log("Load_ClearCheck");
                    }
                }
                //if (getdata)
                //{
                //    Debug.Log("loadsucces");
                //    //StaticMng.Instance._Stage_Chapter = 1;
                //}
                //else
                //    Debug.Log("loadfail");
                conn.Close();
            }
            catch (System.Exception ex)
            {
                Debug.Log(ex.ToString());

                conn.Close();
            }
        }
        catch (Exception ex)
        {
            Debug.Log(ex);
        }
    }