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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  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. return _this;
  50. }
  51. GD.prototype.onLoad = function () {
  52. this.node.y = -500;
  53. // this.KIND_FootHold==7
  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. }
  62. if (this.KIND_FootHold == 7) {
  63. // this.KIND_FootHold = 7;
  64. this.node.x = (Math.random() * 2 - 1) * 140;
  65. }
  66. if (this.KIND_FootHold == 1) {
  67. this.node.getChildByName("gd").getComponent("CliGD").enabled = false;
  68. }
  69. else {
  70. this.node.getChildByName("gd").getComponent("CliGD").enabled = true;
  71. }
  72. this.LifeDing = this.main.LifeDing.children;
  73. };
  74. GD.prototype.update = function (dt) {
  75. // console.log(Global.instance.CollisionFlag);
  76. var self = this;
  77. // console.log("状态:"+ self.node.active+",位置:"+self.node.x);
  78. if (Global_1.default.instance.OverFlag) {
  79. self.enabled = false;
  80. }
  81. else {
  82. this.node.active = true;
  83. if (this.node.isHold) {
  84. Global_1.default.instance.CollisionFlag = true;
  85. Global_1.default.instance.TheHolder = this.node;
  86. this.node.y += Global_1.default.instance.FHFallSpeed;
  87. }
  88. else {
  89. this.node.y += Global_1.default.instance.FHFallSpeed;
  90. }
  91. if (this.node.y > 360) {
  92. if (this.node.isHold) {
  93. this.node.isHold = false;
  94. Global_1.default.instance.CollisionFlag = false;
  95. }
  96. this.node.destroy();
  97. }
  98. }
  99. };
  100. GD.prototype.MoveThis = function () {
  101. };
  102. /**
  103. * 初始化函数
  104. * @param main 主场景
  105. */
  106. GD.prototype.init = function (main, kind) {
  107. this.main = main;
  108. this.KIND_FootHold = kind;
  109. };
  110. /**
  111. * 获取落脚点类型
  112. */
  113. GD.prototype.getKind = function () {
  114. return this.KIND_FootHold;
  115. };
  116. GD.prototype.onCollisionEnter = function (other, self) {
  117. var rootself = this;
  118. if (rootself.GoUp) {
  119. return;
  120. }
  121. if (other.tag == 111) {
  122. // console.log("我被撞到了");
  123. rootself.main.Score();
  124. rootself.gainSc = true;
  125. rootself.GoUp = true;
  126. return;
  127. }
  128. Global_1.default.instance.TheHolder = this.node;
  129. Global_1.default.instance.KIND_FootHold = this.KIND_FootHold;
  130. Global_1.default.instance.CollisionFlag = true;
  131. this.node.isHold = true;
  132. // this.main.Score();
  133. };
  134. __decorate([
  135. property(Boolean)
  136. ], GD.prototype, "isHold", void 0);
  137. __decorate([
  138. property(Number)
  139. ], GD.prototype, "NodeH", void 0);
  140. GD = __decorate([
  141. ccclass
  142. ], GD);
  143. return GD;
  144. }(cc.Component));
  145. exports.default = GD;
  146. cc._RF.pop();