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

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