class GameHelper2 { constructor() { this.version = 2.0; this.funArr2 = []; this.EventFun2 = 'EventFun2'; console.error('你好,指挥官,欢迎来到新世界 version = ' + this.version); this._init(); } _init() { this._registerFunctions(); this._startScheduledTasks(); Event_E.on(this.EventFun2, this, this._begin2); //执行前状态 window['yxg2.star'] = false; this._begin2(); } _registerFunctions() { this.funArr2.push(this.star.bind(this)); this.funArr2.push(this.planet.bind(this)); } _startScheduledTasks() { Laya.timer.loop(1200000, this, () => { this.funArr2.push(this.star.bind(this)); this.funArr2.push(this.planet.bind(this)); this._begin2(); }); } _begin2() { let fun = this.funArr2.pop(); fun && fun(); if(!fun) window['yxg2.star'] = true; } _listens(listens) { for (let i = 0; i < listens.length; i++) { let fun = listens[i]; if (fun) { fun.run(); } } } _waitPanelRegist(fun, name) { Laya.timer.once(1000, this, fun, [true, name]); } _checkViewName(name) { return name; } // #region 资源星球 star() { Event_E.on(EventName.OPEN_CLOSE_PANEL, this, this._star); Event_E.event(EventName.OPEN_OR_CLOSE_RES_STAR_MAIN_VIEW, [true, 0]); } _star(isOpen, name) { name = this._checkViewName(name); if (!(isOpen && name == UINameConst.ResStarMainView.uiName)) { return; } Event_E.off(EventName.OPEN_CLOSE_PANEL, this, this._star); let p = window['xz' + UINameConst.ResStarMainView.class.name]; if (!p || !p.ui || p.ui.name != UINameConst.ResStarMainView.uiName) { Laya.timer.once(1000, this, this._star, [true, UINameConst.ResStarMainView.uiName]); return; } let view = p.ui._children[1]; let mineArrA = DC.selfVo.mineData.mineArrA; let group = ['m_group0', 'm_group1', 'm_group2']; let panel = [ ['m_pos0_0', 'm_pos0_1', 'm_pos0_2', 'm_pos0_3', 'm_pos0_4'], ['m_pos1_0', 'm_pos1_1', 'm_pos1_2', 'm_pos1_3', 'm_pos1_4'], ['m_pos2_0', 'm_pos2_1', 'm_pos2_2', 'm_pos2_3', 'm_pos2_4'], ]; let quality = 3; if (DC.selfVo.mineData.countA <= 2) { quality = 0; } for (let i = 0; i < group.length; i++) { let groupe = group[i]; if (!view[groupe].visible) continue; for (let j = 0; j < panel[i].length; j++) { const t = panel[i]; const element = view[t[j]].component; if (!element || !element.visible) continue; if (element.data.quality < quality) continue; if (mineArrA.length < 4 || mineArrA.includes(0)) { if (element.m_c1.selectedIndex == 0) { element.onClickOperateBtn(); Laya.timer.once(500, this, this._star, [true, UINameConst.ResStarMainView.uiName]); return; } } } } let isend = false; if (mineArrA.length < 4 || mineArrA.includes(0)) { if (DC.selfVo.mineData.countA == 0) { isend = true; } else { let listens = view.m_searchBtn._displayObject._events.click; this._listens(listens); Laya.timer.once(3000, this, this._star, [true, UINameConst.ResStarMainView.uiName]); } } else { isend = true; } if (isend) { console.error('资源星球占领结束'); Event_E.event(EventName.OPEN_OR_CLOSE_RES_STAR_MAIN_VIEW, [false]); Event_E.event(this.EventFun2); } } // #endregion // #region 我的星球 planet() { Event_E.on(EventName.OPEN_CLOSE_PANEL, this, this._planet); Event_E.event(EventName.OPEN_OR_CLOSE_RESOURCE_PLANET_VIEW, [true]); } _planet(isOpen, name) { name = this._checkViewName(name); if (!(isOpen && name == UINameConst.ResourcePlanetMainView.uiName)) { return; } Event_E.off(EventName.OPEN_CLOSE_PANEL, this, this._planet); let p = window['xz' + UINameConst.ResourcePlanetMainView.class.name]; if (!p || !p.ui || p.ui.name != UINameConst.ResourcePlanetMainView.uiName) { Laya.timer.once(1000, this, this._planet, [true, UINameConst.ResourcePlanetMainView.uiName]); return; } let arr = p.ui.m_itemList.data; let mine2Mine = DC.selfVo.mine2Data.mine2Mine; let count = mine2Mine.m2mArr.length; let msg = require('src/module/resourcePlanet/ResourcePlanetHelper').ResourcePlanetHelper; for (let i = 0; i < arr.length; i++) { const element = arr[i]; let d = element.data; if (!d) continue; if (d.m2mId == 0) { if (count > 0) { Event_E.once(EventName.OPEN_CLOSE_PANEL, this, this._planetkc); p.onClickMineBtn(); return; } else { continue; } } else if (ServerTime.serverTime >= d.m2mET) { if (d.userB.length == 0) { msg.sendMine2Msg(13, i); } else { msg.sendMine2Msg(10, i); } Laya.timer.once(1000, this, this._planet, [true, UINameConst.ResourcePlanetMainView.uiName]); return; } else { let mineConfig = TableEnum.mine2_mine.getCfg(d.m2mId); let remainTime = Math.max(0, d.m2mET - ServerTime.serverTime); if (remainTime < msg.MINE2_REFRESHMINE) continue; if (d.refreshCount < msg.MINE2_REFRESHMINETIME) { if (mineConfig.quality < 5) { msg.currentAdIndex = i; AdvDebug.viewAdv(12); Laya.timer.once(1000, this, this._planet, [true, UINameConst.ResourcePlanetMainView.uiName]); return; } } } } console.error('我的星球放置结束'); Event_E.event(EventName.OPEN_OR_CLOSE_RESOURCE_PLANET_VIEW, [false]); Event_E.event(this.EventFun2); } _planetkc(isOpen, name) { name = this._checkViewName(name); if (!(isOpen && name == UINameConst.ResourcePlanetMineListView.uiName)) { return; } Event_E.off(EventName.OPEN_CLOSE_PANEL, this, this._planetkc); let p = window['xz' + UINameConst.ResourcePlanetMineListView.class.name]; if (!p || !p.ui || p.ui.name != UINameConst.ResourcePlanetMineListView.uiName) { Laya.timer.once(1000, this, this._planetkc, [true, UINameConst.ResourcePlanetMineListView.uiName]); return; } p.onClickMineBtn(0); Laya.timer.once(1000, this, this._planet, [true, UINameConst.ResourcePlanetMainView.uiName]); } _planetsj() { // 预留方法 } // #endregion } const gameHelper2 = new GameHelper2(); console.error( "使用说明:辅助器挂载时,会向平台注入全局变量 yxg2 \n" + "使用 yxg2.star() 占领资源星球\n" + "使用 yxg2.planet() 管理我的星球\n" );

http://example.com/2026/05/19/星战开挂脚本2/
作者
xian
发布于
2026年5月19日
许可协议