Browse Source

脚本更新

Alex 1 year ago
parent
commit
68526c563d
1 changed files with 122 additions and 81 deletions
  1. 122 81
      yyyy_js/python-server/script.js

+ 122 - 81
yyyy_js/python-server/script.js

@@ -1,91 +1,132 @@
 CMD:
 console.log("====>>>>远程脚本加载成功");
-//var cScene = cc.director.getScene();
-//let scene = cc.director.getScene();
-//let layersCount = scene.childrenCount;
-//console.log("图层数量:", layersCount);
-//
-//function getTotalComponentsCount(node) {
-//    let count = node.getComponents(cc.Component).length;
-//    node.children.forEach(childNode => {
-//        count += getTotalComponentsCount(childNode);
-//    });
-//    return count;
-//}
-//
-//// 使用当前场景的根节点作为起点
-//let totalComponents = getTotalComponentsCount(scene);
-//console.log("场景中的组件总数量:", totalComponents);
-
-//function printNodePath(node, path = '') {
-//    // 构建当前节点的路径
-//    let currentPath = path ? `${path}/${node.name}` : node.name;
-//    console.log(currentPath); // 打印当前节点的路径
-//    lws.send(currentPath);
-//    // 遍历子节点
-//    node.children.forEach((child) => {
-//        printNodePath(child, currentPath);
-//    });
-//}
-//
-// 获取当前场景的根节点并开始遍历
-//let scene = cc.director.getScene();
-//scene.children.forEach((child) => {
-//    // 假设每个直接子节点都是一个“图层”
-//    printNodePath(child);
-//});
-//
-//function printNodePath(node, path = '') {
-//    // 构建当前节点的路径
-//    let currentPath = path ? `${path}/${node.name}` : node.name;
-//
-//    // 检查节点是否有 cc.Button 组件,这意味着它监听了点击事件
-//    let buttonComponent = node.getComponent(cc.Button);
-//
-//    // 可以根据需要,检查其他组件,如 cc.ScrollView 等
-//
-//    if (buttonComponent) {
-//        console.log(currentPath); // 打印当前节点的路径
-//        lws.send(currentPath);
-//    }
-//
-//    // 遍历子节点
-//    node.children.forEach((child) => {
-//        printNodePath(child, currentPath);
-//    });
-//}
-
-
-//// 获取当前场景的根节点并开始遍历
-//let scene = cc.director.getScene();
-//scene.children.forEach((child) => {
-//    printNodePath(child);
-//});
-
-// 点击扑克大师游戏
-let pokerMasterGame = cc.find("Canvas/container/content/smallGame/createScrollView/view/cotent/row1/pokerNode/porkermaster/allHand");//进入大师线路列表
-//let pokerMasterGame = cc.find("Canvas/container/content/smallGame/New Node/listPokerMasterContent/btn_down");//大师线路列表按钮下降
-
-// 检查节点是否找到以及是否有cc.Button组件
-if (pokerMasterGame && pokerMasterGame.getComponent(cc.Button)) {
-    // 模拟点击事件
-    pokerMasterGame.getComponent(cc.Button).clickEvents[0].emit([pokerMasterGame]);
-} else {
-//    console.error("节点未找到或节点上没有cc.Button组件");
-    console.error("未找到扑克大师游戏");
+
+function printNodesCount() {
+    var cScene = cc.director.getScene();
+    let scene = cc.director.getScene();
+    let layersCount = scene.childrenCount;
+    console.log("图层数量:", layersCount);
+
+    function getTotalComponentsCount(node) {
+        let count = node.getComponents(cc.Component).length;
+        node.children.forEach(childNode => {
+            count += getTotalComponentsCount(childNode);
+        });
+        return count;
+    }
+
+    // 使用当前场景的根节点作为起点
+    let totalComponents = getTotalComponentsCount(scene);
+    console.log("场景中的组件总数量:", totalComponents);
 }
 
-// 点击扑克大师游戏线路1
-let pokerMasterGameLine1 = cc.find("Canvas/container/content/smallGame/New Node/listPokerMasterContent/main/view/content/item/main");//线路1
-if (pokerMasterGameLine1 && pokerMasterGameLine1.getComponent(cc.Button)) {
-    // 模拟点击事件
-    pokerMasterGameLine1.getComponent(cc.Button).clickEvents[0].emit([pokerMasterGameLine1]);
-} else {
-//    console.error("节点未找到或节点上没有cc.Button组件");
-    console.error("未找到扑克大师游戏游戏节点1");
+function printAllNodes() {
+    function printNodePath(node, path = '') {
+        // 构建当前节点的路径
+        let currentPath = path ? `${path}/${node.name}` : node.name;
+        console.log(currentPath); // 打印当前节点的路径
+        lws.send(currentPath);
+        // 遍历子节点
+        node.children.forEach((child) => {
+            printNodePath(child, currentPath);
+        });
+    }
+
+    // 获取当前场景的根节点并开始遍历
+    let scene = cc.director.getScene();
+    scene.children.forEach((child) => {
+        // 假设每个直接子节点都是一个“图层”
+        printNodePath(child);
+    });
 }
 
+function printClickAbleNodes() {
+
+    function printNodePath(node, path = '') {
+        // 构建当前节点的路径
+        let currentPath = path ? `${path}/${node.name}` : node.name;
+
+        // 检查节点是否有 cc.Button 组件,这意味着它监听了点击事件
+        let buttonComponent = node.getComponent(cc.Button);
+
+        // 可以根据需要,检查其他组件,如 cc.ScrollView 等
+
+        if (buttonComponent) {
+            console.log(currentPath); // 打印当前节点的路径
+            lws.send(currentPath);
+        }
+
+        // 遍历子节点
+        node.children.forEach((child) => {
+            printNodePath(child, currentPath);
+        });
+    }
+
+
+    // 获取当前场景的根节点并开始遍历
+    let scene = cc.director.getScene();
+    scene.children.forEach((child) => {
+        printNodePath(child);
+    });
+}
+
+function enterGame() {
+    // 点击扑克大师游戏
+    let pokerMasterGame = cc.find("Canvas/container/content/smallGame/createScrollView/view/cotent/row1/pokerNode/porkermaster/allHand");//进入大师线路列表
+    //let pokerMasterGame = cc.find("Canvas/container/content/smallGame/New Node/listPokerMasterContent/btn_down");//大师线路列表按钮下降
+
+    // 检查节点是否找到以及是否有cc.Button组件
+    if (pokerMasterGame && pokerMasterGame.getComponent(cc.Button)) {
+        // 模拟点击事件
+        pokerMasterGame.getComponent(cc.Button).clickEvents[0].emit([pokerMasterGame]);
+    } else {
+    //    console.error("节点未找到或节点上没有cc.Button组件");
+        console.error("未找到扑克大师游戏");
+    }
+
+    // 点击扑克大师游戏线路1
+    let pokerMasterGameLine1 = cc.find("Canvas/container/content/smallGame/New Node/listPokerMasterContent/main/view/content/item/main");//线路1
+    if (pokerMasterGameLine1 && pokerMasterGameLine1.getComponent(cc.Button)) {
+        // 模拟点击事件
+        pokerMasterGameLine1.getComponent(cc.Button).clickEvents[0].emit([pokerMasterGameLine1]);
+    } else {
+    //    console.error("节点未找到或节点上没有cc.Button组件");
+        console.error("未找到扑克大师游戏游戏节点1");
+    }
+
+}
+
+function showDialogAndClose() {
+
+    // 点击显示退出弹窗
+    let btn_menu = cc.find("PokerMasterScene/btn_menu");//进入大师线路列表
+    //let btn_menu = cc.find("Canvas/container/content/smallGame/New Node/listPokerMasterContent/btn_down");//大师线路列表按钮下降
+
+    // 检查节点是否找到以及是否有cc.Button组件
+    if (btn_menu && btn_menu.getComponent(cc.Button)) {
+        // 模拟点击事件
+        btn_menu.getComponent(cc.Button).clickEvents[0].emit([]);
+    } else {
+    //    console.error("节点未找到或节点上没有cc.Button组件");
+        console.error("未找到显示弹出");
+    }
+
+    // 点击扑克大师游戏线路1
+//    let pokerMasterGameLine1 = cc.find("Canvas/container/content/smallGame/New Node/listPokerMasterContent/main/view/content/item/main");//线路1
+//    if (pokerMasterGameLine1 && pokerMasterGameLine1.getComponent(cc.Button)) {
+//        // 模拟点击事件
+//        pokerMasterGameLine1.getComponent(cc.Button).clickEvents[0].emit([pokerMasterGameLine1]);
+//    } else {
+//    //    console.error("节点未找到或节点上没有cc.Button组件");
+//        console.error("未找到扑克大师游戏游戏节点1");
+//    }
+
+}
 
+//printClickAbleNodes();
+//enterGame();
+//printAllNodes();
+//printNodesCount();
 
 //lws.send("存到本地");