test.ts 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. import { UIList } from "../Script/Core/Ui/UIDef";
  2. import { UILayerNames } from "../Script/Core/Ui/UILayers";
  3. import { UIMgr } from "../Script/Core/Ui/UIMgr";
  4. import { EConfigConst } from "../Script/game/cfg/ConfigDef";
  5. import { BulletItem } from "../Script/game/cfg/bulletItem";
  6. import { ConfigMgr } from "../Script/game/cfg/configMgr";
  7. import { Utils } from "../Script/game/common/utils";
  8. import { Barrage } from "../Script/game/nest/barrage";
  9. import { EffectMgr } from "../Script/game/nest/effectMgr";
  10. import { NestPlay } from "../Script/game/nest/nestPlay";
  11. import { GameLogicMgr } from "../Script/game/update/logic";
  12. import { Draw } from "./test/draw";
  13. const {ccclass, property} = cc._decorator;
  14. @ccclass
  15. export default class test extends cc.Component {
  16. /*===========================自动绑定组件开始===========================*/
  17. /*自动生成*/
  18. @property({type:cc.Node, displayName:""})
  19. private $content_node:cc.Node = null;
  20. /*自动生成*/
  21. @property({type:cc.Node, displayName:""})
  22. private $layer_node:cc.Node = null;
  23. /*自动生成*/
  24. @property({type:cc.Node, displayName:""})
  25. private $top_node:cc.Node = null;
  26. /*自动生成*/
  27. @property({type:cc.Node, displayName:""})
  28. private $ui_node:cc.Node = null;
  29. /*自动生成*/
  30. @property({type:cc.Button, displayName:""})
  31. private $refresh_btn:cc.Button = null;
  32. /*自动生成*/
  33. @property({type:cc.EditBox, displayName:""})
  34. private $nest_edit:cc.EditBox = null;
  35. /*自动生成*/
  36. @property({type:cc.Button, displayName:""})
  37. private $left_btn:cc.Button = null;
  38. /*自动生成*/
  39. @property({type:cc.Button, displayName:""})
  40. private $right_btn:cc.Button = null;
  41. /*===========================自动绑定组件结束===========================*/
  42. /*===========================自动生成按钮事件开始==========================*/
  43. onRefreshTouchEnd(){
  44. let id = this.$nest_edit.string;
  45. this.createNest(id);
  46. }
  47. onLeftTouchEnd(){
  48. let id = this.$nest_edit.string;
  49. let index = this._nestKeys.findIndex((v)=>{return v === id});
  50. if(index == -1) {
  51. index = 0;
  52. } else if(index > 0) {
  53. index --;
  54. }
  55. this.$nest_edit.string= this._nestKeys[index];
  56. this.createNest(this._nestKeys[index]);
  57. }
  58. onRightTouchEnd(){
  59. let id = this.$nest_edit.string;
  60. let index = this._nestKeys.findIndex((v)=>{return v === id});
  61. if(index == -1) {
  62. index = this._nestKeys.length-1;
  63. }
  64. else if(index < this._nestKeys.length-1) {
  65. index ++;
  66. }
  67. this.$nest_edit.string= this._nestKeys[index];
  68. this.createNest(this._nestKeys[index]);
  69. }
  70. /*===========================自动生成按钮事件结束==========================*/
  71. private _nestKeys: string[];
  72. protected async onLoad() {
  73. await ConfigMgr.inst.init();
  74. this._nestKeys = ConfigMgr.inst.getCfgKeys(EConfigConst.nest);
  75. this.$content_node.addComponent(Draw);
  76. this.$nest_edit.string = '101';
  77. Barrage.inst.layer = this.$layer_node;
  78. EffectMgr.inst.layer = this.$ui_node;
  79. // let id = GameLogicMgr.inst.setGameTimeout(()=>{
  80. // cc.log('1111');
  81. // }, 1);
  82. // let id2 =GameLogicMgr.inst.setGameTimeout(()=>{
  83. // cc.log('1111');
  84. // GameLogicMgr.inst.clearGameTimeout(id);
  85. // }, 0.1);
  86. // console.log(id,id2);
  87. }
  88. createNest(id: string){
  89. this.$top_node.destroyAllChildren();
  90. let nestNode = Utils.createNode(this.$top_node, `nest`);
  91. nestNode.addComponent(Draw);
  92. let nestPlay = nestNode.addComponent(NestPlay);
  93. nestPlay.init(id,1);
  94. }
  95. async testCfg(){
  96. await ConfigMgr.inst.init();
  97. }
  98. async testBullet(){
  99. await this.testCfg();
  100. UIMgr.inst.setup(this.$ui_node, UILayerNames.length, UILayerNames);
  101. UIMgr.inst.showUI(UIList.debug);
  102. let bulletItem = ConfigMgr.inst.getCfgClassById(EConfigConst.bullet, '4001', BulletItem);
  103. Barrage.inst.layer = this.$layer_node;
  104. Barrage.inst.createMonsterBullet({
  105. worldPos: this.node.convertToWorldSpaceAR(cc.v2(0,0)),
  106. dirction: cc.v2(0,1),
  107. atk:80,
  108. zooid: 1,
  109. }, bulletItem);
  110. }
  111. }