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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  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. };
  72. NodeKitchen.prototype.start = function () {
  73. this.findUpGrade();
  74. };
  75. NodeKitchen.prototype.findUpGrade = function () {
  76. this.selectUpIndex = -1;
  77. for (var i = App_1.App.DataManager.kinchenLevel.length - 1; i >= 0; i--) {
  78. var KitchenCurLevel = App_1.App.DataManager.kinchenLevel[i];
  79. if (KitchenCurLevel == App_1.App.DataManager.maxKitchenLevel) {
  80. this.btnList[i].interactable = false;
  81. this.LabelCoinNum[i].node.active = false;
  82. }
  83. else {
  84. this.selectUpIndex = i;
  85. this.LabelCoinNum[i].string = App_1.App.DataManager.upgradeKitchenCoin[i][KitchenCurLevel] + "";
  86. }
  87. }
  88. console.log("aaa--------this.selectUpIndex----------", this.selectUpIndex);
  89. this.btnClickCallBack(this.selectUpIndex);
  90. };
  91. NodeKitchen.prototype.btnClickCallBack = function (index) {
  92. if (index < 0) {
  93. return;
  94. }
  95. this.selectUpIndex = index;
  96. this.labelExp.string = this.kitchenName[index];
  97. this.selectSprite.spriteFrame = this.kitchenSpriteFrame[index];
  98. var KitchenCurLevel = App_1.App.DataManager.kinchenLevel[index];
  99. this.labelCurCount.string = App_1.App.DataManager.kitchenNum[index][KitchenCurLevel] + "";
  100. this.labelNextCount.string = App_1.App.DataManager.kitchenNum[index][KitchenCurLevel + 1] + "";
  101. };
  102. NodeKitchen.prototype.clickBtnUpgrade = function () {
  103. if (this.selectUpIndex < 0) {
  104. App_1.App.Facade.popView(TipPanelMediator_1.default, TipPanel_1.default, "已经是最高级了", false);
  105. return;
  106. }
  107. var KitchenCurLevel = App_1.App.DataManager.kinchenLevel[this.selectUpIndex];
  108. var upgradeCoin = App_1.App.DataManager.upgradeKitchenCoin[this.selectUpIndex][KitchenCurLevel];
  109. if (App_1.App.DataManager.UserCoin < upgradeCoin) {
  110. App_1.App.Facade.popView(TipPanelMediator_1.default, TipPanel_1.default, "金币不足", false);
  111. }
  112. else {
  113. App_1.App.DataManager.kinchenLevel[this.selectUpIndex]++;
  114. App_1.App.DataManager.UserCoin -= upgradeCoin;
  115. // 保存到本地
  116. App_1.App.LocalStorageUtil.setNumber(App_1.App.LocalStorageUtil.lst_Coin, App_1.App.DataManager.UserCoin);
  117. App_1.App.LocalStorageUtil.setJsonObj(App_1.App.LocalStorageUtil.list_kitchenLevel, App_1.App.DataManager.kinchenLevel);
  118. App_1.App.Facade.popView(TipPanelMediator_1.default, TipPanel_1.default, "升级成功", false);
  119. App_1.App.Facade.getModel(hallModel_1.default).updateCoinNumber();
  120. for (var i = 0; i < 3; i++) {
  121. var level = App_1.App.DataManager.kinchenLevel[i];
  122. this.shengjiTishi[i].active = false;
  123. if (level < App_1.App.DataManager.maxKitchenLevel) {
  124. // 升级所需金币
  125. this.LabelCoinNum[i].string = App_1.App.DataManager.upgradeKitchenCoin[i][level] + "";
  126. if (App_1.App.DataManager.UserCoin > App_1.App.DataManager.upgradeKitchenCoin[i][level]) {
  127. // 提示可以升级
  128. this.shengjiTishi[i].active = true;
  129. }
  130. }
  131. else {
  132. this.btnList[i].interactable = false;
  133. this.LabelCoinNum[i].node.active = false;
  134. }
  135. }
  136. this.findUpGrade();
  137. }
  138. };
  139. __decorate([
  140. property(cc.Label)
  141. ], NodeKitchen.prototype, "labelExp", void 0);
  142. __decorate([
  143. property([cc.SpriteFrame])
  144. ], NodeKitchen.prototype, "kitchenSpriteFrame", void 0);
  145. __decorate([
  146. property(cc.Sprite)
  147. ], NodeKitchen.prototype, "selectSprite", void 0);
  148. __decorate([
  149. property(cc.Label)
  150. ], NodeKitchen.prototype, "labelCurCount", void 0);
  151. __decorate([
  152. property(cc.Label)
  153. ], NodeKitchen.prototype, "labelNextCount", void 0);
  154. __decorate([
  155. property(cc.Button)
  156. ], NodeKitchen.prototype, "btnUpgrade", void 0);
  157. NodeKitchen = __decorate([
  158. ccclass
  159. ], NodeKitchen);
  160. return NodeKitchen;
  161. }(cc.Component));
  162. exports.default = NodeKitchen;
  163. cc._RF.pop();