ab60d4e9-6ec3-4ad5-a707-43a51f6632e7.js 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. "use strict";
  2. cc._RF.push(module, 'ab60dTpbsNK1acHQ6UfZjLn', 'ChooseLevelPanel');
  3. // Script/view/chooseLevel/ChooseLevelPanel.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 BaseView_1 = require("../../../lightMVC/core/base/BaseView");
  26. var App_1 = require("../../Manager/App");
  27. var SoundManager_1 = require("../../Manager/SoundManager");
  28. var TimeControl_1 = require("../../TimeControl");
  29. var SuperScrollView_1 = require("../SuperScrollview/SuperScrollView");
  30. var _a = cc._decorator, ccclass = _a.ccclass, property = _a.property;
  31. var ChooseLevelPanel = /** @class */ (function (_super) {
  32. __extends(ChooseLevelPanel, _super);
  33. function ChooseLevelPanel() {
  34. var _this = _super !== null && _super.apply(this, arguments) || this;
  35. _this.list = [];
  36. _this.levelList = null;
  37. _this.nodeList = [];
  38. _this.btnList = [];
  39. _this.imgList = [];
  40. _this.labelExp = null;
  41. return _this;
  42. }
  43. ChooseLevelPanel.prototype.drawView = function () {
  44. var _this = this;
  45. // 返回
  46. var closeBtn = this.ui.getNode("close");
  47. closeBtn.on(cc.Node.EventType.TOUCH_END, function () {
  48. _this.closeView();
  49. }, this);
  50. var backBtn = this.ui.getNode("btnBack");
  51. backBtn.on(cc.Node.EventType.TOUCH_END, function () {
  52. _this.closeView();
  53. }, this);
  54. for (var i = 1; i < App_1.App.DataManager.LevelCount + 1; i++) {
  55. this.list.push(i);
  56. }
  57. var nodeName = ["nodeLevel", "nodeFood", "nodeKitchen"];
  58. var btnName = ["btn_level", "btn_food", "btn_kitchen"];
  59. var imgName = ["img_level", "img_food", "img_kitchen"];
  60. var _loop_1 = function (i) {
  61. this_1.nodeList[i] = this_1.ui.getNode(nodeName[i]);
  62. this_1.btnList[i] = this_1.ui.getNode(btnName[i]);
  63. this_1.imgList[i] = this_1.ui.getNode(imgName[i]);
  64. this_1.btnList[i].on(cc.Node.EventType.TOUCH_END, function () {
  65. _this.btnClickCall(i);
  66. }, this_1);
  67. };
  68. var this_1 = this;
  69. for (var i = 0; i < 3; i++) {
  70. _loop_1(i);
  71. }
  72. this.ui.getNode("labelTili").getComponent(cc.Label).string = TimeControl_1.default.instance.currentTili + "/" + TimeControl_1.default.instance.tiliMax;
  73. this.ui.getNode("labelCoin").getComponent(cc.Label).string = App_1.App.DataManager.UserCoin + "";
  74. this.ui.getNode("labelDiamond").getComponent(cc.Label).string = App_1.App.DataManager.UserDiamond + "";
  75. this.CreateLevel();
  76. this.scheduleOnce(function () { _this.SetCenter(App_1.App.DataManager.PlayLevel); }, 0);
  77. App_1.App.SoundManager.playBGM(SoundManager_1.SoundManager.hallBgm[1]);
  78. };
  79. ChooseLevelPanel.prototype.btnClickCall = function (index) {
  80. for (var i = 0; i < this.imgList.length; i++) {
  81. this.nodeList[i].active = false;
  82. this.imgList[i].active = false;
  83. }
  84. this.nodeList[index].active = true;
  85. this.imgList[index].active = true;
  86. };
  87. // 显示玩家金币
  88. ChooseLevelPanel.prototype.ShowUserCoinValue = function () {
  89. if (this) {
  90. this.ui.getNode("labelCoin").getComponent(cc.Label).string = App_1.App.DataManager.UserCoin + "";
  91. }
  92. };
  93. /**
  94. * 生成关卡
  95. */
  96. ChooseLevelPanel.prototype.CreateLevel = function () {
  97. console.log('生成关卡');
  98. this.levelList = this.ui.getNode("levelList");
  99. this.levelList.getComponent(SuperScrollView_1.default).setData(this.list, false, null);
  100. };
  101. /**
  102. * 设置关卡居中显示
  103. * @param currentPlayLevel 最后游玩关卡
  104. */
  105. ChooseLevelPanel.prototype.SetCenter = function (currentPlayLevel) {
  106. var maxShowRow = 4;
  107. var maxShowColumn = 4;
  108. var currentRow = Math.ceil(currentPlayLevel / maxShowColumn);
  109. var wholeRow = Math.ceil(this.list.length / maxShowColumn);
  110. if (currentRow < maxShowRow) {
  111. this.levelList.getComponent(cc.ScrollView).scrollToTop(0.1);
  112. console.log("最上方");
  113. }
  114. else if (currentRow > wholeRow - maxShowRow) {
  115. this.levelList.getComponent(cc.ScrollView).scrollToBottom(0.1);
  116. console.log("最下方");
  117. }
  118. else {
  119. var percent = currentRow / wholeRow;
  120. this.levelList.getComponent(cc.ScrollView).scrollToPercentVertical(percent, 0.1, true);
  121. }
  122. };
  123. ChooseLevelPanel.path = function () {
  124. return "hallScene/prefabs/ChooseLevelPanel";
  125. };
  126. ChooseLevelPanel.prototype.onDestroy = function () {
  127. this.closeView();
  128. };
  129. ChooseLevelPanel = __decorate([
  130. ccclass
  131. ], ChooseLevelPanel);
  132. return ChooseLevelPanel;
  133. }(BaseView_1.BaseView));
  134. exports.default = ChooseLevelPanel;
  135. cc._RF.pop();