test.ts 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  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 { Draw } from "./test/draw";
  12. const {ccclass, property} = cc._decorator;
  13. @ccclass
  14. export default class test extends cc.Component {
  15. /*===========================自动绑定组件开始===========================*/
  16. /*自动生成*/
  17. @property({type:cc.Node, displayName:""})
  18. private $content_node:cc.Node = null;
  19. /*自动生成*/
  20. @property({type:cc.Node, displayName:""})
  21. private $layer_node:cc.Node = null;
  22. /*自动生成*/
  23. @property({type:cc.Node, displayName:""})
  24. private $top_node:cc.Node = null;
  25. /*自动生成*/
  26. @property({type:cc.Node, displayName:""})
  27. private $ui_node:cc.Node = null;
  28. /*自动生成*/
  29. @property({type:cc.Button, displayName:""})
  30. private $refresh_btn:cc.Button = null;
  31. /*自动生成*/
  32. @property({type:cc.EditBox, displayName:""})
  33. private $nest_edit:cc.EditBox = null;
  34. /*===========================自动绑定组件结束===========================*/
  35. /*===========================自动生成按钮事件开始==========================*/
  36. onRefreshTouchEnd(){
  37. let id = this.$nest_edit.string;
  38. this.createNest(id);
  39. }
  40. /*===========================自动生成按钮事件结束==========================*/
  41. protected async onLoad() {
  42. await ConfigMgr.inst.init();
  43. this.$content_node.addComponent(Draw);
  44. this.$nest_edit.string = '101';
  45. Barrage.inst.layer = this.$layer_node;
  46. EffectMgr.inst.layer = this.$ui_node;
  47. }
  48. createNest(id: string){
  49. this.$top_node.destroyAllChildren();
  50. let nestNode = Utils.createNode(this.$top_node, `nest`);
  51. nestNode.addComponent(Draw);
  52. let nestPlay = nestNode.addComponent(NestPlay);
  53. nestPlay.init(id,1);
  54. }
  55. async testCfg(){
  56. await ConfigMgr.inst.init();
  57. }
  58. async testBullet(){
  59. await this.testCfg();
  60. UIMgr.inst.setup(this.$ui_node, UILayerNames.length, UILayerNames);
  61. UIMgr.inst.showUI(UIList.debug);
  62. let bulletItem = ConfigMgr.inst.getCfgClassById(EConfigConst.bullet, '4001', BulletItem);
  63. Barrage.inst.layer = this.$layer_node;
  64. Barrage.inst.createMonsterBullet({
  65. worldPos: this.node.convertToWorldSpaceAR(cc.v2(0,0)),
  66. dirction: cc.v2(0,1),
  67. atk:80,
  68. }, bulletItem);
  69. }
  70. }