"use strict"; cc._RF.push(module, 'e6ab6pvtKVLOraCBY2TthQK', 'LevelItem'); // Script/view/chooseLevel/LevelItem.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 App_1 = require("../../Manager/App"); var SuperListItem_1 = require("../SuperScrollview/SuperListItem"); var TipPanel_1 = require("../tipPanel/TipPanel"); var TipPanelMediator_1 = require("../tipPanel/TipPanelMediator"); var NodeLevel_1 = require("./NodeLevel"); var _a = cc._decorator, ccclass = _a.ccclass, property = _a.property; var LevelItem = /** @class */ (function (_super) { __extends(LevelItem, _super); function LevelItem() { var _this = _super !== null && _super.apply(this, arguments) || this; _this.label = null; _this.level = 1; _this.lock = null; _this.open = null; _this.pass = null; _this.star = []; _this.key = null; _this.isPass = false; return _this; } // LIFE-CYCLE CALLBACKS: LevelItem.prototype.onLoad = function () { // this.lock.on(cc.Node.EventType.TOUCH_END, this.btnClickCallBack.bind(this), this); this.open.on(cc.Node.EventType.TOUCH_END, this.btnClickCallBack.bind(this), this); this.pass.on(cc.Node.EventType.TOUCH_END, this.btnClickCallBack.bind(this), this); }; LevelItem.prototype.setData = function (data) { // console.log('LevelItem:', data) this.label.string = data; this.level = Number(data); // 判断这一关是都通过,通过是否有值 this.isPass = (App_1.App.DataManager.PassProgress[this.level]) ? true : false; this.lock.active = !this.isPass; this.label.node.active = this.isPass; if (this.isPass) { if (App_1.App.DataManager.PassProgress[this.level] > 3) { this.pass.active = true; } else if (App_1.App.DataManager.PassProgress[this.level] > 1) { this.pass.active = true; } else { this.open.active = true; this.pass.active = false; } for (var i = 0; i < 3; i++) { var star = this.node.getChildByName("star" + i); var passStar = Number(App_1.App.DataManager.PassProgress[this.level]); star.active = passStar - 1 > i; } } else { for (var i = 0; i < 3; i++) { var star = this.node.getChildByName("star" + i); star.active = false; } } console.log('是否通关', App_1.App.DataManager.PassProgress[this.level]); this.key.active = App_1.App.DataManager.PassProgress[this.level] > App_1.App.DataManager.keyPos[this.level]; }; LevelItem.prototype.btnClickCallBack = function () { if (this.isPass) { if (App_1.App.DataManager.PassProgress[this.level] > 3) { console.log('Game level pass~'); App_1.App.Facade.popView(TipPanelMediator_1.default, TipPanel_1.default, "Game level pass~", false); return; } else { cc.find("Canvas/ChooseLevelPanel/nodeLevel").getComponent(NodeLevel_1.default).freshLevelNum(this.level); // console.log("aaa---------------", cc.find("Canvas/ChooseLevelPanel/nodeLevel").name); } } else { console.log('Level not unlocked~'); App_1.App.Facade.popView(TipPanelMediator_1.default, TipPanel_1.default, "Level not unlocked~", false); return; } }; __decorate([ property(cc.Label) ], LevelItem.prototype, "label", void 0); __decorate([ property(cc.Node) ], LevelItem.prototype, "lock", void 0); __decorate([ property(cc.Node) ], LevelItem.prototype, "open", void 0); __decorate([ property(cc.Node) ], LevelItem.prototype, "pass", void 0); __decorate([ property([cc.Node]) ], LevelItem.prototype, "star", void 0); __decorate([ property(cc.Node) ], LevelItem.prototype, "key", void 0); LevelItem = __decorate([ ccclass ], LevelItem); return LevelItem; }(SuperListItem_1.default)); exports.default = LevelItem; cc._RF.pop();