Beispiel #1
0
    public static SettingConfigData LoadJson(string path)
    {
        SettingConfigData data = new SettingConfigData();

        if (!File.Exists(path))
        {
            return(null);
        }
        string text = File.ReadAllText(path);

        if (text.Length == 0)
        {
            File.Delete(path);
            return(null);
        }
        try
        {
            data = JsonReader.Deserialize <SettingConfigData>(text);
        }
        catch (Exception e)
        {
            File.Delete(path);
        }

        return(data);
    }
Beispiel #2
0
    public static void SaveJson(SettingConfigData data, string path)
    {
        string str = JsonWriter.Serialize(data);

        if (File.Exists(path))
        {
            File.Delete(path);
        }

        FileStream fs = new FileStream(path, FileMode.Create, FileAccess.Write, FileShare.None, 8192, FileOptions.WriteThrough);

        byte[] bytes = Encoding.UTF8.GetBytes(str);
        fs.Write(bytes, 0, bytes.Length);
        fs.Flush();
        fs.Close();
        fs.Dispose();
    }
Beispiel #3
0
    private bool _isIdle;                                     // 待机


    public void Init()
    {
        // 取出后台存储所有数据
        this.po = HelperTool.LoadJson(Application.streamingAssetsPath + "/SettingConfig.json");
        if (null == this.po)
        {
            this.po = new SettingConfigData();
        }

        // CheckID
        this._checkID = po.CheckId;

        // 游戏币率
        this._gameRate = po.GameRate;

        // 游戏语言版本 0中文 1英文
        this._gameLanguage = po.GameLanguage;

        // 检查点模式
        this._ticket = po.Ticket;

        // 游戏初始时间
        this._playTime = po.PlayTime;

        // 游戏音量
        this._gameVolume = po.GameVolume;

        // 当前剩余币数
        this._hasCoin = po.Coin;

        // 月份信息
        this._monthList = po.MonthList;

        // 总记录
        this._totalRecord = po.TotalRecord;

        CheckIsNewMonth();

        //GameConfig.ParsingGameConfig();
    }
Beispiel #4
0
    //public void Init()
    //{
    //    string filePath = Application.persistentDataPath + "/" + Const.Setting_Coinfig_Path;
    //    if (!File.Exists(filePath))
    //    {
    //        CoroutineController.Instance.StartCoroutine(ToCopy(Const.Setting_Coinfig_Path, Init));
    //    }
    //    else
    //    {
    //        PreLoadData();
    //    }
    //}

    //IEnumerator ToCopy(string fileName, Action handle)
    //{
    //    string src = Const.getStreamingPath_for_www(fileName);
    //    string des = Application.persistentDataPath + "/" + fileName;
    //    WWW www = new WWW(src);
    //    yield return www;
    //    if (!string.IsNullOrEmpty(www.error))
    //    {
    //        Debug.Log("www.error: " + www.error);
    //    }
    //    else
    //    {
    //        FileStream fsDes = new FileStream(des, FileMode.Create);
    //        fsDes.Write(www.bytes, 0, www.bytes.Length);
    //        fsDes.Flush();
    //        fsDes.Close();
    //    }
    //    www.Dispose();
    //    handle();
    //}

    public SettingManager()
    {
        // 取出后台存储所有数据
        this.po = LoadJson(Application.persistentDataPath + "/" + Const.Setting_Coinfig_Path);
        if (null == this.po)
        {
            this.po = new SettingConfigData();
        }

        // CheckID
        this._checkID = po.CheckId;

        // 游戏币率
        this._gameRate = po.GameRate;

        // 游戏语言版本 0中文 1英文
        this._gameLanguage = po.GameLanguage;

        // 检查点模式
        this._ticketModel = po.TicketModel;

        // 游戏音量
        this._gameVolume = po.GameVolume;

        // 游戏难度
        this._gameLevel = po.GameLevel;

        // 当前剩余币数
        this._hasCoin = po.Coin;

        // 月份信息
        this._monthList = po.MonthList;

        // 总记录
        this._totalRecord = po.TotalRecord;

        CheckIsNewMonth();
    }
Beispiel #5
0
    private int _coin;                                             // 耗币

    public void Init()
    {
        // 取出后台存储所有数据
        this.po = HelperTool.LoadJson(ResUpdateManager.Instance.GetFilePath(GameConfig.SETTING_COINFIG));
        if (null == this.po)
        {
            this.po = new SettingConfigData();
        }

        // CheckID
        this._checkID = po.CheckId;

        // 游戏币率
        this._gameRate = po.GameRate;

        // 游戏语言版本 0中文 1英文
        this._gameLanguage = po.GameLanguage;

        // 游戏难度
        this._gameLevel = po.GameDiffculty;

        // 出票模式
        this._ticketModel = po.TicketModel;

        // 出票分数
        this._ticketScore = SettingConfig.scorePreTicket[this._ticketModel];

        // 游戏音量
        this._gameVolume = po.GameVolume;

        // 当前剩余币数
        this._hasCoin = po.Coin;

        // 当前剩余票数
        //this._hasTicket = po.Ticket;

        // 是否显示水标 0显示 1不显示
        this._watershow = po.ShowWater;

        // 月份信息
        this._monthList = po.MonthList;

        // 总记录
        this._totalRecord = po.TotalRecord;

        // 获取玩家剩余币数
        for (int i = 0; i < GameConfig.GAME_CONFIG_PLAYER_COUNT; i++)
        {
            Main.PlayerManager.getPlayer(i).ChangeCoin(this._hasCoin[i]);
        }

        // 屏幕宽高
        _screenInfo = po.ScreenInfo;

        // 玩家校验屏幕宽高
        _screenInfoList = po.ScreenInfoList;

        // 玩家校验点X
        this._pointXList = po.PointX;
        this._pointYList = po.PointY;

        CheckIsNewMonth();
    }