123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166 |
- "use strict";
- cc._RF.push(module, '14234A5MHtMZKtdbmpz/EN8', 'NodeKitchen');
- // Script/view/chooseLevel/NodeKitchen.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 hallModel_1 = require("../../model/hallModel");
- var TipPanel_1 = require("../tipPanel/TipPanel");
- var TipPanelMediator_1 = require("../tipPanel/TipPanelMediator");
- var _a = cc._decorator, ccclass = _a.ccclass, property = _a.property;
- var NodeKitchen = /** @class */ (function (_super) {
- __extends(NodeKitchen, _super);
- function NodeKitchen() {
- var _this = _super !== null && _super.apply(this, arguments) || this;
- _this.labelExp = null;
- _this.btnList = [];
- _this.LabelCoinNum = [];
- _this.shengjiTishi = [];
- _this.kitchenSpriteFrame = [];
- _this.kitchenName = [];
- _this.selectSprite = null;
- _this.labelCurCount = null;
- _this.labelNextCount = null;
- _this.selectUpIndex = -1;
- _this.btnUpgrade = null;
- return _this;
- // update (dt) {}
- }
- NodeKitchen.prototype.onLoad = function () {
- for (var i = 0; i < 3; i++) {
- this.btnList[i] = this.node.getChildByName("btnKitchen" + i).getComponent(cc.Button);
- this.btnList[i].node.on("click", this.btnClickCallBack.bind(this, i), this);
- this.LabelCoinNum[i] = this.btnList[i].node.getChildByName("LabelCoinNum").getComponent(cc.Label);
- this.shengjiTishi[i] = this.btnList[i].node.getChildByName("tip_shenji");
- this.shengjiTishi[i].active = false;
- var level = App_1.App.DataManager.kinchenLevel[i];
- if (level < App_1.App.DataManager.maxKitchenLevel) {
- // 升级所需金币
- this.LabelCoinNum[i].string = App_1.App.DataManager.upgradeKitchenCoin[i][level] + "";
- if (App_1.App.DataManager.UserCoin > App_1.App.DataManager.upgradeKitchenCoin[i][level]) {
- // 提示可以升级
- this.shengjiTishi[i].active = true;
- }
- }
- else {
- this.btnList[i].interactable = false;
- this.LabelCoinNum[i].node.active = false;
- }
- }
- this.btnUpgrade.node.on("click", this.clickBtnUpgrade.bind(this), this);
- // this.kitchenName = ["盘子", "铁板", "饮料机"];
- this.kitchenName = ["plate", "hot plate", "juicer"];
- };
- NodeKitchen.prototype.start = function () {
- this.findUpGrade();
- };
- NodeKitchen.prototype.findUpGrade = function () {
- this.selectUpIndex = -1;
- for (var i = App_1.App.DataManager.kinchenLevel.length - 1; i >= 0; i--) {
- var KitchenCurLevel = App_1.App.DataManager.kinchenLevel[i];
- if (KitchenCurLevel == App_1.App.DataManager.maxKitchenLevel) {
- this.btnList[i].interactable = false;
- this.LabelCoinNum[i].node.active = false;
- }
- else {
- this.selectUpIndex = i;
- this.LabelCoinNum[i].string = App_1.App.DataManager.upgradeKitchenCoin[i][KitchenCurLevel] + "";
- }
- }
- console.log("aaa--------this.selectUpIndex----------", this.selectUpIndex);
- this.btnClickCallBack(this.selectUpIndex);
- };
- NodeKitchen.prototype.btnClickCallBack = function (index) {
- if (index < 0) {
- return;
- }
- this.selectUpIndex = index;
- this.labelExp.string = this.kitchenName[index];
- this.selectSprite.spriteFrame = this.kitchenSpriteFrame[index];
- var KitchenCurLevel = App_1.App.DataManager.kinchenLevel[index];
- this.labelCurCount.string = App_1.App.DataManager.kitchenNum[index][KitchenCurLevel] + "";
- this.labelNextCount.string = App_1.App.DataManager.kitchenNum[index][KitchenCurLevel + 1] + "";
- };
- NodeKitchen.prototype.clickBtnUpgrade = function () {
- if (this.selectUpIndex < 0) {
- App_1.App.Facade.popView(TipPanelMediator_1.default, TipPanel_1.default, "It's the highest level", false);
- return;
- }
- var KitchenCurLevel = App_1.App.DataManager.kinchenLevel[this.selectUpIndex];
- var upgradeCoin = App_1.App.DataManager.upgradeKitchenCoin[this.selectUpIndex][KitchenCurLevel];
- if (App_1.App.DataManager.UserCoin < upgradeCoin) {
- App_1.App.Facade.popView(TipPanelMediator_1.default, TipPanel_1.default, "Not enough gold coins", false);
- }
- else {
- App_1.App.DataManager.kinchenLevel[this.selectUpIndex]++;
- App_1.App.DataManager.UserCoin -= upgradeCoin;
- // 保存到本地
- App_1.App.LocalStorageUtil.setNumber(App_1.App.LocalStorageUtil.lst_Coin, App_1.App.DataManager.UserCoin);
- App_1.App.LocalStorageUtil.setJsonObj(App_1.App.LocalStorageUtil.list_kitchenLevel, App_1.App.DataManager.kinchenLevel);
- App_1.App.Facade.popView(TipPanelMediator_1.default, TipPanel_1.default, "update successfully", false);
- App_1.App.Facade.getModel(hallModel_1.default).updateCoinNumber();
- for (var i = 0; i < 3; i++) {
- var level = App_1.App.DataManager.kinchenLevel[i];
- this.shengjiTishi[i].active = false;
- if (level < App_1.App.DataManager.maxKitchenLevel) {
- // 升级所需金币
- this.LabelCoinNum[i].string = App_1.App.DataManager.upgradeKitchenCoin[i][level] + "";
- if (App_1.App.DataManager.UserCoin > App_1.App.DataManager.upgradeKitchenCoin[i][level]) {
- // 提示可以升级
- this.shengjiTishi[i].active = true;
- }
- }
- else {
- this.btnList[i].interactable = false;
- this.LabelCoinNum[i].node.active = false;
- }
- }
- this.findUpGrade();
- }
- };
- __decorate([
- property(cc.Label)
- ], NodeKitchen.prototype, "labelExp", void 0);
- __decorate([
- property([cc.SpriteFrame])
- ], NodeKitchen.prototype, "kitchenSpriteFrame", void 0);
- __decorate([
- property(cc.Sprite)
- ], NodeKitchen.prototype, "selectSprite", void 0);
- __decorate([
- property(cc.Label)
- ], NodeKitchen.prototype, "labelCurCount", void 0);
- __decorate([
- property(cc.Label)
- ], NodeKitchen.prototype, "labelNextCount", void 0);
- __decorate([
- property(cc.Button)
- ], NodeKitchen.prototype, "btnUpgrade", void 0);
- NodeKitchen = __decorate([
- ccclass
- ], NodeKitchen);
- return NodeKitchen;
- }(cc.Component));
- exports.default = NodeKitchen;
- cc._RF.pop();
|