14234039-307b-4c64-ab5d-6e6a73fc437c.js 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  1. "use strict";
  2. cc._RF.push(module, '14234A5MHtMZKtdbmpz/EN8', 'NodeKitchen');
  3. // Script/view/chooseLevel/NodeKitchen.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 hallModel_1 = require("../../model/hallModel");
  27. var TipPanel_1 = require("../tipPanel/TipPanel");
  28. var TipPanelMediator_1 = require("../tipPanel/TipPanelMediator");
  29. var _a = cc._decorator, ccclass = _a.ccclass, property = _a.property;
  30. var NodeKitchen = /** @class */ (function (_super) {
  31. __extends(NodeKitchen, _super);
  32. function NodeKitchen() {
  33. var _this = _super !== null && _super.apply(this, arguments) || this;
  34. _this.labelExp = null;
  35. _this.btnList = [];
  36. _this.LabelCoinNum = [];
  37. _this.shengjiTishi = [];
  38. _this.kitchenSpriteFrame = [];
  39. _this.kitchenName = [];
  40. _this.selectSprite = null;
  41. _this.labelCurCount = null;
  42. _this.labelNextCount = null;
  43. _this.selectUpIndex = -1;
  44. _this.btnUpgrade = null;
  45. return _this;
  46. // update (dt) {}
  47. }
  48. NodeKitchen.prototype.onLoad = function () {
  49. for (var i = 0; i < 3; i++) {
  50. this.btnList[i] = this.node.getChildByName("btnKitchen" + i).getComponent(cc.Button);
  51. this.btnList[i].node.on("click", this.btnClickCallBack.bind(this, i), this);
  52. this.LabelCoinNum[i] = this.btnList[i].node.getChildByName("LabelCoinNum").getComponent(cc.Label);
  53. this.shengjiTishi[i] = this.btnList[i].node.getChildByName("tip_shenji");
  54. this.shengjiTishi[i].active = false;
  55. var level = App_1.App.DataManager.kinchenLevel[i];
  56. if (level < App_1.App.DataManager.maxKitchenLevel) {
  57. // 升级所需金币
  58. this.LabelCoinNum[i].string = App_1.App.DataManager.upgradeKitchenCoin[i][level] + "";
  59. if (App_1.App.DataManager.UserCoin > App_1.App.DataManager.upgradeKitchenCoin[i][level]) {
  60. // 提示可以升级
  61. this.shengjiTishi[i].active = true;
  62. }
  63. }
  64. else {
  65. this.btnList[i].interactable = false;
  66. this.LabelCoinNum[i].node.active = false;
  67. }
  68. }
  69. this.btnUpgrade.node.on("click", this.clickBtnUpgrade.bind(this), this);
  70. // this.kitchenName = ["盘子", "铁板", "饮料机"];
  71. this.kitchenName = ["plate", "hot plate", "juicer"];
  72. };
  73. NodeKitchen.prototype.start = function () {
  74. this.findUpGrade();
  75. };
  76. NodeKitchen.prototype.findUpGrade = function () {
  77. this.selectUpIndex = -1;
  78. for (var i = App_1.App.DataManager.kinchenLevel.length - 1; i >= 0; i--) {
  79. var KitchenCurLevel = App_1.App.DataManager.kinchenLevel[i];
  80. if (KitchenCurLevel == App_1.App.DataManager.maxKitchenLevel) {
  81. this.btnList[i].interactable = false;
  82. this.LabelCoinNum[i].node.active = false;
  83. }
  84. else {
  85. this.selectUpIndex = i;
  86. this.LabelCoinNum[i].string = App_1.App.DataManager.upgradeKitchenCoin[i][KitchenCurLevel] + "";
  87. }
  88. }
  89. console.log("aaa--------this.selectUpIndex----------", this.selectUpIndex);
  90. this.btnClickCallBack(this.selectUpIndex);
  91. };
  92. NodeKitchen.prototype.btnClickCallBack = function (index) {
  93. if (index < 0) {
  94. return;
  95. }
  96. this.selectUpIndex = index;
  97. this.labelExp.string = this.kitchenName[index];
  98. this.selectSprite.spriteFrame = this.kitchenSpriteFrame[index];
  99. var KitchenCurLevel = App_1.App.DataManager.kinchenLevel[index];
  100. this.labelCurCount.string = App_1.App.DataManager.kitchenNum[index][KitchenCurLevel] + "";
  101. this.labelNextCount.string = App_1.App.DataManager.kitchenNum[index][KitchenCurLevel + 1] + "";
  102. };
  103. NodeKitchen.prototype.clickBtnUpgrade = function () {
  104. if (this.selectUpIndex < 0) {
  105. App_1.App.Facade.popView(TipPanelMediator_1.default, TipPanel_1.default, "It's the highest level", false);
  106. return;
  107. }
  108. var KitchenCurLevel = App_1.App.DataManager.kinchenLevel[this.selectUpIndex];
  109. var upgradeCoin = App_1.App.DataManager.upgradeKitchenCoin[this.selectUpIndex][KitchenCurLevel];
  110. if (App_1.App.DataManager.UserCoin < upgradeCoin) {
  111. App_1.App.Facade.popView(TipPanelMediator_1.default, TipPanel_1.default, "Not enough gold coins", false);
  112. }
  113. else {
  114. App_1.App.DataManager.kinchenLevel[this.selectUpIndex]++;
  115. App_1.App.DataManager.UserCoin -= upgradeCoin;
  116. // 保存到本地
  117. App_1.App.LocalStorageUtil.setNumber(App_1.App.LocalStorageUtil.lst_Coin, App_1.App.DataManager.UserCoin);
  118. App_1.App.LocalStorageUtil.setJsonObj(App_1.App.LocalStorageUtil.list_kitchenLevel, App_1.App.DataManager.kinchenLevel);
  119. App_1.App.Facade.popView(TipPanelMediator_1.default, TipPanel_1.default, "update successfully", false);
  120. App_1.App.Facade.getModel(hallModel_1.default).updateCoinNumber();
  121. for (var i = 0; i < 3; i++) {
  122. var level = App_1.App.DataManager.kinchenLevel[i];
  123. this.shengjiTishi[i].active = false;
  124. if (level < App_1.App.DataManager.maxKitchenLevel) {
  125. // 升级所需金币
  126. this.LabelCoinNum[i].string = App_1.App.DataManager.upgradeKitchenCoin[i][level] + "";
  127. if (App_1.App.DataManager.UserCoin > App_1.App.DataManager.upgradeKitchenCoin[i][level]) {
  128. // 提示可以升级
  129. this.shengjiTishi[i].active = true;
  130. }
  131. }
  132. else {
  133. this.btnList[i].interactable = false;
  134. this.LabelCoinNum[i].node.active = false;
  135. }
  136. }
  137. this.findUpGrade();
  138. }
  139. };
  140. __decorate([
  141. property(cc.Label)
  142. ], NodeKitchen.prototype, "labelExp", void 0);
  143. __decorate([
  144. property([cc.SpriteFrame])
  145. ], NodeKitchen.prototype, "kitchenSpriteFrame", void 0);
  146. __decorate([
  147. property(cc.Sprite)
  148. ], NodeKitchen.prototype, "selectSprite", void 0);
  149. __decorate([
  150. property(cc.Label)
  151. ], NodeKitchen.prototype, "labelCurCount", void 0);
  152. __decorate([
  153. property(cc.Label)
  154. ], NodeKitchen.prototype, "labelNextCount", void 0);
  155. __decorate([
  156. property(cc.Button)
  157. ], NodeKitchen.prototype, "btnUpgrade", void 0);
  158. NodeKitchen = __decorate([
  159. ccclass
  160. ], NodeKitchen);
  161. return NodeKitchen;
  162. }(cc.Component));
  163. exports.default = NodeKitchen;
  164. cc._RF.pop();