import { UIList } from "../Script/Core/Ui/UIDef"; import { UILayerNames } from "../Script/Core/Ui/UILayers"; import { UIMgr } from "../Script/Core/Ui/UIMgr"; import { EConfigConst } from "../Script/game/cfg/ConfigDef"; import { BulletItem } from "../Script/game/cfg/bulletItem"; import { ConfigMgr } from "../Script/game/cfg/configMgr"; import { Utils } from "../Script/game/common/utils"; import { Barrage } from "../Script/game/nest/barrage"; import { EffectMgr } from "../Script/game/nest/effectMgr"; import { NestPlay } from "../Script/game/nest/nestPlay"; import { GameLogicMgr } from "../Script/game/update/logic"; import { Draw } from "./test/draw"; const {ccclass, property} = cc._decorator; @ccclass export default class test extends cc.Component { /*===========================自动绑定组件开始===========================*/ /*自动生成*/ @property({type:cc.Node, displayName:""}) private $content_node:cc.Node = null; /*自动生成*/ @property({type:cc.Node, displayName:""}) private $layer_node:cc.Node = null; /*自动生成*/ @property({type:cc.Node, displayName:""}) private $top_node:cc.Node = null; /*自动生成*/ @property({type:cc.Node, displayName:""}) private $ui_node:cc.Node = null; /*自动生成*/ @property({type:cc.Button, displayName:""}) private $refresh_btn:cc.Button = null; /*自动生成*/ @property({type:cc.EditBox, displayName:""}) private $nest_edit:cc.EditBox = null; /*自动生成*/ @property({type:cc.Button, displayName:""}) private $left_btn:cc.Button = null; /*自动生成*/ @property({type:cc.Button, displayName:""}) private $right_btn:cc.Button = null; /*===========================自动绑定组件结束===========================*/ /*===========================自动生成按钮事件开始==========================*/ onRefreshTouchEnd(){ let id = this.$nest_edit.string; this.createNest(id); } onLeftTouchEnd(){ let id = this.$nest_edit.string; let index = this._nestKeys.findIndex((v)=>{return v === id}); if(index == -1) { index = 0; } else if(index > 0) { index --; } this.$nest_edit.string= this._nestKeys[index]; this.createNest(this._nestKeys[index]); } onRightTouchEnd(){ let id = this.$nest_edit.string; let index = this._nestKeys.findIndex((v)=>{return v === id}); if(index == -1) { index = this._nestKeys.length-1; } else if(index < this._nestKeys.length-1) { index ++; } this.$nest_edit.string= this._nestKeys[index]; this.createNest(this._nestKeys[index]); } /*===========================自动生成按钮事件结束==========================*/ private _nestKeys: string[]; protected async onLoad() { await ConfigMgr.inst.init(); this._nestKeys = ConfigMgr.inst.getCfgKeys(EConfigConst.nest); this.$content_node.addComponent(Draw); this.$nest_edit.string = '101'; Barrage.inst.layer = this.$layer_node; EffectMgr.inst.layer = this.$ui_node; // let id = GameLogicMgr.inst.setGameTimeout(()=>{ // cc.log('1111'); // }, 1); // let id2 =GameLogicMgr.inst.setGameTimeout(()=>{ // cc.log('1111'); // GameLogicMgr.inst.clearGameTimeout(id); // }, 0.1); // console.log(id,id2); } createNest(id: string){ this.$top_node.destroyAllChildren(); let nestNode = Utils.createNode(this.$top_node, `nest`); nestNode.addComponent(Draw); let nestPlay = nestNode.addComponent(NestPlay); nestPlay.init(id,1); } async testCfg(){ await ConfigMgr.inst.init(); } async testBullet(){ await this.testCfg(); UIMgr.inst.setup(this.$ui_node, UILayerNames.length, UILayerNames); UIMgr.inst.showUI(UIList.debug); let bulletItem = ConfigMgr.inst.getCfgClassById(EConfigConst.bullet, '4001', BulletItem); Barrage.inst.layer = this.$layer_node; Barrage.inst.createMonsterBullet({ worldPos: this.node.convertToWorldSpaceAR(cc.v2(0,0)), dirction: cc.v2(0,1), atk:80, zooid: 1, }, bulletItem); } }