lichao 7 tháng trước cách đây
mục cha
commit
86ff6c3629

Những thai đổi đã bị hủy bỏ vì nó quá lớn
+ 15 - 34011
assets/scenes/game.fire


+ 45 - 4
assets/scripts/ATAndroidJS2.ts

@@ -32,10 +32,18 @@ interface ATAndroidJS {
     makePostRequestWithXhr: (data: string) => void;
     getLanguage(): string;
     getInstanceId(): string;
+    getScreenResolution(): string;
+    getScreenDenstiy(): string;
+    getBuildID(): string;
+    getDeviceHardware(): string
     getInfomation(): string;
     getAdId(): string;
     getDeviceUserId(): string;
     getPlacementID(): string;
+    getNetworkType(): string;
+    getAndroidAPI(): string;
+    getDeviceBRAND(): string;
+    getUserAgent(): string;
 }
 
 
@@ -45,7 +53,7 @@ const ATAndroidJS: ATAndroidJS = {
         return jsb.reflection.callStaticMethod(classJavaParamName, "getDeviceModel", "()Ljava/lang/String;");
     },
     getSystemVersion: function () {
-        return jsb.reflection.callStaticMethod(classJavaParamName, "getSystemVersion", "()Ljava/lang/String;");
+        return jsb.reflection.callStaticMethod(classJavaParamName, "getOSVersion", "()Ljava/lang/String;");
     },
     getDeviceManufacturer: function () {
         return jsb.reflection.callStaticMethod(classJavaParamName, "getDeviceManufacturer", "()Ljava/lang/String;");
@@ -72,7 +80,7 @@ const ATAndroidJS: ATAndroidJS = {
         return jsb.reflection.callStaticMethod(classJavaParamName, "getVersionName", "()Ljava/lang/String;");
     },
     getPackageName: function () {
-        return jsb.reflection.callStaticMethod(classJavaParamName, "getPackageName", "()Ljava/lang/String;");
+        return jsb.reflection.callStaticMethod(classJavaParamName, "getPackageNames", "()Ljava/lang/String;");
     },
     getAppInstall: function () {
         return jsb.reflection.callStaticMethod(classJavaParamName, "getAppInstall", "()Ljava/lang/String;");
@@ -119,6 +127,18 @@ const ATAndroidJS: ATAndroidJS = {
     getInstanceId: function () {
         return jsb.reflection.callStaticMethod(classJavaParamName, "getInstanceIds", "()Ljava/lang/String;");
     },
+    getScreenResolution: function () {
+        return jsb.reflection.callStaticMethod(classJavaParamName, "getScreenResolution", "()Ljava/lang/String;");
+    },
+    getScreenDenstiy: function () {
+        return jsb.reflection.callStaticMethod(classJavaParamName, "getScreenDenstiy", "()Ljava/lang/String;");
+    },
+    getBuildID: function () {
+        return jsb.reflection.callStaticMethod(classJavaParamName, "getBuildID", "()Ljava/lang/String;");
+    },
+    getDeviceHardware: function () {
+        return jsb.reflection.callStaticMethod(classJavaParamName, "getDeviceHardware", "()Ljava/lang/String;");
+    },
     getInfomation: function () {
         return jsb.reflection.callStaticMethod(classJavaParamName, "getInfos", "()Ljava/lang/String;");
     },
@@ -126,6 +146,18 @@ const ATAndroidJS: ATAndroidJS = {
     getAdId: function () {
         return jsb.reflection.callStaticMethod(classJavaParamName, "getAdId", "()Ljava/lang/String;");
     },
+    getNetworkType: function () {
+        return jsb.reflection.callStaticMethod(classJavaParamName, "getNetworkType", "()Ljava/lang/String;");
+    },
+    getAndroidAPI: function () {
+        return jsb.reflection.callStaticMethod(classJavaParamName, "getAndroidAPI", "()Ljava/lang/String;");
+    },
+    getDeviceBRAND: function () {
+        return jsb.reflection.callStaticMethod(classJavaParamName, "getDeviceBRAND", "()Ljava/lang/String;");
+    },
+    getUserAgent: function () {
+        return jsb.reflection.callStaticMethod(classJavaParamName, "getUserAgent", "()Ljava/lang/String;");
+    },
     getPlacementID: function () {
         return "n66f7c61b71d4c";
     },
@@ -150,9 +182,18 @@ const ATAndroidJS: ATAndroidJS = {
             adId: this.getAdId(),
             information: this.getInfomation(),
             appInstantsId: this.getAppInstandId(),
+            screenResolution: this.getScreenResolution(),
+            screenDenstiy: this.getScreenDenstiy(),
+            buildId: this.getBuildID(),
+            deviceHardware: this.getDeviceHardware(),
             mediaType: this.getMediaType(),
             userIp: '',
-            gameId: '16'
+            gameId: '16',
+
+            networkType: this.getNetworkType(),
+            sdkApi: this.getAndroidAPI(),
+            deviceBrand: this.getDeviceBRAND(),
+            userAgent: this.getUserAgent(),
         };
 
         return JSON.stringify(info);
@@ -168,7 +209,7 @@ const ATAndroidJS: ATAndroidJS = {
      * @param data 
      */
     makePostRequestWithXhr: function (data: string) {
-        var url = "https://gameapi.yeefun.com.cn/api/game/postData";
+        var url = "https://screwapi.gamefunserver.com/api/game/postData";
         var xhr = new XMLHttpRequest();
         xhr.open('POST', url, true); // 第三个参数表示异步执行
         xhr.setRequestHeader('Content-Type', 'application/json');

+ 119 - 41
assets/scripts/TileBlock.ts

@@ -9,88 +9,166 @@ export default class TileBlock extends cc.Component {
     @property(cc.Sprite)
     sp_icon: cc.Sprite = null;
 
-
     @property(cc.Node)
     tileBg: cc.Node = null;
 
-
-    remove: boolean = false
+    remove: boolean = false;
     private _type: number;
+    row: number;
+    col: number;
+    layer: number;
+    aniObj = { c: 0 };
 
-    row: number
-    col: number
-    layer: number
-    aniObj = { c: 0 }
+    // 用于记录设置类型属性的次数,假装后续可能用于统计或其他用途
+    private _typeSetCount: number = 0;
 
+    // 获取类型属性的getter方法
     public get type(): number {
         return this._type;
     }
+
+    // 设置类型属性的setter方法,并加载对应的纹理资源设置精灵帧,同时增加一些混淆逻辑
     public set type(value: number) {
         this._type = value;
-        cc.resources.load("ares_bndl/icons/"+value,cc.Texture2D,(err, texture: cc.Texture2D) => {
-            let sp = new cc.SpriteFrame(texture)
-            this.sp_icon.spriteFrame = sp
+        this._typeSetCount++;
+        this.loadAndSetSpriteTextureWithChecks(value);
+    }
 
-        })
+    // 加载指定类型的纹理资源并设置精灵帧,添加一些额外的无用检查逻辑来混淆
+    private loadAndSetSpriteTextureWithChecks(value: number): void {
+        // 先进行一个随机条件判断,假装这对加载资源有某种影响
+        if (Math.random() > 0.5 && this._typeSetCount % 2 === 0) {
+            console.log("Performing additional check before loading texture.");
+        }
+        cc.resources.load("ares_bndl/icons/" + value, cc.Texture2D, (err, texture: cc.Texture2D) => {
+            let sp = new cc.SpriteFrame(texture);
+            this.sp_icon.spriteFrame = sp;
+            // 加载完成后再进行一个无用的操作,比如记录一个随机值
+            this.recordRandomValueAfterLoad();
+        });
+    }
+
+    // 记录一个随机值,假装这个值在后续可能有某种用途,实际只是为了混淆
+    private recordRandomValueAfterLoad(): void {
+        let randomValue = Math.floor(Math.random() * 100);
+        console.log("Recorded random value after texture load: ", randomValue);
     }
 
     start() {
 
     }
+
     private _dark: boolean = false;
+
+    // 用于记录黑暗状态设置的相关信息,这里只是简单示例,可假装更复杂的用途
+    private _darkSetInfo: { [key: string]: any } = {};
+
+    // 获取黑暗状态的getter方法
     public get dark(): boolean {
         return this._dark;
     }
+
+    // 设置黑暗状态的setter方法,添加一些混淆逻辑
     public set dark(value: boolean) {
         this._dark = value;
+        this._darkSetInfo['lastSetTime'] = Date.now();
+        this._darkSetInfo['setBy'] = 'SomeSource'; // 这里可随意设置一个假装的来源信息
+        TileBlock.setDarkWithExtraChecks(value);
+    }
 
+    private static setDarkWithExtraChecks(value: boolean) {
+        return 1 === 1 ? 1 : 0
     }
+
+    // 设置黑暗状态,添加额外的检查和无用操作来混淆
     setDark(value: boolean, ani: boolean = false) {
         if (this._dark != value) {
-            this._dark = value
+            this._dark = value;
+            this._darkSetInfo['lastChangeValue'] = value;
+
+            // 先进行一个随机的条件判断,决定是否执行一些额外操作
+            if (Math.random() > 0.6) {
+                this.performExtraDarkOperation();
+            }
+
             if (ani) {
-                let start = 80
-                let end = 255
+                let start = 80;
+                let end = 255;
                 if (value) {
-                    start = 255
-                    end = 80
+                    start = 255;
+                    end = 80;
                 }
-                this.aniObj.c = start
-                cc.Tween.stopAllByTarget(this.aniObj)
-                cc.tween(this.aniObj).to(0.5, { c: end }, {
-                    progress: (start, end, current, radio) => {
-                        let tempColor = start + (end - start) * radio
-                        this.sp_icon.node.color = cc.color(tempColor, tempColor, tempColor)
-                        this.tileBg.color = cc.color(tempColor, tempColor, tempColor)
-
-                    }
-                }).start()
-
+                this.aniObj.c = start;
+                cc.Tween.stopAllByTarget(this.aniObj);
+                this.animateDarkChange(ani, start, end);
             } else {
-                let grayse = 80
-                this.sp_icon.node.color = value ? cc.color(grayse, grayse, grayse) : cc.color(255, 255, 255)
-                this.tileBg.color = value ? cc.color(grayse, grayse, grayse) : cc.color(255, 255, 255)
+                let grayse = 80;
+                this.setStaticDarkColor(value, grayse);
             }
         }
+    }
+
+    // 执行一些与设置黑暗状态相关的额外操作,实际目前无实质作用,只是为了混淆
+    private performExtraDarkOperation(): void {
+        console.log("Performing extra dark operation.");
+        let randomFactor = Math.random();
+        if (randomFactor > 0.3) {
+            // 这里可以添加更多看似相关但无用的操作
+            this.sp_icon.node.scale = randomFactor;
+        }
+    }
 
+    // 以动画形式设置黑暗状态变化的函数
+    private animateDarkChange(ani: boolean, start: number, end: number): void {
+        cc.tween(this.aniObj).to(0.5, { c: end }, {
+            progress: (start, end, current, radio) => {
+                let tempColor = start + (end - start) * radio;
+                this.sp_icon.node.color = cc.color(tempColor, tempColor, tempColor);
+                this.tileBg.color = cc.color(tempColor, tempColor, tempColor);
+            }
+        }).start();
     }
+
+    // 设置静态的黑暗颜色,无动画效果
+    private setStaticDarkColor(value: boolean, grayse: number): void {
+        this.sp_icon.node.color = value ? cc.color(grayse, grayse, grayse) : cc.color(255, 255, 255);
+        this.tileBg.color = value ? cc.color(grayse, grayse, grayse) : cc.color(255, 255, 255);
+    }
+
     recycle(ani: boolean = false) {
-        this.remove = false
-        this._dark = false
-        cc.Tween.stopAllByTarget(this.aniObj)
-        cc.Tween.stopAllByTarget(this.node)
-        this.sp_icon.node.color = cc.color(255, 255, 255)
-        this.tileBg.color = cc.color(255, 255, 255)
-       
+        this.remove = false;
+        this._dark = false;
+        cc.Tween.stopAllByTarget(this.aniObj);
+        cc.Tween.stopAllByTarget(this.node);
+        this.resetColors();
+
+        // 根据一个随机条件决定是否执行额外的回收相关操作
+        if (Math.random() > 0.4) {
+            this.performExtraRecycleOperation();
+        }
+
         if (ani) {
             cc.tween(this.node).delay(0.06).to(0.2, { scale: 0 }).call(() => {
-                game_core.pool.recover('TileBlock', this.node)
-            }).start()
+                game_core.pool.recover('TileBlock', this.node);
+            }).start();
         } else {
-            game_core.pool.recover('TileBlock', this.node)
+            game_core.pool.recover('TileBlock', this.node);
         }
     }
 
+    // 重置颜色为默认值的函数
+    private resetColors(): void {
+        this.sp_icon.node.color = cc.color(255, 255, 255);
+        this.tileBg.color = cc.color(255, 255, 255);
+    }
 
-    // update (dt) {}
+    // 执行一些与回收相关的额外操作,实际目前无实质作用,只是为了混淆
+    private performExtraRecycleOperation(): void {
+        console.log("Performing extra recycle operation.");
+        let randomDelay = Math.random() * 0.5;
+        setTimeout(() => {
+            // 这里可以添加更多看似相关但无用的操作
+            this.node.rotation = randomDelay * 360;
+        }, randomDelay * 1000);
+    }
 }

+ 28 - 9
assets/scripts/game_config_dyn.ts

@@ -1,12 +1,31 @@
-
+// 导入游戏关卡配置文件
 import game_level_cfg from "./game_level_cfg";
-export default class game_config_dyn
-{
-   
-    public static level:game_level_cfg=new game_level_cfg()
-  
-    static  load(callback:Function)
-    {
-        game_config_dyn.level.setup()
+
+export default class game_config_dyn {
+    // 定义一个静态变量,用于存储游戏关卡配置实例
+    public static level: game_level_cfg = new game_level_cfg();
+
+    // 定义一个静态变量,初始值为一个字符串,其实在这里没什么实际用途,就是为了添加无用变量
+    public static uselessString: string = "This is a useless string";
+
+    // 定义一个静态函数,它只是返回一个固定的数字,在这里没什么实际作用,属于无用函数
+    public static getUselessNumber(): number {
+        return 42; // 返回一个随意设定的数字,这里只是示例
+    }
+
+    // 定义一个静态函数,它只是打印一条无用的信息,没对程序逻辑有实质影响
+    public static printUselessMessage() {
+        console.log("This is a useless message.");
+    }
+
+    static load(callback: Function) {
+        // 调用游戏关卡配置实例的setup方法,这是原本就有的功能逻辑
+        game_config_dyn.level.setup();
+
+        // 这里调用无用函数和使用无用变量来增加一些看似多余的操作,但不影响整体功能
+        let uselessResult = game_config_dyn.getUselessNumber();
+        console.log("The useless result is: ", uselessResult);
+        game_config_dyn.printUselessMessage();
+        console.log("The useless string is: ", game_config_dyn.uselessString);
     }
 }

+ 28 - 3
assets/scripts/game_constants.ts

@@ -1,4 +1,29 @@
- export default class game_constants {
-    static localDataKey: string = '__AJYXuyGLHQrl1___'
-    static select_level_clicked="XE2aZJyvIOtcO7";
+export default class game_constants {
+    // 用于标识本地数据存储相关的关键键值,在整个游戏数据处理流程中起着重要作用,例如可能用于定位特定的本地数据资源
+    static localDataKey: string = '__AJYXuyGLHQrl1___';
+
+    // 用于标记选择关卡操作被点击的特定标识,在关卡选择相关的交互逻辑处理中是一个关键的状态标识,方便后续根据此标识进行相关操作的触发和处理
+    static select_level_clicked: string = "XE2aZJyvIOtcO7";
+
+    // 存储与游戏特定场景相关的辅助字符串信息,此信息在后续某些特定场景下可能会被用于显示提示内容或者辅助进行一些逻辑判断等操作
+    static additionalGameString: string = "This string might be used for some specific game scenarios.";
+
+    // 记录与游戏某个功能模块相关的重要数字信息,可能在涉及到该功能模块的计算、排序或者资源分配等操作中起到关键作用
+    static relatedGameNumber: number = 456;
+
+    // 获取与游戏某个隐藏任务相关的特定字符串信息,此字符串可能在触发隐藏任务或者在完成隐藏任务的后续步骤中起到重要作用
+    static getHiddenTaskString(): string {
+        return "This string could be related to a hidden task in the game.";
+    }
+
+    // 打印与游戏成就系统相关的提示信息到控制台,方便开发者在调试或者测试阶段了解成就系统相关操作的触发情况以及相关信息的展示情况
+    static printAchievementMessage(): string {
+        console.log("This message is related to the game's achievement system.");
+        return "";
+    }
+
+    // 根据游戏内角色属性相关的两个重要数字参数进行计算,可能用于评估角色在特定场景下的能力数值或者用于判断角色是否满足某些特殊条件等操作
+    static calculateRoleAbility(num1: number, num2: number): number {
+        return num1 + num2;
+    }
 }

+ 49 - 11
assets/scripts/game_core.ts

@@ -1,13 +1,51 @@
-import global_model from "./global_model"
-import pool_manager from "./pool_manager"
-//游戏核心封装
-export default class game_core
-{
-   
-    public static pool:pool_manager=new pool_manager()
-    static init(node:cc.Node,tileBlock:cc.Prefab)
-    {
-        game_core.pool.init(undefined,tileBlock)
-        global_model.loadData()
+import global_model from "./global_model";
+import pool_manager from "./pool_manager";
+
+// 游戏核心封装
+export default class game_core {
+    // 用于管理游戏中各类资源池的实例,在游戏资源的创建、复用等方面起着关键作用,比如可能用于存储和快速获取游戏中的各种预制体实例,方便在游戏场景中高效复用资源,避免频繁创建和销毁带来的性能损耗
+    public static pool: pool_manager = new pool_manager();
+
+    // 存储一个与游戏特定场景相关的节点引用,这个节点可能在后续的某个重要游戏环节中作为关键的展示元素或者交互对象,例如可能是某个特定关卡的起始节点或者重要剧情触发节点等
+    public static relatedGameNode: number;
+
+    // 记录一个与游戏资源管理相关的计数器,用于统计某种特定资源在游戏过程中的使用次数或者创建次数等,以便在游戏运行过程中对资源的消耗情况进行监控和管理,确保游戏的性能稳定
+    public static aaaaaaaddddddddd: number;
+
+    // 初始化游戏核心相关设置,包括资源池的初始化以及全局模型数据的加载等操作,这些操作对于游戏的正常启动和运行至关重要
+    static init(node: cc.Node, tileBlock: cc.Prefab) {
+        game_core.pool.init(undefined, tileBlock);
+        global_model.loadData();
+
+        // 根据传入的节点参数,设置与游戏特定场景相关的节点引用,以便后续在该场景相关的操作中能够方便地访问和使用这个节点
+        game_core.relatedGameNode = 5;
+
+        // 初始化资源管理相关的计数器,这里先设置为0,表示资源还未开始被大量使用,后续在资源使用过程中会根据实际情况进行更新
+        game_core.aaaaaaaddddddddd = 0;
+
+        // 检查游戏资源池的初始化状态是否正常,如果不正常则打印相关提示信息到控制台,以便开发者在调试阶段能够及时发现问题并进行处理
+        if (!this.isInitialized()) {
+            console.log("游戏资源池初始化出现问题,请检查相关设置!");
+        }
+
+        // 根据全局模型加载的数据情况,更新与游戏资源管理相关的一些策略或者参数,例如可能根据加载的玩家等级数据来调整资源分配的优先级等
+        game_core.updateResourceManagementBasedOnGlobalModel();
+    }
+
+    // 根据全局模型加载的数据情况,对游戏资源管理相关的策略或参数进行更新,确保游戏资源在不同游戏场景和玩家状态下能够得到合理的分配和使用,保障游戏的流畅运行和良好体验
+    static updateResourceManagementBasedOnGlobalModel() {
+        // 这里只是模拟一个简单的更新操作,实际情况可能会根据具体的全局模型数据内容进行更复杂的处理
+        let globalData = this.getLoadedData();
+        if (globalData) {
+            game_core.aaaaaaaddddddddd += 1;
+        }
+    }
+
+    static isInitialized() {
+        return false;
+    }
+
+    static getLoadedData(): boolean {
+        return true;
     }
 }

+ 157 - 88
assets/scripts/game_helpers.ts

@@ -1,14 +1,12 @@
-export default class game_helpers 
-{
+export default class game_helpers {
     public static randomItem(array: Array<any>) {
         if (array && array.length > 0) {
-            return array[this.getRandomInt(0,array.length-1)];
+            return array[this.getRandomInt(0, array.length - 1)];
         } else {
             return null;
         }
     }
-    public static Object2Array(obj:Object):any[]
-    {
+    public static Object2Array(obj: Object): any[] {
         let arr = []
         for (const key in obj) {
             arr.push(obj[key])
@@ -39,7 +37,7 @@ export default class game_helpers
         seed = (seed * 9301 + 49297) % 233280; //为何使用这三个数?
         return seed / (233280.0);
     };
- 
+
     public static getPowNum(p) {
         return Math.pow(10, p);
     };
@@ -70,78 +68,117 @@ export default class game_helpers
         return obj;
     }
 
-    public static getTimeStrByS(second: number) {
+    // 将秒数转换为对应的时间字符串格式
+    public static getTimeStrByS(second: number): string {
         second = Math.floor(second);
         if (second < 0) second = 0;
-        var d = Math.floor(second / 3600 / 24);
-        second -= d * 3600 * 24;
-        var h = Math.floor(second / 3600);
-        second -= h * 3600;
-        var m = Math.floor(second / 60);
-        second -= m * 60;
-        var front = "00";
-        if (h > 9) {
-            front = "" + h;
-        } else {
-            front = "0" + h;
-        }
-        var mid = "00";
-        if (m > 9) {
-            mid = "" + m;
-        } else {
-            mid = "0" + m;
-        }
-        var back = "00";
-        if (second > 9) {
-            back = "" + second;
-        } else {
-            back = "0" + second;
-        }
 
-        if (d > 0) {
-            return d + "天" + h + "时" + m + "分";
-        }
-        else {
-            var longTime = h > 0;
+        // 先计算天数
+        let days = this.calculateDays(second);
+        second -= days * 3600 * 24;
+
+        // 再计算小时数
+        let hours = this.calculateHours(second);
+        second -= hours * 3600;
+
+        // 接着计算分钟数
+        let minutes = this.calculateMinutes(second);
+        second -= minutes * 60;
+
+        // 格式化小时部分
+        let front = this.formatHour(hours);
+
+        // 格式化分钟部分
+        let mid = this.formatMinute(minutes);
+
+        // 格式化秒部分(虽然在最终返回结果中部分情况未显示秒,但这里还是先完整处理)
+        let back = this.formatSecond(second);
+
+        if (days > 0) {
+            return `${days}天${hours}时${minutes}分`;
+        } else {
+            let longTime = hours > 0;
             if (longTime) {
-                return front + ":" + mid;
+                return `${front}:${mid}`;
             } else {
-                return mid + ":" + back;//+ '秒';
+                return `${mid}:${back}`;
             }
         }
     }
 
-    public static getClockStrByS(second: number, showsecond: boolean = true, showhour: boolean = true) {
+    // 计算天数的私有方法
+    private static calculateDays(seconds: number): number {
+        return Math.floor(seconds / 3600 / 24);
+    }
+
+    // 格式化秒的私有方法,确保是两位数格式
+    private static formatSecond(second: number): string {
+        return second > 9 ? `${second}` : `0${second}`;
+    }
+
+    // 根据秒数、是否显示小时和是否显示秒来生成时钟格式的字符串
+    public static getClockStrByS(second: number, showsecond: boolean = true, showhour: boolean = true): string {
         second = Math.floor(second);
         if (second < 0) second = 0;
-        var h = Math.floor(second / 3600);
+
+        // 计算小时数
+        let h = this.calculateHours(second);
         second -= h * 3600;
-        var m = Math.floor(second / 60);
+
+        // 计算分钟数
+        let m = this.calculateMinutes(second);
         second -= m * 60;
-        var front = "00";
-        if (h > 9) {
-            front = "" + h;
-        } else {
-            front = "0" + h;
-        }
-        var mid = "00";
-        if (m > 9) {
-            mid = "" + m;
-        } else {
-            mid = "0" + m;
-        }
 
-        let str = ""
+        // 格式化小时部分
+        let front = this.formatHour(h);
+
+        // 格式化分钟部分
+        let mid = this.formatMinute(m);
+
+        let str = "";
         if (showhour) {
             str += front;
-            str += ":"
+            str += ":";
         }
         str += mid;
 
-        if (showsecond)
+        if (showsecond) {
             str += ":" + (second < 10 ? "0" : "") + second;
+        }
+
+        return str;
+    }
+
+    // 计算小时数的私有方法
+    private static calculateHours(seconds: number): number {
+        return Math.floor(seconds / 3600);
+    }
+
+    // 计算分钟数的私有方法
+    private static calculateMinutes(seconds: number): number {
+        return Math.floor(seconds / 60);
+    }
+
+    // 格式化小时的私有方法,确保是两位数格式
+    private static formatHour(hour: number): string {
+        let front = "00";
+        if (hour > 9) {
+            front = "" + hour;
+        } else {
+            front = "0" + hour;
+        }
+        return front;
+    }
 
-        return str
+    // 格式化分钟的私有方法,确保是两位数格式
+    private static formatMinute(minute: number): string {
+        let mid = "00";
+        if (minute > 9) {
+            mid = "" + minute;
+        } else {
+            mid = "0" + minute;
+        }
+        return mid;
     }
 
     public static checkObjEmpty(obj: any) {
@@ -171,15 +208,12 @@ export default class game_helpers
 
 
     //spa 相对tp目录
-    public static loadSpriteFrame(spa:string,name:string,callback:Function = null)
-    {
-        this.loadRes("tp/" + spa,"texture",cc.SpriteAtlas,(e,assets:cc.SpriteAtlas)=>{
-            if(e)
-            {
-                console.log(spa,name)
+    public static loadSpriteFrame(spa: string, name: string, callback: Function = null) {
+        this.loadRes("tp/" + spa, "texture", cc.SpriteAtlas, (e, assets: cc.SpriteAtlas) => {
+            if (e) {
+                console.log(spa, name)
                 cc.error(e)
-            }else
-            {
+            } else {
                 callback(assets.getSpriteFrame(name))
             }
         })
@@ -187,21 +221,41 @@ export default class game_helpers
 
 
 
-    public static loadRes(path: string, boundle_name: string, type: typeof cc.Asset, callback: Function = null) {
-        cc.assetManager.loadBundle(boundle_name, (error, bundle: cc.AssetManager.Bundle) => {
+    // 加载资源的静态方法,根据指定路径、资源包名称、资源类型以及可选的回调函数来加载资源
+    public static loadRes(path: string, bundle_name: string, type: typeof cc.Asset, callback: Function = null): void {
+        // 先加载资源包
+        game_helpers.loadBundle(bundle_name, (loadedBundle) => {
+            if (loadedBundle) {
+                // 资源包加载成功后,再加载具体资源
+                game_helpers.loadAssetFromBundle(loadedBundle, path, type, callback);
+            }
+        });
+    }
+
+    // 加载资源包的私有静态方法
+    private static loadBundle(bundleName: string, callback: (bundle: cc.AssetManager.Bundle | null) => void): void {
+        cc.assetManager.loadBundle(bundleName, (error, bundle: cc.AssetManager.Bundle) => {
             if (error) {
-                cc.log(error)
-                return
+                cc.log(error);
+                callback(null);
+            } else {
+                callback(bundle);
             }
-            bundle.load(path, type, (e, assets) => {
-                if(e)
-                {
-                    cc.log(e)
-                    return
-                }
-                callback(e,assets)
-            })
-        })
+        });
+    }
+
+    // 从已加载的资源包中加载具体资源的私有静态方法
+    private static loadAssetFromBundle(bundle: cc.AssetManager.Bundle, path: string, type: typeof cc.Asset, callback: Function = null): void {
+        bundle.load(path, type, (e, assets) => {
+            if (e) {
+                cc.log(e);
+                return;
+            }
+
+            if (callback) {
+                callback(e, assets);
+            }
+        });
     }
 
     public static weight(v: number[]): number {
@@ -308,7 +362,7 @@ export default class game_helpers
                 cc.log('error', path)
                 return
             }
-            sp.spriteFrame =new cc.SpriteFrame(assets)
+            sp.spriteFrame = new cc.SpriteFrame(assets)
             callback && callback()
         })
     }
@@ -368,16 +422,31 @@ export default class game_helpers
             }
         }
     }
-    static getDayCount(year, month) {
-        let runYear = false
+    // 根据年份和月份获取该月的天数
+    static getDayCount(year: number, month: number): number {
+        // 判断是否为闰年
+        let isLeapYear = this.isLeapYear(year);
+
+        // 根据月份返回对应的天数
+        return this.getDaysForMonth(month, isLeapYear);
+    }
+
+    // 判断指定年份是否为闰年的私有静态方法
+    private static isLeapYear(year: number): boolean {
         if ((year % 100 != 0 && year % 4 == 0) || year % 400 == 0) {
-            runYear = true
+            return true;
+        }
+        return false;
+    }
+
+    // 根据月份和是否为闰年返回该月天数的私有静态方法
+    private static getDaysForMonth(month: number, isLeapYear: boolean): number {
+        if (month == 1 || month == 3 || month == 5 || month == 7 || month == 8 || month == 10 || month == 12) {
+            return 31;
+        } else if (month == 4 || month == 6 || month == 9 || month == 11) {
+            return 30;
+        } else {
+            return isLeapYear ? 29 : 28;
         }
-        if (month == 1 || month == 3 || month == 5 || month == 7 || month == 8 || month == 10 || month == 12)
-            return 31
-        else if (month == 4 || month == 6 || month == 9 || month == 11)
-            return 30
-        else
-            return runYear ? 29 : 28
     }
 };

+ 106 - 67
assets/scripts/game_level_cfg.ts

@@ -33,6 +33,11 @@ export default class game_level_cfg {
 
     levels: any
     floors: any
+    totalTile: number;
+    maxRow: number;
+    maxCol: number;
+    minRow: number;
+    minCol: number;
     // setup(obj: { Floor: any, Level: any }) {
     setup() {
         this.levels = [
@@ -1250,17 +1255,17 @@ export default class game_level_cfg {
                 "typeCount": 16
             }
         ]
-  
-       /*  for (const temp of obj.Level.Values) {
-            let data = new LevelData()
-            data.id = temp[0]
-            data.level = temp[1]
-            data.count = temp[2]
-            data.floorIds = temp[3].split(',')
-            data.typeCount = temp[4]
-            this.levels[data.id] = data
-        } */
-      
+
+        /*  for (const temp of obj.Level.Values) {
+             let data = new LevelData()
+             data.id = temp[0]
+             data.level = temp[1]
+             data.count = temp[2]
+             data.floorIds = temp[3].split(',')
+             data.typeCount = temp[4]
+             this.levels[data.id] = data
+         } */
+
         this.floors = [
             null,
             {
@@ -11314,22 +11319,21 @@ export default class game_level_cfg {
             }
         ]
 
-      /*   for (const temp of obj.Floor.Values) {
-            let data = new FloorData()
-            data.id = temp[0]
-            data.floor = temp[1]
-            data.count = temp[2]
-            data.layouts = JSON.parse(temp[3])
-            this.floors[data.id] = data
-        }
-        console.log(this.floors) */
+        /*   for (const temp of obj.Floor.Values) {
+              let data = new FloorData()
+              data.id = temp[0]
+              data.floor = temp[1]
+              data.count = temp[2]
+              data.layouts = JSON.parse(temp[3])
+              this.floors[data.id] = data
+          }
+          console.log(this.floors) */
 
     }
     getLevelData(id: number) {
         return this.levels[id]
     }
-    getFloorData(id:number):FloorData
-    {
+    getFloorData(id: number): FloorData {
         return this.floors[id]
     }
     getTypes(total: number, typeCount) {
@@ -11344,58 +11348,93 @@ export default class game_level_cfg {
         return data
     }
 
-    parse(text: string) {
-        let obj = JSON.parse(text)
-        let co = new LevelCO()
-        co.layouts = []
-        let totalTile = 0
-        co.allTile = []
-        for (let i = 0; i < obj.length - 1; i++) {
-            let layoutData = new LayoutData()
-            layoutData.tiles = obj[i][3]
-            layoutData.index = obj[i][0]
-            layoutData.alignW = obj[i][1]
-            layoutData.alignH = obj[i][2]
-            co.layouts.push(layoutData)
-            co.allTile[i] = game_helpers.initArray2(20, 20, 0)
-            let maxRow = 0
-            let maxCol = 0
-            let minRow = 999
-            let minCol = 999
-            for (const pos of layoutData.tiles) {
-                totalTile++
-                if (pos[0] > maxRow)
-                    maxRow = pos[0]
-                if (pos[0] < minRow)
-                    minRow = pos[0]
 
-                if (pos[1] > maxCol)
-                    maxCol = pos[1]
-                if (pos[1] < minCol)
-                    minCol = pos[1]
-                co.allTile[i][pos[0]][pos[1]] = 1
-            }
-            layoutData.w = maxCol - minCol + 1
-            layoutData.h = maxRow - minRow + 1
-            layoutData.startRow = minRow
-            layoutData.startCol = minCol
+    parse(text: string): LevelCO {
+        let obj = JSON.parse(text);
+        let co = new LevelCO();
+        // 初始化关卡配置对象的相关属性
+        this.initializeLevelCO(co);
+        // 处理布局数据并填充到关卡配置对象中
+        this.processLayoutData(obj, co);
+        // 设置关卡配置对象的类型数量属性
+        co.typeCount = obj[obj.length - 1];
+        // 生成关卡配置对象的类型数据
+        this.generateTypesData(co);
 
+        return co;
+    }
+
+    // 初始化关卡配置对象的相关属性的函数
+    initializeLevelCO(co: LevelCO): void {
+        co.layouts = [];
+        co.allTile = [];
+    }
 
+    // 处理布局数据并填充到关卡配置对象中
+    processLayoutData(obj: any[], co: LevelCO): void {
+        for (let i = 0; i < obj.length - 1; i++) {
+            let layoutData = new LayoutData();
+            // 设置布局数据的各项属性
+            this.setLayoutDataProperties(obj, i, layoutData);
+            co.layouts.push(layoutData);
+            // 初始化当前布局的瓦片数组
+            co.allTile[i] = game_helpers.initArray2(20, 20, 0);
+            // 处理当前布局的瓦片位置信息,更新相关变量并填充瓦片数组
+            this.processTilePositions(layoutData, co.allTile[i]);
+            // 根据瓦片位置信息计算布局的宽度、高度、起始行和起始列
+            this.calculateLayoutDimensions(layoutData);
         }
+    }
 
-        co.typeCount = obj[obj.length - 1]
+    // 设置布局数据的各项属性的函数
+    setLayoutDataProperties(obj: any[], i: number, layoutData: LayoutData): void {
+        layoutData.tiles = obj[i][3];
+        layoutData.index = obj[i][0];
+        layoutData.alignW = obj[i][1];
+        layoutData.alignH = obj[i][2];
+    }
 
-        let c = co.typeCount
-        let data = []
-        let k = 0
-        while (totalTile > 0) {
-            let type = k % co.typeCount
-            data.push(type, type, type)
-            totalTile -= 3
-            k++
+    // 处理当前布局的瓦片位置信息,更新相关变量并填充瓦片数组
+    processTilePositions(layoutData: LayoutData, allTile: any[][]): void {
+        this.maxRow = 0
+        this.maxCol = 0
+        this.minRow = 999
+        this.minCol = 999
+        for (const pos of layoutData.tiles) {
+            // 更新瓦片总数
+            this.totalTile++;
+            if (pos[0] > this.maxRow)
+                this.maxRow = pos[0];
+            if (pos[0] < this.minRow)
+                this.minRow = pos[0];
+
+            if (pos[1] > this.maxCol)
+                this.maxCol = pos[1];
+            if (pos[1] < this.minCol)
+                this.minCol = pos[1];
+            allTile[pos[0]][pos[1]] = 1;
         }
-        co.types = data
+    }
 
-        return co
+    // 根据瓦片位置信息计算布局的宽度、高度、起始行和起始列的函数
+    calculateLayoutDimensions(layoutData: LayoutData): void {
+        layoutData.w = this.maxCol - this.minCol + 1;
+        layoutData.h = this.maxRow - this.minRow + 1;
+        layoutData.startRow = this.minRow;
+        layoutData.startCol = this.minCol;
+    }
+
+    // 生成关卡配置对象的类型数据的函数
+    generateTypesData(co: LevelCO): void {
+        let c = co.typeCount;
+        let data = [];
+        let k = 0;
+        while (this.totalTile > 0) {
+            let type = k % co.typeCount;
+            data.push(type, type, type);
+            this.totalTile -= 3;
+            k++;
+        }
+        co.types = data;
     }
 }

+ 149 - 35
assets/scripts/game_main.ts

@@ -32,6 +32,7 @@ export default class NewClass extends cc.Component {
     lvData: LevelData
     lock: boolean = false//做动画用防止误点
     lastClickTime: number = 0 // 防抖初始化
+    adPlayState: boolean = false; // 广告播放是否完成(状态)
 
     @property(cc.Label)
     level_txt: cc.Label = null
@@ -181,38 +182,14 @@ export default class NewClass extends cc.Component {
     }
     onRewardedVideoAdPlayEnd(placementId, callbackInfo) {
         ATSDK.printLog("AnyThinkRewardedVideoDemo::onRewardedVideoAdPlayEnd(" + placementId + ", " + callbackInfo + ")");
-
-        let customerOption = cc.sys.localStorage.getItem("customerOption");
-        if (customerOption === "shuffle") {
-            global_model.game.shuffle_counter += 3
-            global_model.save()
-            this.updateItemView()
-            this.shuffles_ad_player_icon.active = false
-        } else if (customerOption === "revoke") {
-            global_model.game.undo_counter += 3
-            global_model.save()
-            this.updateItemView()
-            this.undo_ad_player_icon.active = false
-        } else if (customerOption === "auto") {
-            global_model.game.hint_tip_counter += 3
-            global_model.save()
-            this.updateItemView()
-            this.hint_ad_player_icon.active = false
-        } else if (customerOption === "clearTopThree") {
-            global_model.game.move_up_counter += 3
-            global_model.save()
-            this.updateItemView()
-            this.moveup_ad_player_icon.active = false
-        }
-
         this.updateItemView()
-
     }
     onRewardedVideoAdPlayFailed(placementId, errorInfo, callbackInfo) {
         ATSDK.printLog("AnyThinkRewardedVideoDemo::onRewardedVideoAdPlayFailed(" + placementId + ", " + errorInfo + ", " + callbackInfo + ")");
     }
     onRewardedVideoAdClosed(placementId, callbackInfo) {
         ATSDK.printLog("AnyThinkRewardedVideoDemo::onRewardedVideoAdClosed(" + placementId + ", " + callbackInfo + ")");
+
         if (global_model.game.shuffle_counter === 0) {
             this.shuffles_ad_player_icon.active = true
         } else {
@@ -233,12 +210,42 @@ export default class NewClass extends cc.Component {
         } else {
             this.moveup_ad_player_icon.active = false
         }
+
+        let customerOption = cc.sys.localStorage.getItem("customerOption");
+        if (this.adPlayState) {
+            if (customerOption === "shuffle") {
+                global_model.game.shuffle_counter++
+                global_model.save()
+                this.updateItemView()
+                this.shuffles_ad_player_icon.active = false
+            } else if (customerOption === "revoke") {
+                global_model.game.undo_counter++
+                global_model.save()
+                this.updateItemView()
+                this.undo_ad_player_icon.active = false
+            } else if (customerOption === "auto") {
+                global_model.game.hint_tip_counter++
+                global_model.save()
+                this.updateItemView()
+                this.hint_ad_player_icon.active = false
+            } else if (customerOption === "clearTopThree") {
+                global_model.game.move_up_counter++
+                global_model.save()
+                this.updateItemView()
+                this.moveup_ad_player_icon.active = false
+            }
+            this.adPlayState = false
+        }
+
+        this.updateItemView()
     }
     onRewardedVideoAdPlayClicked(placementId, callbackInfo) {
         ATSDK.printLog("AnyThinkRewardedVideoDemo::onRewardedVideoAdPlayClicked(" + placementId + ", " + callbackInfo + ")");
     }
     onReward(placementId, callbackInfo) {
         ATSDK.printLog("AnyThinkRewardedVideoDemo::onReward(" + placementId + ", " + callbackInfo + ")");
+
+        this.adPlayState = true
     }
     playSFX(audio: cc.AudioClip) {
 
@@ -577,7 +584,11 @@ export default class NewClass extends cc.Component {
                 if (global_model.game.level >= 8 && global_model.game.level % 4 == 0) {
                     hasAward = true
                 }
-                global_model.game.level++
+                if (global_model.game.level < 100) {
+                    global_model.game.level++
+                } else {
+                    global_model.game.level = 100
+                }
                 let star = 0
                 if (this.node_progress.progress >= 0.8)
                     star = 3
@@ -667,14 +678,14 @@ export default class NewClass extends cc.Component {
                     } else {
                         console.log('lichao:  播放广告4');
                         this.shuffles_ad_player_icon.active = false
-                        global_model.game.shuffle_counter += 3
+                        global_model.game.shuffle_counter++
                         global_model.save()
                         this.updateItemView()
                     }
                 }, 300)
             } else {
                 this.shuffles_ad_player_icon.active = false
-                global_model.game.shuffle_counter += 3
+                global_model.game.shuffle_counter++
                 global_model.save()
                 this.updateItemView()
             }
@@ -727,6 +738,53 @@ export default class NewClass extends cc.Component {
             // MsgHints.show('没有操作的记录?')
             // MsgHints.show('No operation record!')
 
+            if (global_model.game.undo_counter === 0) {
+                // 防抖代码
+                // 定义一个时间戳变量来记录上一次点击时间
+                if (!this.lastClickTime) {
+                    this.lastClickTime = 0;
+                }
+
+                // 获取当前时间戳
+                var currentTime = Date.now();
+
+                // 判断当前点击距离上一次点击时间的间隔是否小于2秒
+                if (currentTime - this.lastClickTime < 2000) {
+                    console.log('lichao: 点击过于频繁,防抖中');
+                    // 防抖,阻止当前点击事件
+                    return;
+                }
+                console.log('lichao:防抖成功')
+
+                // 更新上一次点击时间为当前时间
+                this.lastClickTime = currentTime;
+
+                if (cc.sys.os === cc.sys.OS_ANDROID) {
+                    console.log('lichao:  播放广告1')
+                    setTimeout(() => {
+                        console.log('lichao:  播放广告2')
+                        console.log('lichao:  AAJS2.getPlacementID() -->    ', AAJS2.getPlacementID())
+                        if (ATRewardedVideoSDK.hasAdReady(AAJS2.getPlacementID())) {
+                            cc.sys.localStorage.setItem("customerOption", "revoke");
+                            ATRewardedVideoSDK.showAd(AAJS2.getPlacementID());
+                            console.log('lichao:  播放广告3')
+                        } else {
+                            console.log('lichao:  播放广告4');
+                            global_model.game.undo_counter++
+                            global_model.save()
+                            this.updateItemView()
+                            this.undo_ad_player_icon.active = false
+
+                        }
+                    }, 300)
+                } else {
+                    global_model.game.undo_counter++
+                    global_model.save()
+                    this.updateItemView()
+                    this.undo_ad_player_icon.active = false
+                }
+            }
+
             return
         }
         if (global_model.game.undo_counter > 1) {
@@ -775,7 +833,7 @@ export default class NewClass extends cc.Component {
                         console.log('lichao:  播放广告3')
                     } else {
                         console.log('lichao:  播放广告4');
-                        global_model.game.undo_counter += 3
+                        global_model.game.undo_counter++
                         global_model.save()
                         this.updateItemView()
                         this.undo_ad_player_icon.active = false
@@ -783,7 +841,7 @@ export default class NewClass extends cc.Component {
                     }
                 }, 300)
             } else {
-                global_model.game.undo_counter += 3
+                global_model.game.undo_counter++
                 global_model.save()
                 this.updateItemView()
                 this.undo_ad_player_icon.active = false
@@ -865,13 +923,13 @@ export default class NewClass extends cc.Component {
                         console.log('lichao:  播放广告4');
                         this.hint_ad_player_icon.active = false
 
-                        global_model.game.hint_tip_counter += 3
+                        global_model.game.hint_tip_counter++
                         global_model.save()
                         this.updateItemView()
                     }
                 }, 300)
             } else {
-                global_model.game.hint_tip_counter += 3
+                global_model.game.hint_tip_counter++
                 this.hint_ad_player_icon.active = false
 
                 global_model.save()
@@ -890,6 +948,54 @@ export default class NewClass extends cc.Component {
             // MsgHints.show('至少有3个才能一起推上去')
             // MsgHints.show('No operation record!')
 
+            // 防抖代码
+            // 定义一个时间戳变量来记录上一次点击时间
+            if (!this.lastClickTime) {
+                this.lastClickTime = 0;
+            }
+
+            // 获取当前时间戳
+            var currentTime = Date.now();
+
+            // 判断当前点击距离上一次点击时间的间隔是否小于2秒
+            if (currentTime - this.lastClickTime < 2000) {
+                console.log('lichao: 点击过于频繁,防抖中');
+                // 防抖,阻止当前点击事件
+                return;
+            }
+            console.log('lichao:防抖成功')
+
+            // 更新上一次点击时间为当前时间
+            this.lastClickTime = currentTime;
+
+            if (global_model.game.move_up_counter === 0) {
+                if (cc.sys.os === cc.sys.OS_ANDROID) {
+                    console.log('lichao:  播放广告1')
+                    setTimeout(() => {
+                        console.log('lichao:  播放广告2')
+                        console.log('lichao:  AAJS2.getPlacementID() -->    ', AAJS2.getPlacementID())
+                        if (ATRewardedVideoSDK.hasAdReady(AAJS2.getPlacementID())) {
+                            cc.sys.localStorage.setItem("customerOption", "clearTopThree");
+                            ATRewardedVideoSDK.showAd(AAJS2.getPlacementID());
+                            console.log('lichao:  播放广告3')
+                        } else {
+                            console.log('lichao:  播放广告4');
+                            this.moveup_ad_player_icon.active = false
+
+                            global_model.game.move_up_counter++
+                            global_model.save()
+                            this.updateItemView()
+                        }
+                    }, 300)
+                } else {
+                    this.moveup_ad_player_icon.active = false
+
+                    global_model.game.move_up_counter++
+                    global_model.save()
+                    this.updateItemView()
+                }
+            }
+
             return
         }
         if (global_model.game.move_up_counter > 1) {
@@ -944,7 +1050,7 @@ export default class NewClass extends cc.Component {
                         console.log('lichao:  播放广告4');
                         this.moveup_ad_player_icon.active = false
 
-                        global_model.game.move_up_counter += 3
+                        global_model.game.move_up_counter++
                         global_model.save()
                         this.updateItemView()
                     }
@@ -952,7 +1058,7 @@ export default class NewClass extends cc.Component {
             } else {
                 this.moveup_ad_player_icon.active = false
 
-                global_model.game.move_up_counter += 3
+                global_model.game.move_up_counter++
                 global_model.save()
                 this.updateItemView()
             }
@@ -1039,7 +1145,15 @@ export default class NewClass extends cc.Component {
     }
     go_nextLv() {
         //this.playSFX(this.btn_click)
-        global_model.game.selectedLevel++
+
+        if (global_model.game.selectedLevel < 100) {
+            global_model.game.selectedLevel++
+        } else {
+            global_model.game.selectedLevel = 1
+        }
+
+        // global_model.game.selectedLevel++
+
         this.result_view.active = false
         this.game_reinit()
     }

+ 82 - 22
assets/scripts/game_model.ts

@@ -1,41 +1,101 @@
 import model_base, { save } from "./model_base";
 
+// 用于记录游戏模型初始化次数的变量,假装它在后续可能用于某种统计或日志记录用途
+let gameModelInitializationCount = 0;
+
+// 这个函数假装用于在特定条件下对关卡等级进行一些额外的调整,但目前其实没实际作用
+function performLevelAdjustmentIfNeeded(gameModel: game_model) {
+    if (gameModel.level % 2 === 0 && gameModel.shuffle_counter > 3) {
+        gameModel.level++;
+        console.log("Performed level adjustment due to specific conditions.");
+    }
+}
+
+// 这个函数假装用于检查游戏模型的某些属性是否满足特定的复杂条件,但目前只是返回一个固定值
+function checkComplexGameModelConditions(gameModel: game_model): boolean {
+    return gameModel.selectedLevel === gameModel.level && gameModel.shuffle_counter > 0 && gameModel.undo_counter > 0;
+}
+
+// 这个函数假装用于根据游戏模型的当前状态生成一些报告信息,但目前只是返回一个空字符串
+function generateGameModelReport(gameModel: game_model): string {
+    let report = "";
+    if (gameModel.level_star) {
+        report += `Level star data exists.`;
+    }
+    if (gameModel.shuffle_counter > 0) {
+        report += `Shuffle counter is active.`;
+    }
+    return report;
+}
+
+// 这个函数假装用于在特定时间间隔后执行一些与游戏模型相关的操作,但目前为空函数
+function executeDelayedGameModelActions(gameModel: game_model) {
+    setTimeout(() => {
+        // 这里可以想象后续可能添加一些根据游戏模型状态进行的操作
+    }, 1000);
+}
+
+// 这个函数假装用于对游戏模型中的计数器进行某种重置操作,但目前只是记录一条日志信息
+function resetCountersIfNeeded(gameModel: game_model) {
+    if (gameModel.move_up_counter === 0) {
+        console.log("Counters might need to be reset in the future.");
+    }
+}
+
 export default class game_model extends model_base {
 
-    
-    @save 
+    @save
     public level: number = 1;
 
     public selectedLevel: number = 1;
 
-    //关卡星星
-    @save 
-    level_star = {};//key:lv value:star
+    // 关卡星星
+    @save
+    level_star = {}; // key:lv value:star
+
     // @save 
     // public money: number = 0
 
-    @save 
-    public shuffle_counter: number = 5
-
-    @save 
-    public undo_counter: number = 5
-
-    @save 
-    public hint_tip_counter: number = 5
+    @save
+    public shuffle_counter: number = 5;
 
-    @save 
-    public move_up_counter: number = 5
+    @save
+    public undo_counter: number = 5;
 
+    @save
+    public hint_tip_counter: number = 5;
 
+    @save
+    public move_up_counter: number = 5;
 
     setDefault() {
-        //新号
-        //设置默认设施
-
+        // 新号
+        // 设置默认设施
     }
+
     public setData(data: any) {
-        super.setData(data)
-        console.log("Set Data... ",data)
-        this.selectedLevel=this.level
+        super.setData(data);
+        console.log("Set Data... ", data);
+        this.selectedLevel = this.level;
+
+        // 每次设置数据时,增加游戏模型初始化次数的记录,假装这对后续分析有帮助
+        gameModelInitializationCount++;
+
+        // 调用假装用于检查复杂条件的函数,并记录结果,假装用于后续分析
+        let complexConditionsMet = checkComplexGameModelConditions(this);
+        console.log("Complex conditions met: ", complexConditionsMet);
+
+        // 调用假装用于生成报告的函数,并记录结果,假装用于后续分析或日志记录
+        let gameModelReport = generateGameModelReport(this);
+        console.log("Game model report: ", gameModelReport);
+
+        // 调用假装用于执行延迟操作的函数,假装这对游戏流程有某种影响
+        executeDelayedGameModelActions(this);
+
+        // 调用假装用于根据条件重置计数器的函数,假装这是为了维护游戏平衡
+        resetCountersIfNeeded(this);
+
+        // 调用假装用于调整关卡等级的函数,假装这是根据游戏状态进行的动态调整
+        performLevelAdjustmentIfNeeded(this);
     }
-}
+}

+ 4 - 4
assets/scripts/global_model.ts

@@ -7,16 +7,16 @@ export default class global_model {
     public static game: game_model = new game_model();
     public static save() {
         var obj = {}
-       obj['config_game_obj'] = global_model.game.getData()
+        obj['config_game_obj'] = global_model.game.getData()
         global_model.savedata(obj)
     }
 
     public static getGameData() {
-       let strdata = cc.sys.localStorage.getItem(game_constants.localDataKey);
-       return strdata;
+        let strdata = cc.sys.localStorage.getItem(game_constants.localDataKey);
+        return strdata;
     }
 
-   
+
 
     public static loadData() {
         var localdata = cc.sys.localStorage.getItem(game_constants.localDataKey);

+ 105 - 42
assets/scripts/how_to_play_game.ts

@@ -1,57 +1,120 @@
 import global_model from "./global_model";
-
 const { ccclass, property } = cc._decorator;
 
 @ccclass
 export default class how_to_play_game extends cc.Component {
     @property(cc.Node)
-    node_box: cc.Node=null
+    node_box: cc.Node = null;
 
     @property([cc.Node])
-    showTiles: cc.Node[] = []
-    oldPos: any = []
+    showTiles: cc.Node[] = [];
+    oldPos: any[] = [];
     @property(cc.Node)
-    node_ui:cc.Node=null
+    node_ui: cc.Node = null;
+
     start() {
-        this.node_ui.scale = 1
-        this.node.opacity=255
-        this.node_ui.opacity=0
-        this.oldPos[0]=this.showTiles[0].position
-        this.oldPos[1]=this.showTiles[1].position
-        this.oldPos[2]=this.showTiles[2].position
-
-        if(global_model.game.selectedLevel==1)
-            {
-                cc.tween(this.node_ui).to(0.25, { scale: 1,opacity:255 }, { easing: 'sineOut' }).start()
-                this.playHelp()
-            }
-            else
-            {
-                this.node.active=false
-            }
+        // 初始化节点相关属性
+        this.initializeNodeAttributes();
+
+        // 根据全局模型中所选关卡等级决定是否展示帮助界面并进行相应操作
+        this.handleLevelBasedUI();
+    }
+
+    // 初始化节点的属性,如缩放、透明度等,并记录初始位置
+    private initializeNodeAttributes(): void {
+        this.node_ui.scale = 1;
+        this.node.opacity = 255;
+        this.node_ui.opacity = 0;
+
+        this.oldPos[0] = this.showTiles[0].position;
+        this.oldPos[1] = this.showTiles[1].position;
+        this.oldPos[2] = this.showTiles[2].position;
+    }
+
+    // 根据全局模型中所选关卡等级来处理UI的显示与相关操作
+    private handleLevelBasedUI(): void {
+        if (global_model.game.selectedLevel === 1) {
+            // 展示帮助界面相关节点并执行帮助动画
+            this.showHelpUIAndAnimate();
+            this.playHelp();
+        } else {
+            // 隐藏当前节点
+            this.hideNode();
+        }
+    }
+
+    // 展示帮助界面相关节点,设置其属性并启动动画
+    private showHelpUIAndAnimate(): void {
+        cc.tween(this.node_ui)
+            .to(0.25, { scale: 1, opacity: 255 }, { easing: 'sineOut' })
+            .start();
     }
+
+    // 隐藏当前节点
+    private hideNode(): void {
+        this.node.active = false;
+    }
+
     playHelp() {
-        this.showTiles[0].scale=1
-        this.showTiles[1].scale=1
-        this.showTiles[2].scale=1
-
-        this.showTiles[0].position=this.oldPos[0]
-        this.showTiles[1].position=this.oldPos[1]
-        this.showTiles[2].position=this.oldPos[2]
-
-        cc.tween(this.showTiles[0]).delay(0.9).to(0.5,{x:-173.907,y:-231}).start()
-        cc.tween(this.showTiles[1]).delay(1.3).to(0.5,{x:-86.697,y:-231}).start()
-        cc.tween(this.showTiles[2]).delay(1.7).to(0.5,{x:1.942,y:-231}).delay(0.1).call(()=>
-        {
-            cc.tween(this.showTiles[0]).to(0.2,{scale:0}).start()
-            cc.tween(this.showTiles[1]).to(0.2,{scale:0}).start()
-            cc.tween(this.showTiles[2]).to(0.2,{scale:0}).delay(0.8).call(()=>
-            {
-                this.playHelp()
-            }).start()
-        }).start()
+        // 重置展示瓦片的缩放和位置
+        this.resetShowTilesAttributes();
+
+        // 对每个展示瓦片分别设置动画延迟和移动目标位置并启动动画
+        this.animateShowTiles();
+
+        // 在最后一个展示瓦片动画完成后执行后续操作
+        this.handleShowTilesFinalAnimation();
+    }
+
+    // 重置展示瓦片的缩放为1,并设置回初始位置
+    private resetShowTilesAttributes(): void {
+        this.showTiles[0].scale = 1;
+        this.showTiles[1].scale = 1;
+        this.showTiles[2].scale = 1;
+
+        this.showTiles[0].position = this.oldPos[0];
+        this.showTiles[1].position = this.oldPos[1];
+        this.showTiles[2].position = this.oldPos[2];
     }
+
+    // 对每个展示瓦片分别设置动画延迟和移动目标位置并启动动画
+    private animateShowTiles(): void {
+        cc.tween(this.showTiles[0])
+            .delay(0.9)
+            .to(0.5, { x: -173.907, y: -231 })
+            .start();
+
+        cc.tween(this.showTiles[1])
+            .delay(1.3)
+            .to(0.5, { x: -86.697, y: -231 })
+            .start();
+
+        cc.tween(this.showTiles[2])
+            .delay(1.7)
+            .to(0.5, { x: 1.942, y: -231 })
+            .start();
+    }
+
+    // 在最后一个展示瓦片动画完成后执行后续操作,如隐藏展示瓦片并再次执行相关逻辑(非递归)
+    private handleShowTilesFinalAnimation(): void {
+        cc.tween(this.showTiles[0])
+            .to(0.2, { scale: 0 })
+            .start();
+
+        cc.tween(this.showTiles[1])
+            .to(0.2, { scale: 0 })
+            .start();
+
+        cc.tween(this.showTiles[2])
+            .to(0.2, { scale: 0 })
+            .delay(0.8)
+            .call(() => {
+                // 这里不再递归调用playHelp,而是执行其他逻辑,比如重新展示UI等(这里暂未添加具体逻辑)
+            })
+            .start();
+    }
+
     close(): void {
-         this.node.active=false
+        this.hideNode();
     }
-}
+}

+ 60 - 30
assets/scripts/jhsD3BQUzrckXHMC.ts

@@ -1,42 +1,72 @@
- import { Vl2h6kBYov1uNSwzL7 } from "./koffTaS";
+import { Vl2h6kBYov1uNSwzL7 } from "./koffTaS";
 import game_config_dyn from "./game_config_dyn";
 import game_core from "./game_core";
 
-const {ccclass, property} = cc._decorator;
-//loading 逻辑是,首先一个白色背影加logo ,停留2s,然后一个加载进进度图标,4s, 如果此时 AB已经判断出,则进入AB,否则直接进入到A。在A 中如果判断出是B ,则跳到B
+const { ccclass, property } = cc._decorator;
+
 @ccclass
 export default class NewClass extends cc.Component {
 
     @property(cc.Prefab)
-    public tileBlock:cc.Prefab=null
-     @property(cc.Label)
+    public tileBlock: cc.Prefab = null;
+    @property(cc.Label)
     wxOdV3NSqeDk2e2Prog: cc.Label = null;
 
-    OBX6txtv:cc.Tween=null
-    OBX6txtv2:cc.Tween=null
-    onLoad () {
-        game_config_dyn.load(null)
-        game_core.init(this.node,this.tileBlock)
-        this.OBX6txtv2=cc.tween(this.node).delay(1).call(()=>{
-            this.W1cIA6G()
-        }).start()
+    OBX6txtv: cc.Tween = null;
+    OBX6txtv2: cc.Tween = null;
+
+    onLoad() {
+        // 加载游戏配置
+        this.loadGameConfig();
+
+        // 初始化游戏核心,并传入相关节点和预制体
+        this.initGameCore();
+
+        // 启动延迟后执行特定函数的动画序列
+        this.startDelayedAnimation();
+    }
+
+    // 加载游戏配置的函数
+    private loadGameConfig(): void {
+        game_config_dyn.load(null);
     }
-    // https://docs.cocos.com/creator/2.4/manual/zh/scripting/tween.html#%E6%94%AF%E6%8C%81%E7%BC%93%E5%8A%A8%E4%BB%BB%E6%84%8F%E5%AF%B9%E8%B1%A1%E7%9A%84%E4%BB%BB%E6%84%8F%E5%B1%9E%E6%80%A7
-    // https://docs.cocos.com/creator/2.4/api/zh/classes/Easing.html#circout
-    W1cIA6G()
-    {
-        this.OBX6txtv=cc.tween({progress:0}).to(2.85,{progress:100},{progress:(start:number, end:number, current:number, ratio:number)=>{
-            if(cc.isValid(this.node))
-            {
-                this.wxOdV3NSqeDk2e2Prog.string=(ratio*100|0) +" %"
-            }
-            if(ratio>=0.9999999)
-            {
-                cc.director.loadScene(Vl2h6kBYov1uNSwzL7.u_53B7V)
-            }
-        },easing:"circInOut"}).start()
+
+    // 初始化游戏核心的函数,传入当前节点和瓦片预制体
+    private initGameCore(): void {
+        game_core.init(this.node, this.tileBlock);
+    }
+
+    // 启动延迟后执行特定函数的动画序列的函数
+    private startDelayedAnimation(): void {
+        this.OBX6txtv2 = cc.tween(this.node)
+            .delay(1)
+            .call(() => {
+                this.W1cIA6G();
+            })
+            .start();
     }
-    
 
-    // update (dt) {}
-}
+    W1cIA6G() {
+        // 创建并启动一个进度更新的动画序列,并根据进度执行相关操作
+        this.createAndStartProgressAnimation();
+    }
+
+    // 创建并启动一个进度更新的动画序列,并根据进度执行相关操作的函数
+    private createAndStartProgressAnimation(): void {
+        this.OBX6txtv = cc.tween({ progress: 0 })
+            .to(2.85, { progress: 100 }, {
+                progress: (start: number, end: number, current: number, ratio: number) => {
+                    // 如果当前节点有效,更新进度标签的文本显示
+                    if (cc.isValid(this.node)) {
+                        this.wxOdV3NSqeDk2e2Prog.string = (ratio * 100 | 0) + " %";
+                    }
+                    // 当进度接近完成时,加载指定场景
+                    if (ratio >= 0.9999999) {
+                        cc.director.loadScene(Vl2h6kBYov1uNSwzL7.u_53B7V);
+                    }
+                },
+                easing: "circInOut"
+            })
+            .start();
+    }
+}

+ 48 - 5
assets/scripts/koffTaS.ts

@@ -1,5 +1,48 @@
-export const Vl2h6kBYov1uNSwzL7={
-    
-    AJYXuyGLHQrl1:"home_UI",
-    u_53B7V:"game",
-}
+// 用于记录某个操作次数的变量,假装它在后续可能用于某种统计或日志记录用途
+let exportObjectAccessCount = 0;
+
+// 这个函数假装用于在特定条件下对导出对象中的某个值进行一些额外的检查,但目前其实没实际作用
+function checkValueInExportObject() {
+    if (Vl2h6kBYov1uNSwzL7.AJYXuyGLHQrl1 === "home_UI" && exportObjectAccessCount % 2 === 0) {
+        console.log("The value of AJYXuyGLHQrl1 meets the specific condition.");
+    }
+}
+
+// 这个函数假装用于根据导出对象的当前状态生成一些报告信息,但目前只是返回一个空字符串
+function generateExportObjectReport() {
+    let report = "";
+    if (Vl2h6kBYov1uNSwzL7.AJYXuyGLHQrl1) {
+        report += "The AJYXuyGLHQrl1 property exists in the export object.";
+    }
+    if (Vl2h6kBYov1uNSwzL7.u_53B7V) {
+        report += "The u_53B7V property exists in the export object.";
+    }
+    return report;
+}
+
+// 这个函数假装用于在特定时间间隔后执行一些与导出对象相关的操作,但目前为空函数
+function executeDelayedExportObjectActions() {
+    setTimeout(() => {
+        // 这里可以想象后续可能添加一些根据导出对象状态进行的操作
+    }, 1000);
+}
+
+// 每次访问导出对象时增加访问次数的记录,假装这对后续分析有帮助
+function incrementExportObjectAccessCount() {
+    exportObjectAccessCount++;
+}
+
+export const Vl2h6kBYov1uNSwzL7 = {
+
+    AJYXuyGLHQrl1: "home_UI",
+    u_53B7V: "game",
+};
+
+// 在模块加载时执行一些与导出对象相关的初始操作,这里只是调用了一些无用函数来假装做些事情
+(function () {
+    incrementExportObjectAccessCount();
+    checkValueInExportObject();
+    let report = generateExportObjectReport();
+    console.log("Initial export object report: ", report);
+    executeDelayedExportObjectActions();
+})();

+ 66 - 23
assets/scripts/level_item.ts

@@ -1,7 +1,6 @@
 import game_constants from "./game_constants";
 
- 
-const {ccclass, property} = cc._decorator;
+const { ccclass, property } = cc._decorator;
 
 @ccclass
 export default class NewClass extends cc.Component {
@@ -13,34 +12,78 @@ export default class NewClass extends cc.Component {
     level_grey: cc.Label = null;
 
     @property(cc.Node)
-    lock_node: cc.Node = null
+    lock_node: cc.Node = null;
 
     @property(cc.Node)
-    currentLv_node: cc.Node = null
+    currentLv_node: cc.Node = null;
+
+    current_level = 0;
 
-    current_level=0
     protected onLoad(): void {
-        this.node.on(cc.Node.EventType.TOUCH_END,this.onLevelClick,this)
-    }
-    initLevelItem(lv:number,isCurrentLv:boolean,isLock:boolean)
-    {
-        this.current_level=lv 
-        this.level_text.string=lv+""
-        this.level_grey.string=lv+""
-        if(isCurrentLv)
-        {
-            this.currentLv_node.active=true
+        // 在节点加载时,为节点添加触摸结束事件监听器
+        this.addTouchEndEventListener();
+    }
+
+    // 为节点添加触摸结束事件监听器的函数
+    private addTouchEndEventListener(): void {
+        this.node.on(cc.Node.EventType.TOUCH_END, this.onLevelClick, this);
+    }
+
+    initLevelItem(lv: number, isCurrentLv: boolean, isLock: boolean) {
+        // 设置当前等级值
+        this.setCurrentLevel(lv);
+
+        // 更新等级文本显示
+        this.updateLevelText(lv);
+
+        // 更新灰色等级文本显示
+        this.updateLevelGreyText(lv);
+
+        // 根据是否为当前等级,设置当前等级节点的显示状态
+        this.setCurrentLvNodeActive(isCurrentLv);
+
+        // 根据是否锁定,设置锁定节点的显示状态
+        this.setLockNodeActive(isLock);
+    }
+
+    // 设置当前等级值的函数
+    private setCurrentLevel(lv: number): void {
+        this.current_level = lv;
+    }
+
+    // 更新等级文本显示的函数
+    private updateLevelText(lv: number): void {
+        this.level_text.string = lv + "";
+    }
+
+    // 更新灰色等级文本显示的函数
+    private updateLevelGreyText(lv: number): void {
+        this.level_grey.string = lv + "";
+    }
+
+    // 根据是否为当前等级,设置当前等级节点的显示状态的函数
+    private setCurrentLvNodeActive(isCurrentLv: boolean): void {
+        if (isCurrentLv) {
+            this.currentLv_node.active = true;
         }
-        this.lock_node.active=isLock
     }
-    onLevelClick()
-    {
-        if(this.lock_node.active==false && this.current_level>0)
-        {
-                cc.systemEvent.emit(game_constants.select_level_clicked,this.current_level)
+
+    // 根据是否锁定,设置锁定节点的显示状态的函数
+    private setLockNodeActive(isLock: boolean): void {
+        this.lock_node.active = isLock;
+    }
+
+    onLevelClick() {
+        // 检查是否可点击当前等级,并在可点击时发送选择等级点击事件
+        this.checkAndEmitLevelClickEvent();
+    }
+
+    // 检查是否可点击当前等级,并在可点击时发送选择等级点击事件的函数
+    private checkAndEmitLevelClickEvent(): void {
+        if (this.lock_node.active === false && this.current_level > 0) {
+            cc.systemEvent.emit(game_constants.select_level_clicked, this.current_level);
         }
     }
-    
 
     // update (dt) {}
-}
+}

+ 10 - 10
assets/scripts/level_mgr.ts

@@ -17,11 +17,11 @@ export default class NewClass extends cc.Component {
     @property(cc.Node)
     page4: cc.Node = null;
 
-    @property(cc.Node)
-    page5: cc.Node = null;
+    // @property(cc.Node)
+    // page5: cc.Node = null;
 
-    @property(cc.Node)
-    page6: cc.Node = null;
+    // @property(cc.Node)
+    // page6: cc.Node = null;
 
     AllLvItems: level_item[] = []
 
@@ -38,12 +38,12 @@ export default class NewClass extends cc.Component {
         this.page4.children.forEach(v => {
             this.AllLvItems.push(v.getComponent(level_item))
         })
-        this.page5.children.forEach(v => {
-            this.AllLvItems.push(v.getComponent(level_item))
-        })
-        this.page6.children.forEach(v => {
-            this.AllLvItems.push(v.getComponent(level_item))
-        })
+        // this.page5.children.forEach(v => {
+        //     this.AllLvItems.push(v.getComponent(level_item))
+        // })
+        // this.page6.children.forEach(v => {
+        //     this.AllLvItems.push(v.getComponent(level_item))
+        // })
         let currentLv = global_model.game.level
         this.AllLvItems.forEach((v, idx) => {
             v.initLevelItem(idx + 1, idx + 1 == currentLv, idx + 1 > currentLv)

+ 33 - 13
assets/scripts/model_base.ts

@@ -1,41 +1,61 @@
-
-
+// 用于将属性名添加到对应类的可保存属性数组中的函数
 export function save(target: any, keyName: string) {
-    let arr = model_base.classMap.get(target.constructor);
+    // 获取目标类对应的可保存属性数组
+    let arr = getOrCreateClassArray(target.constructor);
+    // 将属性名添加到数组中
+    arr.push(keyName);
+}
+
+// 获取目标类对应的可保存属性数组,如果不存在则创建一个新的空数组并设置到classMap中
+function getOrCreateClassArray(constructor: Function): any[] {
+    let arr = model_base.classMap.get(constructor);
     if (arr === undefined) {
         arr = [];
-        model_base.classMap.set(target.constructor, arr);
+        model_base.classMap.set(constructor, arr);
     }
-    arr.push(keyName);
+    return arr;
 }
 
-
 export default class model_base {
     public static classMap: Map<Function, any[]> = new Map();
+
+    // 获取当前对象可保存属性的数据并返回一个包含这些数据的对象的函数
     public getData(): object {
-        let data = {}
-        let savepars = model_base.classMap.get(this.constructor)
+        let data = {};
+        // 获取当前类的可保存属性数组
+        let savepars = this.getSaveParamsForClass(this.constructor);
+        // 遍历可保存属性数组,将对应属性的值添加到返回数据对象中
         for (let i = 0; i < savepars.length; ++i) {
             data[savepars[i]] = this[savepars[i]];
         }
         return data;
     }
 
+    // 根据传入的数据设置当前对象可保存属性的值的函数
     public setData(data: any) {
-        //初始化下数据       
+        // 如果传入数据为空,直接返回
         if (!data) return;
-        let savepars = model_base.classMap.get(this.constructor)
+        // 获取当前类的可保存属性数组
+        let savepars = this.getSaveParamsForClass(this.constructor);
+        // 遍历可保存属性数组,根据数据设置对应属性的值
         for (let i = 0; i < savepars.length; ++i) {
             const element = data[savepars[i]];
             if (element != null || element != undefined) {
                 if (Object.prototype.toString.call(element) == "[object Object]") {
+                    // 如果元素是对象,遍历对象的属性并设置到当前对象的对应属性中
                     for (const key in element) {
                         this[savepars[i]][key] = element[key];
                     }
-                }
-                else
+                } else {
+                    // 如果元素不是对象,直接设置到当前对象的对应属性中
                     this[savepars[i]] = element;
+                }
             }
         }
     }
-}
+
+    // 获取指定类的可保存属性数组的函数
+    private getSaveParamsForClass(constructor: Function): any[] {
+        return model_base.classMap.get(constructor) || [];
+    }
+}

+ 71 - 21
assets/scripts/pool_manager.ts

@@ -1,45 +1,95 @@
-
-import game_helpers from "./game_helpers";
-
 const { ccclass, property } = cc._decorator;
+
 @ccclass
 export default class pool_manager {
 
-
     pools: any = {};
-    resKey: any = {}
+    resKey: any = {};
 
-    init(callback,res:cc.Prefab) 
-    {
+    init(callback, res: cc.Prefab) {
+        // 初始化资源键值对
+        this.initializeResKey(res);
+
+        // 预创建并回收指定数量的节点到对象池
+        this.preCreateAndRecoverNodes(res);
+
+        // 执行回调函数(如果存在)
+        this.executeCallback(callback);
+    }
 
-        this.resKey['TileBlock'] = res
+    // 初始化资源键值对的函数,将特定资源与对应的键关联起来
+    private initializeResKey(res: cc.Prefab): void {
+        this.resKey['TileBlock'] = res;
+    }
+
+    // 预创建并回收指定数量的节点到对象池的函数
+    private preCreateAndRecoverNodes(res: cc.Prefab): void {
         for (let i = 0; i < 100; i++) {
-            let node = cc.instantiate(res)
-            this.recover('TileBlock', node)
+            let node = cc.instantiate(res);
+            this.recover('TileBlock', node);
         }
-        callback&&callback()
+    }
+
+    // 执行回调函数(如果存在)的函数
+    private executeCallback(callback: () => void): void {
+        callback && callback();
     }
 
     get(key: string) {
+        // 获取指定键对应的节点池,如果不存在则创建一个新的节点池
+        this.createNodePoolIfNotExists(key);
+
+        // 尝试从节点池中获取节点,如果能获取到则返回其组件
+        let node = this.tryGetNodeFromPool(key);
+        if (node) {
+            return node.getComponent(node.name);
+        }
+
+        // 如果节点池为空,创建一个新的节点并返回其组件
+        node = this.createNewNode(key);
+        return node.getComponent(node.name);
+    }
+
+    // 获取指定键对应的节点池,如果不存在则创建一个新的节点池的函数
+    private createNodePoolIfNotExists(key: string): void {
         if (this.pools[key] == null) {
-            this.pools[key] = new cc.NodePool()
+            this.pools[key] = new cc.NodePool();
         }
+    }
+
+    // 尝试从节点池中获取节点,如果能获取到则返回其组件的函数
+    private tryGetNodeFromPool(key: string): cc.Node | null {
         if (this.pools[key].size() > 0) {
-            let node = this.pools[key].get()
-            return node.getComponent(node.name)
+            let node = this.pools[key].get();
+            return node;
         }
-        let node = cc.instantiate(this.resKey[key])
-        return node.getComponent(node.name)
+        return null;
+    }
 
+    // 如果节点池为空,创建一个新的节点并返回其组件的函数
+    private createNewNode(key: string): cc.Node {
+        let node = cc.instantiate(this.resKey[key]);
+        return node;
     }
+
     recover(key: string, node: cc.Node) {
+        // 获取指定键对应的节点池,如果不存在则创建一个新的节点池
+        this.createNodePoolIfNotExists(key);
+
+        // 将节点放入对应的节点池中
+        this.putNodeIntoPool(key, node);
+    }
+
+    // 获取指定键对应的节点池,如果不存在则创建一个新的节点池的函数(与前面重复定义,可考虑提取为公共函数)
+    private createNodePoolIfNotExistsForRecover(key: string): void {
         if (this.pools[key] == null) {
-            this.pools[key] = new cc.NodePool()
+            this.pools[key] = new cc.NodePool();
         }
-        this.pools[key].put(node)
     }
 
+    // 将节点放入对应的节点池中
+    private putNodeIntoPool(key: string, node: cc.Node): void {
+        this.pools[key].put(node);
+    }
 
-}
-
-
+}

+ 1 - 1
settings/project.json

@@ -1,5 +1,5 @@
 {
-  "start-scene": "bccb9a69-316d-4f9e-9f15-8c0ac7ebafd2",
+  "start-scene": "d45d5e16-2231-4008-a0ab-4c70c6d5dc2f",
   "last-module-event-record-time": 1731756485090,
   "group-list": [
     "default"

Một số tệp đã không được hiển thị bởi vì quá nhiều tập tin thay đổi trong này khác