d80cc3ed-52f1-4019-88d8-8a20ab2c7b7f.js 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  1. "use strict";
  2. cc._RF.push(module, 'd80ccPtUvFAGYjYiiCrLHt/', 'lvdai');
  3. // Script/lvdai.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 lvdai = /** @class */ (function (_super) {
  28. __extends(lvdai, _super);
  29. function lvdai() {
  30. var _this = _super !== null && _super.apply(this, arguments) || this;
  31. /**
  32. * 落脚点类型 3/4:传送带
  33. */
  34. _this.KIND_FootHold = 0;
  35. /**
  36. * player是否落在落脚点上,默认false,没有
  37. */
  38. _this.isHold = false;
  39. _this.NodeH = 60;
  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. lvdai.prototype.onLoad = function () {
  51. var kind = Math.random();
  52. this.node.y = -500;
  53. this.node.x = (Math.random() * 2 - 1) * 140;
  54. this.Ani = this.node.getComponent(cc.Animation);
  55. this.AniState = this.Ani.play("lvdai");
  56. if (kind <= 0.5) {
  57. this.KIND_FootHold = 3;
  58. }
  59. else {
  60. this.KIND_FootHold = 4;
  61. this.AniState.wrapMode = cc.WrapMode.Reverse; //设置动画的播放方式为倒放
  62. }
  63. this.AniState.repeatCount = 100;
  64. this.AniState.speed = 2;
  65. /**
  66. * 这里有点问题,设置模式貌似不奏效。一旦成功可以减小包体
  67. */
  68. };
  69. lvdai.prototype.start = function () {
  70. };
  71. lvdai.prototype.update = function (dt) {
  72. // console.log(Global.instance.CollisionFlag);
  73. var self = this;
  74. if (Global_1.default.instance.OverFlag) {
  75. self.enabled = false;
  76. }
  77. else {
  78. this.node.active = true;
  79. this.node.y += Global_1.default.instance.FHFallSpeed;
  80. if (this.node.isHold) {
  81. Global_1.default.instance.CollisionFlag = true;
  82. Global_1.default.instance.TheHolder = this.node;
  83. }
  84. if (this.node.y > 360) {
  85. if (this.node.isHold) {
  86. this.node.isHold = false;
  87. Global_1.default.instance.CollisionFlag = false;
  88. }
  89. this.node.destroy();
  90. }
  91. }
  92. };
  93. /**
  94. * 初始化函数
  95. * @param main 主场景
  96. */
  97. lvdai.prototype.init = function (main) {
  98. this.main = main;
  99. };
  100. /**
  101. * 获取落脚点类型
  102. */
  103. lvdai.prototype.getKind = function () {
  104. return this.KIND_FootHold;
  105. };
  106. lvdai.prototype.onCollisionEnter = function (other, self) {
  107. var rootself = this; //当前根节点
  108. if (rootself.GoUp) {
  109. return;
  110. }
  111. Global_1.default.instance.KIND_FootHold = this.KIND_FootHold;
  112. Global_1.default.instance.TheHolder = this.node;
  113. if (other.tag == 111) {
  114. // console.log("我被撞到了");
  115. rootself.main.Score();
  116. rootself.gainSc = true;
  117. return;
  118. }
  119. // this.main.Score();
  120. if (!Global_1.default.instance.CollisionFlag) {
  121. // console.log(other);
  122. // console.log("5检测到碰撞!!!");
  123. // console.log(self);
  124. self.node.isHold = true;
  125. Global_1.default.instance.CollisionFlag = true;
  126. }
  127. };
  128. __decorate([
  129. property(Boolean)
  130. ], lvdai.prototype, "isHold", void 0);
  131. __decorate([
  132. property(Number)
  133. ], lvdai.prototype, "NodeH", void 0);
  134. lvdai = __decorate([
  135. ccclass
  136. ], lvdai);
  137. return lvdai;
  138. }(cc.Component));
  139. exports.default = lvdai;
  140. cc._RF.pop();