c3fcd624-b7d1-4cb4-9836-f877935178f0.js 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. "use strict";
  2. cc._RF.push(module, 'c3fcdYkt9FMtJg2+HeTUXjw', 'Opplvdai');
  3. // Script/Opplvdai.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 Opplvdai = /** @class */ (function (_super) {
  28. __extends(Opplvdai, _super);
  29. function Opplvdai() {
  30. var _this = _super !== null && _super.apply(this, arguments) || this;
  31. /**
  32. * 落脚点类型 2:向右传送带
  33. */
  34. _this.KIND_FootHold = 2;
  35. /**
  36. * player是否落在落脚点上,默认false,没有
  37. */
  38. _this.isHold = false;
  39. _this.NodeH = 69;
  40. _this.GoUp = false;
  41. _this.main = null;
  42. /**
  43. * 落脚点对应动画
  44. */
  45. _this.Ani = null;
  46. _this.AniState = null;
  47. _this.gainSc = false;
  48. return _this;
  49. }
  50. Opplvdai.prototype.onLoad = function () {
  51. this.node.y = -500;
  52. this.node.x = (Math.random() * 2 - 1) * 140;
  53. this.Ani = this.node.getComponent(cc.Animation);
  54. this.AniState = this.Ani.play("Opplvdai");
  55. this.AniState.repeatCount = 100;
  56. this.AniState.speed = 2;
  57. };
  58. Opplvdai.prototype.start = function () {
  59. };
  60. Opplvdai.prototype.update = function (dt) {
  61. // console.log(Global.instance.CollisionFlag);
  62. var self = this;
  63. if (Global_1.default.instance.OverFlag) {
  64. self.enabled = false;
  65. }
  66. else {
  67. this.node.active = true;
  68. this.node.y += Global_1.default.instance.FHFallSpeed;
  69. if (this.node.isHold) {
  70. Global_1.default.instance.CollisionFlag = true;
  71. Global_1.default.instance.TheHolder = this.node;
  72. }
  73. if (this.node.y > 360) {
  74. if (this.node.isHold) {
  75. this.node.isHold = false;
  76. Global_1.default.instance.CollisionFlag = false;
  77. }
  78. this.node.destroy();
  79. }
  80. }
  81. };
  82. /**
  83. * 初始化函数
  84. * @param main 主场景
  85. */
  86. Opplvdai.prototype.init = function (main) {
  87. this.main = main;
  88. };
  89. /**
  90. * 获取落脚点类型
  91. */
  92. Opplvdai.prototype.getKind = function () {
  93. return this.KIND_FootHold;
  94. };
  95. Opplvdai.prototype.onCollisionEnter = function (other, self) {
  96. var rootself = this; //当前根节点
  97. if (rootself.GoUp) {
  98. return;
  99. }
  100. Global_1.default.instance.KIND_FootHold = this.KIND_FootHold;
  101. Global_1.default.instance.TheHolder = this.node;
  102. if (other.tag == 111) {
  103. console.log("我被撞到了");
  104. rootself.main.Score();
  105. rootself.gainSc = true;
  106. rootself.GoUp = true;
  107. return;
  108. }
  109. // this.main.Score();
  110. if (!Global_1.default.instance.CollisionFlag) {
  111. // console.log(other);
  112. // console.log("2检测到碰撞!!!");
  113. // console.log(self);
  114. // other.node.y = this.node.y+50;
  115. self.node.isHold = true;
  116. Global_1.default.instance.CollisionFlag = true;
  117. }
  118. };
  119. __decorate([
  120. property(Boolean)
  121. ], Opplvdai.prototype, "isHold", void 0);
  122. __decorate([
  123. property(Number)
  124. ], Opplvdai.prototype, "NodeH", void 0);
  125. Opplvdai = __decorate([
  126. ccclass
  127. ], Opplvdai);
  128. return Opplvdai;
  129. }(cc.Component));
  130. exports.default = Opplvdai;
  131. cc._RF.pop();