123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137 |
- "use strict";
- cc._RF.push(module, 'ab60dTpbsNK1acHQ6UfZjLn', 'ChooseLevelPanel');
- // Script/view/chooseLevel/ChooseLevelPanel.ts
- "use strict";
- var __extends = (this && this.__extends) || (function () {
- var extendStatics = function (d, b) {
- extendStatics = Object.setPrototypeOf ||
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
- function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
- return extendStatics(d, b);
- };
- return function (d, b) {
- extendStatics(d, b);
- function __() { this.constructor = d; }
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
- };
- })();
- var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
- 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;
- return c > 3 && r && Object.defineProperty(target, key, r), r;
- };
- Object.defineProperty(exports, "__esModule", { value: true });
- var BaseView_1 = require("../../../lightMVC/core/base/BaseView");
- var App_1 = require("../../Manager/App");
- var SoundManager_1 = require("../../Manager/SoundManager");
- var TimeControl_1 = require("../../TimeControl");
- var SuperScrollView_1 = require("../SuperScrollview/SuperScrollView");
- var _a = cc._decorator, ccclass = _a.ccclass, property = _a.property;
- var ChooseLevelPanel = /** @class */ (function (_super) {
- __extends(ChooseLevelPanel, _super);
- function ChooseLevelPanel() {
- var _this = _super !== null && _super.apply(this, arguments) || this;
- _this.list = [];
- _this.levelList = null;
- _this.nodeList = [];
- _this.btnList = [];
- _this.imgList = [];
- _this.labelExp = null;
- return _this;
- }
- ChooseLevelPanel.prototype.drawView = function () {
- var _this = this;
- // 返回
- var closeBtn = this.ui.getNode("close");
- closeBtn.on(cc.Node.EventType.TOUCH_END, function () {
- _this.closeView();
- }, this);
- var backBtn = this.ui.getNode("btnBack");
- backBtn.on(cc.Node.EventType.TOUCH_END, function () {
- _this.closeView();
- }, this);
- for (var i = 1; i < App_1.App.DataManager.LevelCount + 1; i++) {
- this.list.push(i);
- }
- var nodeName = ["nodeLevel", "nodeFood", "nodeKitchen"];
- var btnName = ["btn_level", "btn_food", "btn_kitchen"];
- var imgName = ["img_level", "img_food", "img_kitchen"];
- var _loop_1 = function (i) {
- this_1.nodeList[i] = this_1.ui.getNode(nodeName[i]);
- this_1.btnList[i] = this_1.ui.getNode(btnName[i]);
- this_1.imgList[i] = this_1.ui.getNode(imgName[i]);
- this_1.btnList[i].on(cc.Node.EventType.TOUCH_END, function () {
- _this.btnClickCall(i);
- }, this_1);
- };
- var this_1 = this;
- for (var i = 0; i < 3; i++) {
- _loop_1(i);
- }
- this.ui.getNode("labelTili").getComponent(cc.Label).string = TimeControl_1.default.instance.currentTili + "/" + TimeControl_1.default.instance.tiliMax;
- this.ui.getNode("labelCoin").getComponent(cc.Label).string = App_1.App.DataManager.UserCoin + "";
- this.ui.getNode("labelDiamond").getComponent(cc.Label).string = App_1.App.DataManager.UserDiamond + "";
- this.CreateLevel();
- this.scheduleOnce(function () { _this.SetCenter(App_1.App.DataManager.PlayLevel); }, 0);
- App_1.App.SoundManager.playBGM(SoundManager_1.SoundManager.hallBgm[1]);
- };
- ChooseLevelPanel.prototype.btnClickCall = function (index) {
- for (var i = 0; i < this.imgList.length; i++) {
- this.nodeList[i].active = false;
- this.imgList[i].active = false;
- }
- this.nodeList[index].active = true;
- this.imgList[index].active = true;
- };
- // 显示玩家金币
- ChooseLevelPanel.prototype.ShowUserCoinValue = function () {
- if (this) {
- this.ui.getNode("labelCoin").getComponent(cc.Label).string = App_1.App.DataManager.UserCoin + "";
- }
- };
- /**
- * 生成关卡
- */
- ChooseLevelPanel.prototype.CreateLevel = function () {
- console.log('生成关卡');
- this.levelList = this.ui.getNode("levelList");
- this.levelList.getComponent(SuperScrollView_1.default).setData(this.list, false, null);
- };
- /**
- * 设置关卡居中显示
- * @param currentPlayLevel 最后游玩关卡
- */
- ChooseLevelPanel.prototype.SetCenter = function (currentPlayLevel) {
- var maxShowRow = 4;
- var maxShowColumn = 4;
- var currentRow = Math.ceil(currentPlayLevel / maxShowColumn);
- var wholeRow = Math.ceil(this.list.length / maxShowColumn);
- if (currentRow < maxShowRow) {
- this.levelList.getComponent(cc.ScrollView).scrollToTop(0.1);
- console.log("最上方");
- }
- else if (currentRow > wholeRow - maxShowRow) {
- this.levelList.getComponent(cc.ScrollView).scrollToBottom(0.1);
- console.log("最下方");
- }
- else {
- var percent = currentRow / wholeRow;
- this.levelList.getComponent(cc.ScrollView).scrollToPercentVertical(percent, 0.1, true);
- }
- };
- ChooseLevelPanel.path = function () {
- return "hallScene/prefabs/ChooseLevelPanel";
- };
- ChooseLevelPanel.prototype.onDestroy = function () {
- this.closeView();
- };
- ChooseLevelPanel = __decorate([
- ccclass
- ], ChooseLevelPanel);
- return ChooseLevelPanel;
- }(BaseView_1.BaseView));
- exports.default = ChooseLevelPanel;
- cc._RF.pop();
|