aa287443-ac67-45bb-8100-acca56e790bf.js 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  1. "use strict";
  2. cc._RF.push(module, 'aa287RDrGdFu4EArMpW55C/', 'tanhuang');
  3. // Script/tanhuang.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 tanhuang = /** @class */ (function (_super) {
  28. __extends(tanhuang, _super);
  29. function tanhuang() {
  30. var _this = _super !== null && _super.apply(this, arguments) || this;
  31. /**
  32. * 落脚点类型 2:tanhuang
  33. */
  34. _this.KIND_FootHold = 2;
  35. /**
  36. * player是否落在落脚点上,默认false,没有
  37. */
  38. _this.isHold = false;
  39. _this.NodeH = 60;
  40. _this.GoUp = false;
  41. _this.gainSc = false; //弹簧加分标志
  42. _this.main = null;
  43. /**
  44. * 落脚点对应动画
  45. */
  46. _this.Ani = null;
  47. _this.AniState = null;
  48. return _this;
  49. }
  50. tanhuang.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.gainSc = false;
  55. };
  56. tanhuang.prototype.start = function () {
  57. this.Ding = this.main.node.getChildByName("BgNode").getChildByName("LifeDing").getChildByName("ding");
  58. };
  59. tanhuang.prototype.update = function (dt) {
  60. // console.log(Global.instance.CollisionFlag);
  61. var self = this;
  62. if (Global_1.default.instance.OverFlag) {
  63. self.enabled = false;
  64. }
  65. else {
  66. this.node.active = true;
  67. this.node.y += Global_1.default.instance.FHFallSpeed;
  68. if (this.node.isHold) {
  69. Global_1.default.instance.CollisionFlag = true;
  70. Global_1.default.instance.TheHolder = this.node;
  71. }
  72. if (this.node.y > 360) {
  73. if (this.node.isHold) {
  74. Global_1.default.instance.CollisionFlag = false;
  75. this.node.isHold = false;
  76. }
  77. this.node.destroy();
  78. }
  79. }
  80. };
  81. /**
  82. * 初始化函数
  83. * @param main 主场景
  84. */
  85. tanhuang.prototype.init = function (main) {
  86. this.main = main;
  87. };
  88. /**
  89. * 获取落脚点类型
  90. */
  91. tanhuang.prototype.getKind = function () {
  92. return this.KIND_FootHold;
  93. };
  94. /**
  95. * 碰撞
  96. * @param other 碰撞主体player
  97. * @param self 碰撞主体落脚点tanhuang
  98. */
  99. tanhuang.prototype.onCollisionEnter = function (other, self) {
  100. var rootself = this;
  101. if (rootself.GoUp) {
  102. return;
  103. }
  104. if (rootself.main == null) {
  105. rootself.main = Global_1.default.instance.getMN();
  106. }
  107. if (other.tag === 111) {
  108. if (rootself.gainSc == false) {
  109. rootself.main.Score();
  110. rootself.gainSc = true;
  111. rootself.GoUp = true;
  112. }
  113. return;
  114. }
  115. else {
  116. Global_1.default.instance.KIND_FootHold = rootself.KIND_FootHold;
  117. if (!Global_1.default.instance.CollisionFlag) {
  118. Global_1.default.instance.CollisionFlag = true;
  119. Global_1.default.instance.TheHolder = rootself.node;
  120. rootself.isHold = true;
  121. other.node.y = self.node.y + 60;
  122. var spawn = void 0;
  123. spawn = cc.spawn(cc.callFunc(function () {
  124. if (rootself.Ani == null) {
  125. return;
  126. }
  127. rootself.AniState = rootself.Ani.play("tanhuang");
  128. rootself.AniState.speed = 0.8;
  129. }), cc.callFunc(function () {
  130. other.node.runAction(cc.moveBy(0.15, 0, 50));
  131. Global_1.default.instance.CollisionFlag = false;
  132. rootself.isHold = false;
  133. other.node.getComponent("Playcontroler").enabled = false;
  134. }));
  135. rootself.scheduleOnce(function () {
  136. other.node.getComponent("Playcontroler").enabled = true;
  137. }, 0.27);
  138. rootself.scheduleOnce(function () {
  139. // console.log(Global.instance.CollisionFlag+"5")
  140. Global_1.default.instance.CollisionFlag = false;
  141. rootself.isHold = false;
  142. rootself.Ani.stop();
  143. }, 0.41);
  144. other.node.runAction(spawn);
  145. }
  146. }
  147. };
  148. __decorate([
  149. property(Boolean)
  150. ], tanhuang.prototype, "isHold", void 0);
  151. __decorate([
  152. property(Number)
  153. ], tanhuang.prototype, "NodeH", void 0);
  154. tanhuang = __decorate([
  155. ccclass
  156. ], tanhuang);
  157. return tanhuang;
  158. }(cc.Component));
  159. exports.default = tanhuang;
  160. cc._RF.pop();