3b92ab00-4016-4625-9a4a-2ffa910f77b7.js 5.1 KB

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