public static XKGlobalData GetInstance()
    {
        if (Instance == null)
        {
            Instance = new XKGlobalData();
            Instance.InitInfo();
            if (!Directory.Exists(FilePath))
            {
                Directory.CreateDirectory(FilePath);
            }
            if (HandleJsonObj == null)
            {
                HandleJsonObj = HandleJson.GetInstance();
            }

            string startCoinInfo = HandleJsonObj.ReadFromFileXml(FileName, "START_COIN");
            if (startCoinInfo == null || startCoinInfo == "")
            {
                startCoinInfo = "1";
                HandleJsonObj.WriteToFileXml(FileName, "START_COIN", startCoinInfo);
            }
            XKGlobalData.GameNeedCoin = Convert.ToInt32(startCoinInfo);
//			GameNeedCoin = 1;

            string modeGame = HandleJsonObj.ReadFromFileXml(FileName, "GAME_MODE");
            if (modeGame == null || modeGame == "")
            {
                modeGame = "1";
                HandleJsonObj.WriteToFileXml(FileName, "GAME_MODE", modeGame);
            }

            if (modeGame == "0")
            {
                IsFreeMode = true;
            }

            string gmText = HandleJsonObj.ReadFromFileXml(FileName, "GameTextVal");
            if (gmText == null || gmText == "")
            {
                gmText = "0";                 //中文版.
                SetGameTextMode(GameTextType.Chinese);
            }
            GameTextVal = gmText == "0" ? GameTextType.Chinese : GameTextType.English;
            GameTextVal = GameTextType.English;             //test.

            GetGameDiffVal();

            string gunZhenDongStr = HandleJsonObj.ReadFromFileXml(FileName, "GunZDP1");
            if (gunZhenDongStr == null || gunZhenDongStr == "")
            {
                gunZhenDongStr = "5";
            }
            GunZhenDongP1 = Convert.ToInt32(gunZhenDongStr);
            pcvr.SetGunZhenDongDengJi(GunZhenDongP1, PlayerEnum.PlayerOne);

            gunZhenDongStr = HandleJsonObj.ReadFromFileXml(FileName, "GunZDP2");
            if (gunZhenDongStr == null || gunZhenDongStr == "")
            {
                gunZhenDongStr = "5";
            }
            GunZhenDongP2 = Convert.ToInt32(gunZhenDongStr);
            pcvr.SetGunZhenDongDengJi(GunZhenDongP2, PlayerEnum.PlayerTwo);
            string val = HandleJsonObj.ReadFromFileXml(FileName, "GameAudioVolume");
            if (val == null || val == "")
            {
                val = "7";
                HandleJsonObj.WriteToFileXml(FileName, "GameAudioVolume", val);
            }
            GameAudioVolume = Convert.ToInt32(val);
        }
        return(Instance);
    }
Esempio n. 2
0
    public static XKGlobalData GetInstance()
    {
        if (Instance == null)
        {
            Instance = new XKGlobalData();
            Instance.InitInfo();
            if (!Directory.Exists(FilePath))
            {
                Directory.CreateDirectory(FilePath);
            }

            if (HandleJsonObj == null)
            {
                HandleJsonObj = HandleJson.GetInstance();
            }

            string startCoinInfo = HandleJsonObj.ReadFromFileXml(FileName, "START_COIN");
            if (startCoinInfo == null || startCoinInfo == "")
            {
                startCoinInfo = "1";
                HandleJsonObj.WriteToFileXml(FileName, "START_COIN", startCoinInfo);
            }
            GameNeedCoin = Convert.ToInt32(startCoinInfo);

            string modeGame = HandleJsonObj.ReadFromFileXml(FileName, "GAME_MODE");
            if (modeGame == null || modeGame == "")
            {
                modeGame = "1";
                HandleJsonObj.WriteToFileXml(FileName, "GAME_MODE", modeGame);
            }
            IsFreeMode = modeGame == "0" ? true : false;

            GameDiff = HandleJsonObj.ReadFromFileXml(FileName, "GAME_DIFFICULTY");
            if (GameDiff == null || GameDiff == "")
            {
                GameDiff = "1";
                HandleJsonObj.WriteToFileXml(FileName, "GAME_DIFFICULTY", GameDiff);
            }

            string speedStr = HandleJsonObj.ReadFromFileXml(FileName, "DianJiSpeedP1");
            if (speedStr == null || speedStr == "")
            {
                speedStr = "5";
                HandleJsonObj.WriteToFileXml(FileName, "DianJiSpeedP1", speedStr);
            }
            pcvr.DianJiSpeedP1 = Convert.ToInt32(speedStr);

            speedStr = HandleJsonObj.ReadFromFileXml(FileName, "DianJiSpeedP2");
            if (speedStr == null || speedStr == "")
            {
                speedStr = "5";
                HandleJsonObj.WriteToFileXml(FileName, "DianJiSpeedP2", speedStr);
            }
            pcvr.DianJiSpeedP2 = Convert.ToInt32(speedStr);

            speedStr = HandleJsonObj.ReadFromFileXml(FileName, "DianJiSpeedP3");
            if (speedStr == null || speedStr == "")
            {
                speedStr = "5";
                HandleJsonObj.WriteToFileXml(FileName, "DianJiSpeedP3", speedStr);
            }
            pcvr.DianJiSpeedP3 = Convert.ToInt32(speedStr);

            speedStr = HandleJsonObj.ReadFromFileXml(FileName, "DianJiSpeedP4");
            if (speedStr == null || speedStr == "")
            {
                speedStr = "5";
                HandleJsonObj.WriteToFileXml(FileName, "DianJiSpeedP4", speedStr);
            }
            pcvr.DianJiSpeedP4 = Convert.ToInt32(speedStr);

            string val = HandleJsonObj.ReadFromFileXml(FileName, "GameAudioVolume");
            if (val == null || val == "")
            {
                val = "7";
                HandleJsonObj.WriteToFileXml(FileName, "GameAudioVolume", val);
            }
            GameAudioVolume = Convert.ToInt32(val);

            val = HandleJsonObj.ReadFromFileXml(FileName, "GameVersionPlayer");
            if (val == null || val == "")
            {
                val = "0";                 //四人版本.
                HandleJsonObj.WriteToFileXml(FileName, "GameVersionPlayer", val);
            }
            GameVersionPlayer = Convert.ToInt32(val);
        }
        return(Instance);
    }
    public static XKGlobalData GetInstance()
    {
        if (Instance == null)
        {
            Instance = new XKGlobalData();
            Instance.InitInfo();

#if UNITY_STANDALONE_WIN
            if (!Directory.Exists(FilePath))
            {
                Directory.CreateDirectory(FilePath);
            }
#endif

            if (HandleJsonObj == null)
            {
                HandleJsonObj = HandleJson.GetInstance();
            }
            //return Instance;

            string startCoinInfo = HandleJsonObj.ReadFromFileXml(FileName, "START_COIN");
            if (startCoinInfo == null || startCoinInfo == "")
            {
                startCoinInfo = "1";
                HandleJsonObj.WriteToFileXml(FileName, "START_COIN", startCoinInfo);
            }
            GameNeedCoin = Convert.ToInt32(startCoinInfo);

            string modeGame = HandleJsonObj.ReadFromFileXml(FileName, "GAME_MODE");
            if (modeGame == null || modeGame == "")
            {
                modeGame = "1";
                HandleJsonObj.WriteToFileXml(FileName, "GAME_MODE", modeGame);
            }
            IsFreeMode = modeGame == "0" ? true : false;

            GameDiff = HandleJsonObj.ReadFromFileXml(FileName, "GAME_DIFFICULTY");
            if (GameDiff == null || GameDiff == "")
            {
                GameDiff = "1";
                HandleJsonObj.WriteToFileXml(FileName, "GAME_DIFFICULTY", GameDiff);
            }

            //string val = HandleJsonObj.ReadFromFileXml(FileName, "GameAudioVolume");
            //if (val == null || val == "") {
            //	val = "7";
            //	HandleJsonObj.WriteToFileXml(FileName, "GameAudioVolume", val);
            //}
            string val = "10";
            GameAudioVolume = Convert.ToInt32(val);

            //val = HandleJsonObj.ReadFromFileXml(FileName, "GameVersionPlayer");
            //if (val == null || val == "") {
            //	val = "0"; //四人版本.
            //	HandleJsonObj.WriteToFileXml(FileName, "GameVersionPlayer", val);
            //}
            val = "0"; //四人版本.
            GameVersionPlayer = Convert.ToInt32(val);

            Instance.InitIsPrintCaiPiao();
            Instance.InitCoinToCard();
            Instance.InitTotalOutPrintCards();
            Instance.InitTotalInsertCoins();
            Instance.InitZhanCheCaiChi();
            Instance.InitDaoJuCaiChi();
            Instance.InitJPBossCaiChi();
            Instance.InitCaiPiaoPrintState();
        }
        return(Instance);
    }