8788251f-1b51-461e-97ec-1e54b61878d6.js 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. "use strict";
  2. cc._RF.push(module, '87882UfG1FGHpfsHlS2GHjW', 'shandian');
  3. // Script/shandian.ts
  4. "use strict";
  5. var __extends = (this && this.__extends) || (function () {
  6. var extendStatics = function (d, b) {
  7. extendStatics = Object.setPrototypeOf ||
  8. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  9. function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
  10. return extendStatics(d, b);
  11. };
  12. return function (d, b) {
  13. extendStatics(d, b);
  14. function __() { this.constructor = d; }
  15. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  16. };
  17. })();
  18. var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
  19. var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  20. if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  21. else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
  22. return c > 3 && r && Object.defineProperty(target, key, r), r;
  23. };
  24. Object.defineProperty(exports, "__esModule", { value: true });
  25. var Global_1 = require("./Global");
  26. var _a = cc._decorator, ccclass = _a.ccclass, property = _a.property;
  27. var shandian = /** @class */ (function (_super) {
  28. __extends(shandian, _super);
  29. function shandian() {
  30. var _this = _super !== null && _super.apply(this, arguments) || this;
  31. /**
  32. * 落脚点类型 8:闪电
  33. */
  34. _this.KIND_FootHold = 8;
  35. /**
  36. * player是否落在落脚点上,默认false,没有
  37. */
  38. _this.isHold = false;
  39. _this.NodeH = 50;
  40. _this.main = null;
  41. /**
  42. * 落脚点对应动画
  43. */
  44. _this.Ani = null;
  45. _this.AniState = null;
  46. _this.gainSc = false;
  47. return _this;
  48. }
  49. shandian.prototype.onLoad = function () {
  50. this.node.y = -500;
  51. this.node.x = (Math.random() * 2 - 1) * 140;
  52. this.Ani = this.node.getComponent(cc.Animation);
  53. this.AniState = this.Ani.play("shandian");
  54. this.AniState.repeatCount = 100;
  55. };
  56. shandian.prototype.start = function () {
  57. };
  58. shandian.prototype.update = function (dt) {
  59. // console.log(Global.instance.CollisionFlag);
  60. var self = this;
  61. if (Global_1.default.instance.OverFlag) {
  62. self.enabled = false;
  63. }
  64. else {
  65. this.node.active = true;
  66. this.node.y += Global_1.default.instance.FHFallSpeed;
  67. if (this.node.isHold) {
  68. Global_1.default.instance.CollisionFlag = true;
  69. Global_1.default.instance.TheHolder = this.node;
  70. }
  71. if (this.node.y > 360) {
  72. if (this.node.isHold) {
  73. this.node.isHold = false;
  74. Global_1.default.instance.CollisionFlag = false;
  75. }
  76. this.node.destroy();
  77. }
  78. }
  79. };
  80. /**
  81. * 初始化函数
  82. * @param main 主场景
  83. */
  84. shandian.prototype.init = function (main) {
  85. this.main = main;
  86. };
  87. /**
  88. * 获取落脚点类型
  89. */
  90. shandian.prototype.getKind = function () {
  91. return this.KIND_FootHold;
  92. };
  93. shandian.prototype.onCollisionEnter = function (other, self) {
  94. var rootself = this;
  95. switch (other.tag) {
  96. case 0: {
  97. Global_1.default.instance.KIND_FootHold = this.KIND_FootHold;
  98. Global_1.default.instance.TheHolder = this.node;
  99. Global_1.default.instance.Injured = true;
  100. break;
  101. }
  102. case 111: {
  103. console.log("我被撞到了");
  104. rootself.main.Score();
  105. rootself.gainSc = true;
  106. return;
  107. }
  108. }
  109. // this.main.Score();
  110. if (!Global_1.default.instance.CollisionFlag) {
  111. self.node.isHold = false;
  112. Global_1.default.instance.CollisionFlag = false;
  113. }
  114. };
  115. __decorate([
  116. property(Boolean)
  117. ], shandian.prototype, "isHold", void 0);
  118. __decorate([
  119. property(Number)
  120. ], shandian.prototype, "NodeH", void 0);
  121. shandian = __decorate([
  122. ccclass
  123. ], shandian);
  124. return shandian;
  125. }(cc.Component));
  126. exports.default = shandian;
  127. cc._RF.pop();