123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136 |
- 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);
- }
- }
|