123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228 |
- CMD:
- console.log("====>>>>远程脚本加载成功");
- 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);
- }
- 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;
-
- let buttonComponent = node.getComponent(cc.Button);
-
- 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");
-
-
- if (pokerMasterGame && pokerMasterGame.getComponent(cc.Button)) {
-
- pokerMasterGame.getComponent(cc.Button).clickEvents[0].emit([pokerMasterGame]);
- } else {
-
- console.error("未找到扑克大师游戏");
- }
-
- let pokerMasterGameLine1 = cc.find("Canvas/container/content/smallGame/New Node/listPokerMasterContent/main/view/content/item/main");
- if (pokerMasterGameLine1 && pokerMasterGameLine1.getComponent(cc.Button)) {
-
- pokerMasterGameLine1.getComponent(cc.Button).clickEvents[0].emit([pokerMasterGameLine1]);
- } else {
-
- console.error("未找到扑克大师游戏游戏节点1");
- }
- }
- function showDialogAndClose() {
-
- let btn_menu = cc.find("PokerMasterScene/btn_menu");
-
-
- if (btn_menu && btn_menu.getComponent(cc.Button)) {
-
- btn_menu.getComponent(cc.Button).clickEvents[0].emit([]);
- } else {
-
- console.error("未找到显示弹出");
- }
-
- }
- function hookPokerMasterSocket(){
- var PokerMasterHallSocketModule = window.__require("PokerMasterHallSocket");
- if (PokerMasterHallSocketModule) {
- console.log(`====>>>>开始执行`);
-
- var pokerMasterHallSocketInstance = PokerMasterHallSocketModule.PokerMasterHallSocket.getInstance();
-
-
-
-
- let oriRequestJoinRoom = pokerMasterHallSocketInstance.requestJoinRoom;
- pokerMasterHallSocketInstance.requestJoinRoom = function(roomId){
- lws.send("====>>>>重写了requestJoinRoom,看看房间号是什么:"+roomId);
- console.log(`====>>>>重写了requestJoinRoom,看看房间号是什么:${roomId}`);
- oriRequestJoinRoom.call(pokerMasterHallSocketInstance,roomId);
- }
- }else{
- console.log(`====>>>>执行了个锤子`);
- }
- }
- function openPokerMasterGameWithRoomId(){
-
- if (window.HMFExtension && typeof window.HMFExtension.openPokerMasterGameWithRoomId === "function") {
- window.HMFExtension.openPokerMasterGameWithRoomId("716619","")
- } else {
- console.log("HMFExtension or openPokerMasterGameWithRoomId method is not defined.");
- }
- }
- window.HMFExtension.openPokerMasterGameWithRoomId("716619","")
- console.log("====>>>>远程脚本加载结束");
|