bd769062-cd84-44ab-ba4c-6665be7e485f.js 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  1. "use strict";
  2. cc._RF.push(module, 'bd769BizYREq7pMZmW+fkhf', 'Playcontroler');
  3. // Script/Playcontroler.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 Playcontroler = /** @class */ (function (_super) {
  28. __extends(Playcontroler, _super);
  29. function Playcontroler() {
  30. // LIFE-CYCLE CALLBACKS:
  31. var _this = _super !== null && _super.apply(this, arguments) || this;
  32. // parent:cc.Node = null;
  33. _this.MainScene = null;
  34. return _this;
  35. }
  36. Playcontroler.prototype.onLoad = function () {
  37. // this.parent = this.node.parent;
  38. this.MainScene = Global_1.default.instance.getMN();
  39. };
  40. Playcontroler.prototype.start = function () {
  41. };
  42. Playcontroler.prototype.update = function (dt) {
  43. if (Global_1.default.instance.OverFlag) {
  44. this.enabled = false;
  45. }
  46. else {
  47. if (!Global_1.default.instance.CollisionFlag) {
  48. this.node.y -= Global_1.default.instance.InitSpeed;
  49. }
  50. else {
  51. var name = Global_1.default.instance.TheHolder.name;
  52. if (name == "") {
  53. return;
  54. }
  55. this.node.y = Global_1.default.instance.TheHolder.y
  56. + Global_1.default.instance.TheHolder.getComponent(name).NodeH - 10; //here ,this way isnot a good Processing method,should be optimizated
  57. }
  58. }
  59. if (Global_1.default.instance.CollisionWithDing) {
  60. this.node.stopAllActions();
  61. Global_1.default.instance.CollisionWithDing = false;
  62. Global_1.default.instance.CollisionFlag = false;
  63. }
  64. };
  65. /**
  66. * player与墙壁的碰撞检测
  67. * @param other 被撞物体
  68. * @param self 碰撞体
  69. */
  70. Playcontroler.prototype.onCollisionEnter = function (other, self) {
  71. var rootSelf = this;
  72. switch (other.node.name) {
  73. case "Bg_0CollisionR": {
  74. self.node.x = 180;
  75. break;
  76. }
  77. case "Bg_0CollisionL": {
  78. self.node.x = -180;
  79. break;
  80. }
  81. case "Bg_1CollisionR": {
  82. self.node.x = 180;
  83. break;
  84. }
  85. case "Bg_1CollisionL": {
  86. self.node.x = -180;
  87. break;
  88. }
  89. // case "tanhuang":{
  90. // if(other.node.x+75>self.node.x&&other.node.x-75<self.node.x){
  91. // let main = Global.instance.getMN();
  92. // main.getChildByName("output").getComponent(cc.Label).string = "tanhuang";
  93. // }
  94. // }
  95. case "ding": {
  96. Global_1.default.instance.CollisionWithDing = true;
  97. self.node.stopAllActions();
  98. rootSelf.LifeZero();
  99. Global_1.default.instance.CollisionFlag = false;
  100. self.node.getComponent(cc.BoxCollider).enabled = false;
  101. rootSelf.scheduleOnce(function (err) {
  102. self.node.getComponent(cc.BoxCollider).enabled = true;
  103. }, 0.3);
  104. break;
  105. }
  106. default: {
  107. // this.MainScene.getComponent("MainScene").Score();//得分
  108. break;
  109. }
  110. }
  111. };
  112. Playcontroler.prototype.LifeZero = function () {
  113. var main = Global_1.default.instance.getMN();
  114. var lifeChil = main.getChildByName("BgNode").getChildByName("LifeDing").children;
  115. var life = new Array();
  116. var lifeNum = 0;
  117. for (var i = 0; i < lifeChil.length; i++) {
  118. if (lifeChil[i].name == "lifeBG") {
  119. life.push(lifeChil[i]);
  120. }
  121. }
  122. for (var i = 0; i < life.length; i++) {
  123. if (life[i].active) {
  124. lifeNum++;
  125. }
  126. }
  127. if (lifeNum == 0) {
  128. return;
  129. }
  130. };
  131. Playcontroler = __decorate([
  132. ccclass
  133. ], Playcontroler);
  134. return Playcontroler;
  135. }(cc.Component));
  136. exports.default = Playcontroler;
  137. /**
  138. * 1.下落速度加快;
  139. * 2.玻璃:先停一会在碎掉;
  140. * 3.传送带速度快一点;
  141. * 4.
  142. */
  143. cc._RF.pop();