317cdf1a2cc677419bfe696f1a4a7546f5b13f08.js 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. System.register(["__unresolved_0", "cc", "__unresolved_1"], function (_export, _context) {
  2. "use strict";
  3. var _reporterNs, _cclegacy, __checkObsolete__, __checkObsoleteInNamespace__, _decorator, Collider, Component, constant, _dec, _class, _crd, ccclass, property, OUTOFBOUNCE, enemyPlane;
  4. function _reportPossibleCrUseOfconstant(extras) {
  5. _reporterNs.report("constant", "../framework/constant", _context.meta, extras);
  6. }
  7. function _reportPossibleCrUseOfgameMangager(extras) {
  8. _reporterNs.report("gameMangager", "../framework/gameMangager", _context.meta, extras);
  9. }
  10. return {
  11. setters: [function (_unresolved_) {
  12. _reporterNs = _unresolved_;
  13. }, function (_cc) {
  14. _cclegacy = _cc.cclegacy;
  15. __checkObsolete__ = _cc.__checkObsolete__;
  16. __checkObsoleteInNamespace__ = _cc.__checkObsoleteInNamespace__;
  17. _decorator = _cc._decorator;
  18. Collider = _cc.Collider;
  19. Component = _cc.Component;
  20. }, function (_unresolved_2) {
  21. constant = _unresolved_2.constant;
  22. }],
  23. execute: function () {
  24. _crd = true;
  25. _cclegacy._RF.push({}, "fd1ddS50lhH3LjBrCyqMPL7", "enemyPlane", undefined);
  26. __checkObsolete__(['_decorator', 'Collider', 'Component', 'ITriggerEvent', 'Node', 'sp']);
  27. ({
  28. ccclass,
  29. property
  30. } = _decorator);
  31. OUTOFBOUNCE = 50;
  32. _export("enemyPlane", enemyPlane = (_dec = ccclass('enemyPlane'), _dec(_class = class enemyPlane extends Component {
  33. constructor(...args) {
  34. super(...args);
  35. // @property
  36. // public enemySpeed = 0;
  37. this._enemySpeed = 0;
  38. this.enemyType = (_crd && constant === void 0 ? (_reportPossibleCrUseOfconstant({
  39. error: Error()
  40. }), constant) : constant).EnemyPlaneType.TYPE1;
  41. this._gameManager = null;
  42. }
  43. start() {}
  44. update(deltaTime) {
  45. const pos = this.node.position;
  46. const movePos = pos.x - this._enemySpeed;
  47. this.node.setPosition(movePos, pos.y, pos.z);
  48. if (movePos > OUTOFBOUNCE) {
  49. this.node.destroy();
  50. }
  51. }
  52. show(gameManager, speed) {
  53. this._gameManager = gameManager;
  54. this._enemySpeed = speed;
  55. } // 碰撞业务
  56. onEnable() {
  57. const collider = this.getComponent(Collider);
  58. collider.on('onTriggerEnter', this._onTriggerEnter, this);
  59. }
  60. onDisable() {
  61. const collider = this.getComponent(Collider);
  62. collider.off('onTriggerEnter', this._onTriggerEnter, this);
  63. }
  64. _onTriggerEnter(event) {
  65. const collisionGroup = event.otherCollider.getGroup();
  66. console.log('敌人');
  67. if (collisionGroup === (_crd && constant === void 0 ? (_reportPossibleCrUseOfconstant({
  68. error: Error()
  69. }), constant) : constant).CollisionType.SELF_BULLET || collisionGroup === (_crd && constant === void 0 ? (_reportPossibleCrUseOfconstant({
  70. error: Error()
  71. }), constant) : constant).CollisionType.SELF_PLANE) {
  72. this.node.destroy();
  73. this._gameManager.addScore();
  74. }
  75. }
  76. }) || _class));
  77. _cclegacy._RF.pop();
  78. _crd = false;
  79. }
  80. };
  81. });
  82. //# sourceMappingURL=317cdf1a2cc677419bfe696f1a4a7546f5b13f08.js.map