e6ab6a6f-b4a5-4b3a-b682-058d93b6140a.js 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. "use strict";
  2. cc._RF.push(module, 'e6ab6pvtKVLOraCBY2TthQK', 'LevelItem');
  3. // Script/view/chooseLevel/LevelItem.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 App_1 = require("../../Manager/App");
  26. var SuperListItem_1 = require("../SuperScrollview/SuperListItem");
  27. var TipPanel_1 = require("../tipPanel/TipPanel");
  28. var TipPanelMediator_1 = require("../tipPanel/TipPanelMediator");
  29. var NodeLevel_1 = require("./NodeLevel");
  30. var _a = cc._decorator, ccclass = _a.ccclass, property = _a.property;
  31. var LevelItem = /** @class */ (function (_super) {
  32. __extends(LevelItem, _super);
  33. function LevelItem() {
  34. var _this = _super !== null && _super.apply(this, arguments) || this;
  35. _this.label = null;
  36. _this.level = 1;
  37. _this.lock = null;
  38. _this.open = null;
  39. _this.pass = null;
  40. _this.star = [];
  41. _this.key = null;
  42. _this.isPass = false;
  43. return _this;
  44. }
  45. // LIFE-CYCLE CALLBACKS:
  46. LevelItem.prototype.onLoad = function () {
  47. // this.lock.on(cc.Node.EventType.TOUCH_END, this.btnClickCallBack.bind(this), this);
  48. this.open.on(cc.Node.EventType.TOUCH_END, this.btnClickCallBack.bind(this), this);
  49. this.pass.on(cc.Node.EventType.TOUCH_END, this.btnClickCallBack.bind(this), this);
  50. };
  51. LevelItem.prototype.setData = function (data) {
  52. // console.log('LevelItem:', data)
  53. this.label.string = data;
  54. this.level = Number(data);
  55. // 判断这一关是都通过,通过是否有值
  56. this.isPass = (App_1.App.DataManager.PassProgress[this.level]) ? true : false;
  57. this.lock.active = !this.isPass;
  58. this.label.node.active = this.isPass;
  59. if (this.isPass) {
  60. if (App_1.App.DataManager.PassProgress[this.level] > 3) {
  61. this.pass.active = true;
  62. }
  63. else if (App_1.App.DataManager.PassProgress[this.level] > 1) {
  64. this.pass.active = true;
  65. }
  66. else {
  67. this.open.active = true;
  68. this.pass.active = false;
  69. }
  70. for (var i = 0; i < 3; i++) {
  71. var star = this.node.getChildByName("star" + i);
  72. var passStar = Number(App_1.App.DataManager.PassProgress[this.level]);
  73. star.active = passStar - 1 > i;
  74. }
  75. }
  76. else {
  77. for (var i = 0; i < 3; i++) {
  78. var star = this.node.getChildByName("star" + i);
  79. star.active = false;
  80. }
  81. }
  82. console.log('是否通关', App_1.App.DataManager.PassProgress[this.level]);
  83. this.key.active = App_1.App.DataManager.PassProgress[this.level] > App_1.App.DataManager.keyPos[this.level];
  84. };
  85. LevelItem.prototype.btnClickCallBack = function () {
  86. if (this.isPass) {
  87. if (App_1.App.DataManager.PassProgress[this.level] > 3) {
  88. console.log('Game level pass~');
  89. App_1.App.Facade.popView(TipPanelMediator_1.default, TipPanel_1.default, "Game level pass~", false);
  90. return;
  91. }
  92. else {
  93. cc.find("Canvas/ChooseLevelPanel/nodeLevel").getComponent(NodeLevel_1.default).freshLevelNum(this.level);
  94. // console.log("aaa---------------", cc.find("Canvas/ChooseLevelPanel/nodeLevel").name);
  95. }
  96. }
  97. else {
  98. console.log('Level not unlocked~');
  99. App_1.App.Facade.popView(TipPanelMediator_1.default, TipPanel_1.default, "Level not unlocked~", false);
  100. return;
  101. }
  102. };
  103. __decorate([
  104. property(cc.Label)
  105. ], LevelItem.prototype, "label", void 0);
  106. __decorate([
  107. property(cc.Node)
  108. ], LevelItem.prototype, "lock", void 0);
  109. __decorate([
  110. property(cc.Node)
  111. ], LevelItem.prototype, "open", void 0);
  112. __decorate([
  113. property(cc.Node)
  114. ], LevelItem.prototype, "pass", void 0);
  115. __decorate([
  116. property([cc.Node])
  117. ], LevelItem.prototype, "star", void 0);
  118. __decorate([
  119. property(cc.Node)
  120. ], LevelItem.prototype, "key", void 0);
  121. LevelItem = __decorate([
  122. ccclass
  123. ], LevelItem);
  124. return LevelItem;
  125. }(SuperListItem_1.default));
  126. exports.default = LevelItem;
  127. cc._RF.pop();