
                (function() {
                    var nodeEnv = typeof require !== 'undefined' && typeof process !== 'undefined';
                    var __module = nodeEnv ? module : {exports:{}};
                    var __filename = 'preview-scripts/assets/Script/GameManager.js';
                    var __require = nodeEnv ? function (request) {
                        return cc.require(request);
                    } : function (request) {
                        return __quick_compile_project__.require(request, __filename);
                    };
                    function __define (exports, require, module) {
                        if (!nodeEnv) {__quick_compile_project__.registerModule(__filename, module);}"use strict";
cc._RF.push(module, 'df248lSLllOZpCHwGqQ5Ye3', 'GameManager');
// Script/GameManager.ts

"use strict";
// Learn TypeScript:
//  - https://docs.cocos.com/creator/manual/en/scripting/typescript.html
// Learn Attribute:
//  - https://docs.cocos.com/creator/manual/en/scripting/reference/attributes.html
// Learn life-cycle callbacks:
//  - https://docs.cocos.com/creator/manual/en/scripting/life-cycle-callbacks.html
var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
Object.defineProperty(exports, "__esModule", { value: true });
var MiniGameSdk_1 = require("./Sdk/MiniGameSdk");
var _a = cc._decorator, ccclass = _a.ccclass, property = _a.property;
var GameManager = /** @class */ (function (_super) {
    __extends(GameManager, _super);
    function GameManager() {
        var _this = _super !== null && _super.apply(this, arguments) || this;
        _this.label = null;
        _this.text = 'hello';
        _this.Block_Array = [];
        _this.Wall_Prefab = [];
        _this.Block_Color = [];
        // @property({type: [cc.ParticleSystem], tooltip:"粒子数组"})
        // particleEffects : Array<cc.ParticleSystem> = [];
        _this.load1 = false;
        _this.load2 = false;
        _this.load3 = false;
        _this.load4 = false;
        _this.load5 = false;
        return _this;
    }
    GameManager_1 = GameManager;
    // LIFE-CYCLE CALLBACKS:
    GameManager.prototype.onLoad = function () {
        var _this = this;
        window.initMgr();
        this.timeNumber = 1;
        this.startTimeCutDown();
        cc.fx.GameConfig.init(true);
        cc.fx.GameConfig.GM_INFO.gameState = false;
        this.readMusicConfig();
        this.load1 = this.load2 = this.load3 = this.load4 = this.load5 = false;
        setTimeout(function () {
            _this.readUserData();
        }, 200);
        if (GameManager_1._instance == null) {
            GameManager_1._instance = this;
            cc.game.addPersistRootNode(this.node);
        }
        else {
            return;
        }
        var path = 'prefab/block';
        var path2 = 'prefab/wall';
        cc.resources.loadDir(path, cc.Prefab, function (err, assets) {
            if (err) {
                console.log('动态加载 block 失败:', err);
                cc.director.loadScene("LoadScene");
                return;
            }
            // 将加载的 Prefab 赋值给 Block_Array
            _this.Block_Array = assets;
            console.log('方块加载成功，共加载了', _this.Block_Array.length, '个方块');
            _this.setSort();
            _this.load1 = true;
        });
        cc.resources.loadDir(path2, cc.Prefab, function (err, assets) {
            if (err) {
                console.log('动态加载 wall 失败:', err);
                cc.director.loadScene("LoadScene");
                return;
            }
            // 将加载的 Prefab 赋值给 Block_Array
            _this.Wall_Prefab = assets;
            _this.load2 = true;
            console.log('墙加载成功，共加载了', _this.Wall_Prefab.length, '个墙');
            _this.setWallPrefabSort();
        });
        // 检测微信小游戏切到后台
        if (cc.sys.platform === cc.sys.WECHAT_GAME) {
            //@ts-ignore
            wx.onHide(function () {
                _this.onHide();
            });
            // 检测微信小游戏回到前台
            //@ts-ignore
            wx.onShow(function () {
                _this.onShow();
            });
        }
    };
    GameManager.prototype.onHide = function () {
        cc.audioEngine.stopMusic();
        cc.game.pause();
    };
    GameManager.prototype.onShow = function () {
        cc.audioEngine.resumeMusic();
        cc.game.resume();
    };
    GameManager.prototype.loadParticleEffects = function () {
    };
    GameManager.prototype.setWallPrefabSort = function () {
        var order = ['down', 'downLeft', 'downRight', 'left', 'right', 'up', 'upLeft', 'upRight'];
        this.Wall_Prefab.sort(function (a, b) {
            var indexA = order.indexOf(a.name);
            var indexB = order.indexOf(b.name);
            if (indexA === -1)
                return 1;
            if (indexB === -1)
                return -1;
            return indexA - indexB;
        });
    };
    GameManager.prototype.setParticleSort = function () {
        var order = ['top', 'bot', 'rig', 'lef'];
        this.particleEffects.sort(function (a, b) {
            var indexA = order.indexOf(a.name.substr(0, 3));
            var indexB = order.indexOf(b.name.substr(0, 3));
            if (indexA === -1)
                return 1;
            if (indexB === -1)
                return -1;
            return indexA - indexB;
        });
    };
    GameManager.prototype.setSort = function () {
        this.Block_Array.sort(function (a, b) {
            var _a, _b;
            // 从名称中提取数字部分
            var numberA = parseInt(((_a = a.name.match(/\d+/)) === null || _a === void 0 ? void 0 : _a[0]) || '0', 10);
            var numberB = parseInt(((_b = b.name.match(/\d+/)) === null || _b === void 0 ? void 0 : _b[0]) || '0', 10);
            return numberA - numberB;
        });
    };
    GameManager.prototype.start = function () {
    };
    GameManager.prototype.startGame = function () {
        console.log("进入场景之前_____________", cc.fx.GameConfig.GM_INFO.first);
        // 加载 music bundle
        cc.assetManager.loadBundle('music', function (err, bundle) {
            if (err) {
                console.error('加载 music bundle 失败:', err);
                // 加载失败时仍尝试进入 HomeScene
                cc.director.loadScene("HomeScene");
            }
            else {
                console.log('music bundle 加载成功');
                // 加载成功后进入 HomeScene
                cc.director.loadScene("HomeScene");
            }
        });
    };
    GameManager.prototype.returnHome = function () {
        cc.tween(this.node.getChildByName("Game"))
            .to(0.5, { opacity: 100 })
            .call(function () {
            // 预加载成功后加载场景
            cc.director.loadScene("HomeScene", function (err) {
                if (err) {
                    console.error('加载 HomeScene 场景失败:', err);
                }
                else {
                    cc.director.loadScene("HomeScene");
                }
            });
        })
            .start();
        cc.tween(this.node.getChildByName("mask"))
            .to(0.5, { opacity: 255 })
            .start();
        // cc.loader.releaseAll();
        // 预加载 HomeScene 场景
    };
    GameManager.prototype.readUserData = function (retryCount) {
        var _this = this;
        if (retryCount === void 0) { retryCount = 0; }
        //@ts-ignore
        if (typeof wx !== 'undefined' && wx !== null) {
            MiniGameSdk_1.MiniGameSdk.API.shushu_Init();
            var levelInfo = cc.fx.StorageMessage.getStorage("level");
            //旧的读取数据设置数据方法,以强联网为主
            if (levelInfo == undefined || levelInfo == "" || levelInfo == null) {
                this.oldReadData(retryCount);
            }
            //新的读取数据设置方法，以本地为主
            else {
                this.newReadData();
            }
            console.log("即将读取体力值");
            cc.fx.GameTool.getHealth(function (data) {
                console.log("体力值完成进入游戏");
                _this.load5 = true;
            });
        }
        else {
            this.load3 = true;
            this.load4 = true;
            this.load5 = true;
            cc.fx.GameTool.getHealth(null);
        }
        // 存储用户数据
    };
    GameManager.prototype.readMusicConfig = function () {
        var audioInfo = cc.fx.StorageMessage.getStorage("music");
        if (audioInfo == undefined || audioInfo == "" || audioInfo == null) {
            audioInfo = {
                "musicOpen": true,
                "effectOpen": true,
                "vibrateOpen": true,
            };
            cc.fx.StorageMessage.setStorage("music", audioInfo);
        }
        else {
            cc.fx.GameConfig.GM_INFO.musicOpen = audioInfo.musicOpen;
            cc.fx.GameConfig.GM_INFO.effectOpen = audioInfo.effectOpen;
            cc.fx.GameConfig.GM_INFO.vibrateOpen = audioInfo.vibrateOpen;
        }
    };
    //新用户，有本地缓存读取配置
    GameManager.prototype.newReadData = function () {
        var _this = this;
        console.log("读取新信息");
        var openid = cc.fx.StorageMessage.getStorage("openid");
        if (openid == null || openid == "" || openid == undefined) {
            console.log("没有openid");
            //@ts-ignore
            wx.cloud.callFunction({
                name: 'userData',
                data: {
                    action: 'read'
                },
                success: function (res) {
                    console.log('读取用户数据成功', res.result);
                    if (res.result.code == 404 && res.result.message == "未找到用户数据") {
                    }
                    else if (res.result.code == 200) {
                        if (res.result.data) {
                            cc.fx.GameConfig.GM_INFO.openid = res.result.openid;
                            cc.fx.GameConfig.GM_INFO.username = res.result.data.username;
                            cc.fx.GameConfig.GM_INFO.useravatar = res.result.data.useravatar;
                            var register_time = res.result.data.register_time;
                            MiniGameSdk_1.MiniGameSdk.API.shushu_userSet(register_time);
                            cc.fx.StorageMessage.setStorage("openid", cc.fx.GameConfig.GM_INFO.openid);
                        }
                    }
                },
                fail: function (err) {
                    console.error('读取用户数据失败', err);
                }
            });
        }
        else {
            if (openid)
                cc.fx.GameConfig.GM_INFO.openid = openid;
        }
        //等级信息
        cc.fx.GameTool.getUserLevel(function (data) {
            var timestamp = Date.now();
            var levelInfo = cc.fx.StorageMessage.getStorage("level");
            if (data.result.code == 404 && data.result.message == "未找到关卡数据") {
                // console.log("没有等级信息，从用户接口拿到数据");
                if (levelInfo.level) {
                    cc.fx.GameConfig.GM_INFO.level = levelInfo.level;
                }
                _this.load4 = true;
                cc.fx.GameTool.setUserLevel(function (data) {
                });
            }
            else if (data.result.code == 200) {
                // console.log("有等级信息，从关卡接口拿到数据",data.result.data);
                //游戏前端存储 新于服务器端,以游戏前端信息为主，放服务器存储
                var temp = data.result.timestamp - levelInfo.timestamp;
                console.log("等级时间差:", temp);
                if ((data.result.timestamp - levelInfo.timestamp) < 10000) {
                    if (levelInfo.level) {
                        console.log("以游戏前端等级为准", data.result.data);
                        cc.fx.GameConfig.GM_INFO.level = levelInfo.level;
                        // console.log("等级为:",cc.fx.GameConfig.GM_INFO.level);
                        cc.fx.GameTool.setUserLevel(function (data) {
                        });
                    }
                }
                //服务器端存储时间新于游戏端，以服务器端为主,往前端存储
                else {
                    console.log("以服务器等级为准", data.result.data);
                    cc.fx.GameConfig.GM_INFO.level = data.result.data;
                    levelInfo.level = cc.fx.GameConfig.GM_INFO.level;
                    levelInfo.timestamp = timestamp;
                    // console.log("1111111存储关卡数据:",cc.fx.GameConfig.GM_INFO.level);
                    cc.fx.StorageMessage.setStorage("level", levelInfo);
                }
                _this.load4 = true;
            }
        });
        //金币信息
        cc.fx.GameTool.getUserCoin(function (data) {
            var timestamp = Date.now();
            var coinInfo = cc.fx.StorageMessage.getStorage("coin");
            if (data.result.code == 404 && data.result.message == "未找到金币数据") {
                if (coinInfo.coin)
                    cc.fx.GameConfig.GM_INFO.coin = coinInfo.coin;
                console.log("没有金币信息，从用户接口拿到数据", cc.fx.GameConfig.GM_INFO.coin);
                _this.load3 = true;
                cc.fx.GameTool.setUserCoin(function (data) {
                });
            }
            else if (data.result.code == 200) {
                // console.log("有金币信息，从金币接口拿到数据",data.result.data);
                //游戏前端存储 新于服务器端,以游戏前端信息为主，放服务器存储
                var temp = data.result.timestamp - coinInfo.timestamp;
                console.log("金币时间差:", temp);
                if ((data.result.timestamp - coinInfo.timestamp) < 10000) {
                    console.log("以前端金幣为准:", coinInfo);
                    if (coinInfo.coin)
                        cc.fx.GameConfig.GM_INFO.coin = coinInfo.coin;
                    else {
                        cc.fx.GameConfig.GM_INFO.coin = data.result.data;
                        coinInfo.coin = cc.fx.GameConfig.GM_INFO.coin;
                        coinInfo.timestamp = timestamp;
                        console.log("11111111111");
                        cc.fx.StorageMessage.setStorage("coin", coinInfo);
                    }
                    console.log("改变后金币:", cc.fx.GameConfig.GM_INFO.coin);
                    cc.fx.GameTool.setUserCoin(function (data) {
                    });
                }
                //服务器端存储时间新于游戏端，以服务器端为主,往前端存储
                else {
                    console.log("以服务器金幣为准:", data.result.data);
                    cc.fx.GameConfig.GM_INFO.coin = data.result.data;
                    coinInfo.coin = cc.fx.GameConfig.GM_INFO.coin;
                    coinInfo.timestamp = timestamp;
                    console.log("2222222222");
                    cc.fx.StorageMessage.setStorage("coin", coinInfo);
                }
                _this.load3 = true;
            }
        });
        //道具信息
        cc.fx.GameTool.getUserProp(function (data) {
            var timestamp = Date.now();
            var propInfo = cc.fx.StorageMessage.getStorage("prop");
            if (data.result.code == 404 && data.result.message == "未找到道具数据") {
                console.log("没有道具信息，从用户接口拿到数据", propInfo);
                if (propInfo.freezeAmount == undefined || propInfo.hammerAmount == undefined || propInfo.magicAmount == undefined) {
                    console.log("2222222道具数据异常");
                    cc.fx.GameConfig.GM_INFO.freezeAmount = 0;
                    cc.fx.GameConfig.GM_INFO.hammerAmount = 0;
                    cc.fx.GameConfig.GM_INFO.magicAmoun = 0;
                    var propInfoNew = {
                        "freezeAmount": cc.fx.GameConfig.GM_INFO.freezeAmount,
                        "hammerAmount": cc.fx.GameConfig.GM_INFO.hammerAmount,
                        "magicAmount": cc.fx.GameConfig.GM_INFO.magicAmoun,
                        "timestamp": timestamp
                    };
                    console.log("1111111上传道具信息:", propInfoNew);
                    cc.fx.StorageMessage.setStorage("prop", propInfoNew);
                }
                else {
                    // cc.fx.GameConfig.GM_INFO.freezeAmount = data.result.data.freeze;
                    // cc.fx.GameConfig.GM_INFO.hammerAmount = data.result.data.hammer;
                    // cc.fx.GameConfig.GM_INFO.magicAmount = data.result.data.magic_wand;
                    cc.fx.GameConfig.GM_INFO.freezeAmount = propInfo.freezeAmount;
                    cc.fx.GameConfig.GM_INFO.hammerAmount = propInfo.hammerAmount;
                    cc.fx.GameConfig.GM_INFO.magicAmount = propInfo.magicAmount;
                }
                // cc.fx.GameConfig.GM_INFO.freezeAmount = propInfo.freezeAmount;
                // cc.fx.GameConfig.GM_INFO.hammerAmount = propInfo.hammerAmount;
                // cc.fx.GameConfig.GM_INFO.magicAmount = propInfo.magicAmount;
                cc.fx.GameTool.setUserProp(0, 0, function (data) {
                });
            }
            else if (data.result.code == 200) {
                // console.log("本地时间戳",propInfo.timestamp,"服务器时间戳",data.result.timestamp);
                if ((data.result.timestamp - propInfo.timestamp) < 10000) {
                    console.log("以前端道具为主:", propInfo);
                    if (propInfo.freezeAmount == undefined || propInfo.hammerAmount == undefined || propInfo.magicAmount == undefined) {
                        console.log("111111道具数据异常", data.result.data);
                        cc.fx.GameConfig.GM_INFO.freezeAmount = data.result.data.freeze;
                        cc.fx.GameConfig.GM_INFO.hammerAmount = data.result.data.hammer;
                        cc.fx.GameConfig.GM_INFO.magicAmount = data.result.data.magic_wand;
                        var propInfoNew = {
                            "freezeAmount": cc.fx.GameConfig.GM_INFO.freezeAmount,
                            "hammerAmount": cc.fx.GameConfig.GM_INFO.hammerAmount,
                            "magicAmount": cc.fx.GameConfig.GM_INFO.magicAmount,
                            "timestamp": timestamp
                        };
                        console.log("333333上传道具信息:", propInfoNew);
                        cc.fx.StorageMessage.setStorage("prop", propInfoNew);
                    }
                    else {
                        console.log("道具数据正常");
                        cc.fx.GameConfig.GM_INFO.freezeAmount = propInfo.freezeAmount;
                        cc.fx.GameConfig.GM_INFO.hammerAmount = propInfo.hammerAmount;
                        cc.fx.GameConfig.GM_INFO.magicAmount = propInfo.magicAmount;
                        cc.fx.GameTool.setUserProp(0, 0, function (data) {
                        });
                    }
                }
                else {
                    cc.fx.GameConfig.GM_INFO.freezeAmount = data.result.data.freeze;
                    cc.fx.GameConfig.GM_INFO.hammerAmount = data.result.data.hammer;
                    cc.fx.GameConfig.GM_INFO.magicAmount = data.result.data.magic_wand;
                    var propInfoNew = {
                        "freezeAmount": cc.fx.GameConfig.GM_INFO.freezeAmount,
                        "hammerAmount": cc.fx.GameConfig.GM_INFO.hammerAmount,
                        "magicAmount": cc.fx.GameConfig.GM_INFO.magicAmount,
                        "timestamp": timestamp
                    };
                    console.log("22222222上传道具信息:", propInfoNew, data.result);
                    cc.fx.StorageMessage.setStorage("prop", propInfoNew);
                }
            }
        });
    };
    //旧用户，无本地缓存读取配置
    GameManager.prototype.oldReadData = function (retryCount) {
        var _this = this;
        console.log("读取旧信息");
        var MAX_RETRIES = 15;
        var timestamp = Date.now();
        // 读取用户数据
        //@ts-ignore
        wx.cloud.callFunction({
            name: 'userData',
            data: {
                action: 'read'
            },
            success: function (res) {
                console.log('读取用户数据成功', res.result);
                if (res.result.code == 404 && res.result.message == "未找到用户数据") {
                    if (res.result.openid) {
                        cc.fx.GameConfig.GM_INFO.openid = res.result.openid;
                    }
                    cc.fx.GameConfig.GM_INFO.first = true;
                    _this.load3 = true;
                    _this.load4 = true;
                    var levelInfo = { "level": 0, "timestamp": timestamp };
                    cc.fx.StorageMessage.setStorage("level", levelInfo);
                    var coinInfo = { "coin": 0, "timestamp": timestamp };
                    console.log("33333333333");
                    cc.fx.StorageMessage.setStorage("coin", coinInfo);
                    var propInfo = {
                        "freezeAmount": 0,
                        "hammerAmount": 0,
                        "magicAmount": 0,
                        "timestamp": timestamp,
                    };
                    cc.fx.StorageMessage.setStorage("prop", propInfo);
                    cc.fx.GameTool.setUserInfo(function (data) {
                        if (data.result.code == 200) {
                            console.log("上传用户信息成功", data);
                            //@ts-ignore
                            wx.cloud.callFunction({
                                name: 'userData',
                                data: {
                                    action: 'read'
                                },
                                success: function (res) {
                                    console.log("上传后，读取用户信息，为上报注册时间");
                                    if (res.result.code == 200) {
                                        var time = res.result.data.register_time;
                                        MiniGameSdk_1.MiniGameSdk.API.shushu_userSet(time);
                                    }
                                }
                            });
                        }
                    });
                    console.log("服务器也没有金币信息", cc.fx.GameConfig.GM_INFO.coin);
                    cc.fx.GameTool.setUserCoin(cc.fx.GameConfig.GM_INFO.coin, function (data) {
                    });
                    cc.fx.GameTool.setUserLevel(function (data) {
                    });
                    setTimeout(function () {
                        cc.fx.GameConfig.GM_INFO.freezeAmount = 0;
                        cc.fx.GameConfig.GM_INFO.hammerAmount = 0;
                        cc.fx.GameConfig.GM_INFO.magicAmount = 0;
                        cc.fx.GameTool.setUserProp(0, 0, function (data) {
                            if (data.result.code == 200) {
                                console.log("上传道具信息成功", data);
                            }
                            else {
                                MiniGameSdk_1.MiniGameSdk.API.showToast("网络异常，正在努力加载");
                                setTimeout(function () {
                                    _this.oldReadData(0);
                                }, 1000);
                            }
                        });
                    }, 0);
                }
                else if (res.result.code == 200) {
                    if (res.result.data) {
                        cc.fx.GameConfig.GM_INFO.openid = res.result.openid;
                        cc.fx.GameConfig.GM_INFO.level = res.result.data.level;
                        cc.fx.GameConfig.GM_INFO.coin = res.result.data.coinAmount;
                        cc.fx.GameConfig.GM_INFO.freezeAmount = res.result.data.freezeAmount;
                        cc.fx.GameConfig.GM_INFO.hammerAmount = res.result.data.hammerAmount;
                        cc.fx.GameConfig.GM_INFO.magicAmount = res.result.data.magicAmount;
                        cc.fx.GameConfig.GM_INFO.username = res.result.data.username;
                        cc.fx.GameConfig.GM_INFO.useravatar = res.result.data.useravatar;
                        cc.fx.StorageMessage.setStorage("openid", cc.fx.GameConfig.GM_INFO.openid);
                        var register_time = res.result.data.register_time;
                        MiniGameSdk_1.MiniGameSdk.API.shushu_userSet(register_time);
                    }
                    setTimeout(function () {
                        cc.fx.GameTool.getUserCoin(function (data) {
                            if (data.result.code == 404 && data.result.message == "未找到金币数据") {
                                var coinInfo = { "coin": 0, "timestamp": timestamp };
                                cc.fx.GameConfig.GM_INFO.coin = 0;
                                cc.fx.StorageMessage.setStorage("coin", coinInfo);
                                console.log("没有金币信息，从用户接口拿到数据", cc.fx.GameConfig.GM_INFO.coin);
                                cc.fx.GameTool.setUserCoin(function (data) {
                                    // console.log("上传",data);
                                    _this.load3 = true;
                                });
                            }
                            else if (data.result.code == 200) {
                                // console.log("有金币信息，从金币接口拿到数据",data.result.data);
                                cc.fx.GameConfig.GM_INFO.coin = data.result.data;
                                var coinInfo = { "coin": cc.fx.GameConfig.GM_INFO.coin, "timestamp": timestamp };
                                console.log("存储金币信息:", cc.fx.GameConfig.GM_INFO.coin);
                                console.log("4444444444");
                                cc.fx.StorageMessage.setStorage("coin", coinInfo);
                                _this.load3 = true;
                            }
                        });
                    }, 500);
                    cc.fx.GameTool.getUserLevel(function (data) {
                        if (data.result.code == 404 && data.result.message == "未找到关卡数据") {
                            console.log("没有等级信息，从用户接口拿到数据");
                            var levelInfo = { "level": 0, "timestamp": timestamp };
                            // console.log("333333存储关卡数据:",levelInfo);
                            cc.fx.GameConfig.GM_INFO.level = 0;
                            cc.fx.StorageMessage.setStorage("level", levelInfo);
                            cc.fx.GameTool.setUserLevel(function (data) {
                                console.log("拿到的数据", data);
                                _this.load4 = true;
                            });
                        }
                        else if (data.result.code == 200) {
                            console.log("有等级信息，从关卡接口拿到数据", data.result.data);
                            cc.fx.GameConfig.GM_INFO.level = data.result.data;
                            var levelInfo = { "level": cc.fx.GameConfig.GM_INFO.level, "timestamp": timestamp };
                            // console.log("444444存储关卡信息:",levelInfo);
                            cc.fx.StorageMessage.setStorage("level", levelInfo);
                            _this.load4 = true;
                        }
                    });
                    setTimeout(function () {
                        cc.fx.GameTool.getUserProp(function (data) {
                            if (data.result.code == 404 && data.result.message == "未找到道具数据") {
                                console.log("没有道具信息，从用户接口拿到数据");
                                cc.fx.GameConfig.GM_INFO.freezeAmount = 0;
                                cc.fx.GameConfig.GM_INFO.hammerAmount = 0;
                                cc.fx.GameConfig.GM_INFO.magicAmount = 0;
                                var propInfo = {
                                    "freezeAmount": 0,
                                    "hammerAmount": 0,
                                    "magicAmount": 0,
                                    "timestamp": timestamp,
                                };
                                console.log("上传道具信息:", propInfo);
                                cc.fx.StorageMessage.setStorage("prop", propInfo);
                                cc.fx.GameTool.setUserProp(0, 0, function (data) {
                                });
                            }
                            else if (data.result.code == 200) {
                                console.log("有道具信息，从道具接口拿到数据", data.result.data);
                                cc.fx.GameConfig.GM_INFO.freezeAmount = data.result.data.freeze || 0;
                                cc.fx.GameConfig.GM_INFO.hammerAmount = data.result.data.hammer || 0;
                                cc.fx.GameConfig.GM_INFO.magicAmount = data.result.data.magic_wand || 0;
                                var propInfo = {
                                    "freezeAmount": cc.fx.GameConfig.GM_INFO.freezeAmount,
                                    "hammerAmount": cc.fx.GameConfig.GM_INFO.hammerAmount,
                                    "magicAmount": cc.fx.GameConfig.GM_INFO.magicAmount,
                                    "timestamp": timestamp,
                                };
                                console.log("上传道具信息:", propInfo);
                                cc.fx.StorageMessage.setStorage("prop", propInfo);
                            }
                        });
                    }, 0);
                }
            },
            fail: function (err) {
                console.error('读取用户数据失败', err);
                if (retryCount < MAX_RETRIES) {
                    console.error("\u8BFB\u53D6\u7528\u6237\u6570\u636E\u5931\u8D25\uFF0C\u7B2C " + (retryCount + 1) + " \u6B21\u91CD\u8BD5\uFF0C\u9519\u8BEF\u4FE1\u606F:", err);
                    // 延迟 2 秒后重试
                    setTimeout(function () {
                        _this.readUserData(retryCount + 1);
                    }, 2000);
                }
                else {
                    console.error('读取用户数据失败，达到最大重试次数，退出游戏', err);
                    // 退出游戏
                    cc.game.end();
                }
            }
        });
    };
    GameManager.prototype.setUserData = function () {
        cc.fx.GameConfig.GameTool(function (data) {
            console.log("上传", data);
        });
    };
    GameManager.prototype.startTimeCutDown = function () {
        this.scheduleCallback = function () {
            if (this.timeNumber <= 0) {
                this.stopTimeCutDown();
            }
            else {
                this.timeNumber -= 1;
            }
        }.bind(this);
        this.schedule(this.scheduleCallback, 1);
    };
    GameManager.prototype.stopTimeCutDown = function () {
        if (this.scheduleCallback) {
            this.unschedule(this.scheduleCallback);
        }
    };
    GameManager.prototype.update = function (dt) {
        if (this.load1 && this.load2 && this.load3 && this.load4 && this.load5 && this.timeNumber <= 0) {
            this.load1 = this.load2 = false;
            MiniGameSdk_1.MiniGameSdk.API.shushu_Login();
            this.startGame();
        }
    };
    var GameManager_1;
    GameManager._instance = null;
    __decorate([
        property(cc.Label)
    ], GameManager.prototype, "label", void 0);
    __decorate([
        property
    ], GameManager.prototype, "text", void 0);
    __decorate([
        property({ type: [cc.Prefab], tooltip: "方块数组" })
    ], GameManager.prototype, "Block_Array", void 0);
    __decorate([
        property({ type: [cc.Prefab], tooltip: "墙壁数组" })
    ], GameManager.prototype, "Wall_Prefab", void 0);
    __decorate([
        property({ type: [cc.SpriteAtlas], tooltip: "方块颜色" })
    ], GameManager.prototype, "Block_Color", void 0);
    GameManager = GameManager_1 = __decorate([
        ccclass
    ], GameManager);
    return GameManager;
}(cc.Component));
exports.default = GameManager;

cc._RF.pop();
                    }
                    if (nodeEnv) {
                        __define(__module.exports, __require, __module);
                    }
                    else {
                        __quick_compile_project__.registerModuleFunc(__filename, function () {
                            __define(__module.exports, __require, __module);
                        });
                    }
                })();
//# sourceMappingURL=data:application/json;charset=utf-8;base64,[encoded data, 76708 characters]