60a3cc3dac2a575cb9c89501ac659832dcff1e40.js 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362
  1. System.register(["__unresolved_0", "cc", "__unresolved_1", "__unresolved_2", "__unresolved_3"], function (_export, _context) {
  2. "use strict";
  3. var _reporterNs, _cclegacy, __checkObsolete__, __checkObsoleteInNamespace__, _decorator, Component, instantiate, math, Node, Prefab, bullet, constant, enemyPlane, _dec, _dec2, _dec3, _dec4, _dec5, _dec6, _dec7, _dec8, _dec9, _dec10, _class, _class2, _descriptor, _descriptor2, _descriptor3, _descriptor4, _descriptor5, _descriptor6, _descriptor7, _descriptor8, _descriptor9, _descriptor10, _descriptor11, _descriptor12, _descriptor13, _descriptor14, _crd, ccclass, property, gameMangager;
  4. function _initializerDefineProperty(target, property, descriptor, context) { if (!descriptor) return; Object.defineProperty(target, property, { enumerable: descriptor.enumerable, configurable: descriptor.configurable, writable: descriptor.writable, value: descriptor.initializer ? descriptor.initializer.call(context) : void 0 }); }
  5. function _applyDecoratedDescriptor(target, property, decorators, descriptor, context) { var desc = {}; Object.keys(descriptor).forEach(function (key) { desc[key] = descriptor[key]; }); desc.enumerable = !!desc.enumerable; desc.configurable = !!desc.configurable; if ('value' in desc || desc.initializer) { desc.writable = true; } desc = decorators.slice().reverse().reduce(function (desc, decorator) { return decorator(target, property, desc) || desc; }, desc); if (context && desc.initializer !== void 0) { desc.value = desc.initializer ? desc.initializer.call(context) : void 0; desc.initializer = undefined; } if (desc.initializer === void 0) { Object.defineProperty(target, property, desc); desc = null; } return desc; }
  6. function _initializerWarningHelper(descriptor, context) { throw new Error('Decorating class property failed. Please ensure that ' + 'transform-class-properties is enabled and runs after the decorators transform.'); }
  7. function _reportPossibleCrUseOfbullet(extras) {
  8. _reporterNs.report("bullet", "../bullet/bullet", _context.meta, extras);
  9. }
  10. function _reportPossibleCrUseOfconstant(extras) {
  11. _reporterNs.report("constant", "./constant", _context.meta, extras);
  12. }
  13. function _reportPossibleCrUseOfenemyPlane(extras) {
  14. _reporterNs.report("enemyPlane", "../plane/enemyPlane", _context.meta, extras);
  15. }
  16. return {
  17. setters: [function (_unresolved_) {
  18. _reporterNs = _unresolved_;
  19. }, function (_cc) {
  20. _cclegacy = _cc.cclegacy;
  21. __checkObsolete__ = _cc.__checkObsolete__;
  22. __checkObsoleteInNamespace__ = _cc.__checkObsoleteInNamespace__;
  23. _decorator = _cc._decorator;
  24. Component = _cc.Component;
  25. instantiate = _cc.instantiate;
  26. math = _cc.math;
  27. Node = _cc.Node;
  28. Prefab = _cc.Prefab;
  29. }, function (_unresolved_2) {
  30. bullet = _unresolved_2.bullet;
  31. }, function (_unresolved_3) {
  32. constant = _unresolved_3.constant;
  33. }, function (_unresolved_4) {
  34. enemyPlane = _unresolved_4.enemyPlane;
  35. }],
  36. execute: function () {
  37. _crd = true;
  38. _cclegacy._RF.push({}, "2839ePij2VDYp+PBYGbp5DS", "gameMangager", undefined);
  39. __checkObsolete__(['_decorator', 'Component', 'instantiate', 'math', 'Node', 'Prefab']);
  40. ({
  41. ccclass,
  42. property
  43. } = _decorator);
  44. _export("gameMangager", gameMangager = (_dec = ccclass('gameMangager'), _dec2 = property(Node), _dec3 = property(Prefab), _dec4 = property(Prefab), _dec5 = property(Prefab), _dec6 = property(Prefab), _dec7 = property(Prefab), _dec8 = property(Node), _dec9 = property(Prefab), _dec10 = property(Prefab), _dec(_class = (_class2 = class gameMangager extends Component {
  45. constructor(...args) {
  46. super(...args);
  47. _initializerDefineProperty(this, "playerPlane", _descriptor, this);
  48. // bullet
  49. _initializerDefineProperty(this, "bullet01", _descriptor2, this);
  50. _initializerDefineProperty(this, "bullet02", _descriptor3, this);
  51. _initializerDefineProperty(this, "bullet03", _descriptor4, this);
  52. _initializerDefineProperty(this, "bullet04", _descriptor5, this);
  53. _initializerDefineProperty(this, "bullet05", _descriptor6, this);
  54. _initializerDefineProperty(this, "shootTime", _descriptor7, this);
  55. // 子弹周期
  56. _initializerDefineProperty(this, "bulletSpeed", _descriptor8, this);
  57. // 子弹速度
  58. _initializerDefineProperty(this, "bulletRoot", _descriptor9, this);
  59. // 敌机
  60. _initializerDefineProperty(this, "enemyPlane01", _descriptor10, this);
  61. _initializerDefineProperty(this, "enemyPlane02", _descriptor11, this);
  62. _initializerDefineProperty(this, "createEnemyTime", _descriptor12, this);
  63. _initializerDefineProperty(this, "enemySpeed1", _descriptor13, this);
  64. _initializerDefineProperty(this, "enemySpeed2", _descriptor14, this);
  65. this._currShootTime = 0;
  66. this._isShooting = false;
  67. this._currCreatEnemyTime = 0;
  68. this._comBinationInterval = (_crd && constant === void 0 ? (_reportPossibleCrUseOfconstant({
  69. error: Error()
  70. }), constant) : constant).Combination.PLAN1;
  71. // 获取分数
  72. this.score = 0;
  73. }
  74. start() {
  75. this._init();
  76. }
  77. update(deltaTime) {
  78. this._currShootTime += deltaTime;
  79. if (this._isShooting && this._currShootTime > this.shootTime) {
  80. this.createPlayerBullet();
  81. this._currShootTime = 0;
  82. } // 敌机类型
  83. this._currCreatEnemyTime += deltaTime;
  84. if (this._comBinationInterval === (_crd && constant === void 0 ? (_reportPossibleCrUseOfconstant({
  85. error: Error()
  86. }), constant) : constant).Combination.PLAN1) {
  87. if (this._currCreatEnemyTime > this.createEnemyTime) {
  88. this.createEnemyPlane();
  89. this._currCreatEnemyTime = 0;
  90. }
  91. } else if (this._comBinationInterval === (_crd && constant === void 0 ? (_reportPossibleCrUseOfconstant({
  92. error: Error()
  93. }), constant) : constant).Combination.PLAN2) {
  94. if (this._currCreatEnemyTime > this.createEnemyTime * 0.9) {
  95. const randomCombiation = math.randomRangeInt(1, 3);
  96. if (randomCombiation === (_crd && constant === void 0 ? (_reportPossibleCrUseOfconstant({
  97. error: Error()
  98. }), constant) : constant).Combination.PLAN2) {
  99. this.createCombination1();
  100. } else {
  101. this.createEnemyPlane();
  102. }
  103. this._currCreatEnemyTime = 0;
  104. }
  105. } else {
  106. if (this._currCreatEnemyTime > this.createEnemyTime * 0.8) {
  107. const randomCombiation = math.randomRangeInt(1, 4);
  108. if (randomCombiation === (_crd && constant === void 0 ? (_reportPossibleCrUseOfconstant({
  109. error: Error()
  110. }), constant) : constant).Combination.PLAN2) {
  111. this.createCombination1();
  112. } else if (randomCombiation === (_crd && constant === void 0 ? (_reportPossibleCrUseOfconstant({
  113. error: Error()
  114. }), constant) : constant).Combination.PLAN3) {
  115. this.createCombination2();
  116. } else {
  117. this.createEnemyPlane();
  118. }
  119. this._currCreatEnemyTime = 0;
  120. }
  121. }
  122. } // 创建子弹
  123. createPlayerBullet() {
  124. const bullet01 = instantiate(this.bullet01);
  125. bullet01.setParent(this.bulletRoot);
  126. const pos = this.playerPlane.position;
  127. bullet01.setPosition(pos.x + 0, pos.y, pos.z);
  128. const bulletComp = bullet01.getComponent(_crd && bullet === void 0 ? (_reportPossibleCrUseOfbullet({
  129. error: Error()
  130. }), bullet) : bullet);
  131. bulletComp.bulletSpeed = this.bulletSpeed;
  132. } // 创建敌机
  133. createEnemyPlane() {
  134. const whichEnemy = math.randomRangeInt(1, 3);
  135. let prefab = null;
  136. let speed = 0;
  137. if (whichEnemy == (_crd && constant === void 0 ? (_reportPossibleCrUseOfconstant({
  138. error: Error()
  139. }), constant) : constant).EnemyPlaneType.TYPE1) {
  140. prefab = this.enemyPlane01;
  141. speed = this.enemySpeed1;
  142. } else {
  143. prefab = this.enemyPlane02;
  144. speed = this.enemySpeed2;
  145. }
  146. const enemy = instantiate(prefab);
  147. enemy.setParent(this.node);
  148. const enemyComp = enemy.getComponent(_crd && enemyPlane === void 0 ? (_reportPossibleCrUseOfenemyPlane({
  149. error: Error()
  150. }), enemyPlane) : enemyPlane);
  151. enemyComp.show(this, speed);
  152. const randomPos = math.randomRangeInt(-11, 11);
  153. enemy.setPosition(30, 0, randomPos);
  154. }
  155. createCombination1() {
  156. const enemyArry = new Array(3);
  157. for (let i = 0; i < enemyArry.length; i++) {
  158. enemyArry[i] = instantiate(this.enemyPlane01);
  159. const element = enemyArry[i];
  160. element.parent = this.node;
  161. element.setPosition(30, 0, -6 + i * 6);
  162. const enemyComp = element.getComponent(_crd && enemyPlane === void 0 ? (_reportPossibleCrUseOfenemyPlane({
  163. error: Error()
  164. }), enemyPlane) : enemyPlane);
  165. enemyComp.show(this, this.enemySpeed1);
  166. }
  167. }
  168. createCombination2() {
  169. const enemyArry = new Array(5);
  170. const combinationPost = [-8, 0, 40, -4, 0, 35, 0, 0, 30, 4, 0, 35, 8, 0, 40];
  171. for (let i = 0; i < enemyArry.length; i++) {
  172. enemyArry[i] = instantiate(this.enemyPlane02);
  173. const element = enemyArry[i];
  174. element.parent = this.node;
  175. const startIndex = i * 3;
  176. element.setPosition(combinationPost[startIndex + 2], combinationPost[startIndex + 1], combinationPost[startIndex]);
  177. const enemyComp = element.getComponent(_crd && enemyPlane === void 0 ? (_reportPossibleCrUseOfenemyPlane({
  178. error: Error()
  179. }), enemyPlane) : enemyPlane);
  180. enemyComp.show(this, this.enemySpeed2);
  181. }
  182. } // 是否发射
  183. isShooting(val) {
  184. this._isShooting = val;
  185. } // 初始化
  186. _init() {
  187. this._currShootTime = this.shootTime;
  188. this.changePlaneMode();
  189. } // 循环加载
  190. changePlaneMode() {
  191. this.schedule(this._modeChanged, 10, 3);
  192. }
  193. _modeChanged() {
  194. this._comBinationInterval++;
  195. }
  196. addScore() {
  197. this.score++;
  198. console.log('分数:' + this.score);
  199. }
  200. }, (_descriptor = _applyDecoratedDescriptor(_class2.prototype, "playerPlane", [_dec2], {
  201. configurable: true,
  202. enumerable: true,
  203. writable: true,
  204. initializer: function () {
  205. return null;
  206. }
  207. }), _descriptor2 = _applyDecoratedDescriptor(_class2.prototype, "bullet01", [_dec3], {
  208. configurable: true,
  209. enumerable: true,
  210. writable: true,
  211. initializer: function () {
  212. return null;
  213. }
  214. }), _descriptor3 = _applyDecoratedDescriptor(_class2.prototype, "bullet02", [_dec4], {
  215. configurable: true,
  216. enumerable: true,
  217. writable: true,
  218. initializer: function () {
  219. return null;
  220. }
  221. }), _descriptor4 = _applyDecoratedDescriptor(_class2.prototype, "bullet03", [_dec5], {
  222. configurable: true,
  223. enumerable: true,
  224. writable: true,
  225. initializer: function () {
  226. return null;
  227. }
  228. }), _descriptor5 = _applyDecoratedDescriptor(_class2.prototype, "bullet04", [_dec6], {
  229. configurable: true,
  230. enumerable: true,
  231. writable: true,
  232. initializer: function () {
  233. return null;
  234. }
  235. }), _descriptor6 = _applyDecoratedDescriptor(_class2.prototype, "bullet05", [_dec7], {
  236. configurable: true,
  237. enumerable: true,
  238. writable: true,
  239. initializer: function () {
  240. return null;
  241. }
  242. }), _descriptor7 = _applyDecoratedDescriptor(_class2.prototype, "shootTime", [property], {
  243. configurable: true,
  244. enumerable: true,
  245. writable: true,
  246. initializer: function () {
  247. return 0.1;
  248. }
  249. }), _descriptor8 = _applyDecoratedDescriptor(_class2.prototype, "bulletSpeed", [property], {
  250. configurable: true,
  251. enumerable: true,
  252. writable: true,
  253. initializer: function () {
  254. return 1;
  255. }
  256. }), _descriptor9 = _applyDecoratedDescriptor(_class2.prototype, "bulletRoot", [_dec8], {
  257. configurable: true,
  258. enumerable: true,
  259. writable: true,
  260. initializer: function () {
  261. return null;
  262. }
  263. }), _descriptor10 = _applyDecoratedDescriptor(_class2.prototype, "enemyPlane01", [_dec9], {
  264. configurable: true,
  265. enumerable: true,
  266. writable: true,
  267. initializer: function () {
  268. return null;
  269. }
  270. }), _descriptor11 = _applyDecoratedDescriptor(_class2.prototype, "enemyPlane02", [_dec10], {
  271. configurable: true,
  272. enumerable: true,
  273. writable: true,
  274. initializer: function () {
  275. return null;
  276. }
  277. }), _descriptor12 = _applyDecoratedDescriptor(_class2.prototype, "createEnemyTime", [property], {
  278. configurable: true,
  279. enumerable: true,
  280. writable: true,
  281. initializer: function () {
  282. return 50;
  283. }
  284. }), _descriptor13 = _applyDecoratedDescriptor(_class2.prototype, "enemySpeed1", [property], {
  285. configurable: true,
  286. enumerable: true,
  287. writable: true,
  288. initializer: function () {
  289. return 0.01;
  290. }
  291. }), _descriptor14 = _applyDecoratedDescriptor(_class2.prototype, "enemySpeed2", [property], {
  292. configurable: true,
  293. enumerable: true,
  294. writable: true,
  295. initializer: function () {
  296. return 0.01;
  297. }
  298. })), _class2)) || _class));
  299. _cclegacy._RF.pop();
  300. _crd = false;
  301. }
  302. };
  303. });
  304. //# sourceMappingURL=60a3cc3dac2a575cb9c89501ac659832dcff1e40.js.map