SkillItem.js 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602
  1. const SkillApi = require('../net/SkillApi');
  2. const DWTool = require("../utils/DWTool");
  3. const GameModule = require("../utils/GameModule");
  4. const buildingLevel = require('../data/buildingLevel');
  5. const {GameNotificationKey, WechatShareType} = require('../utils/GameEnum');
  6. const WeChat = require('../net/WeChat');
  7. const TapTapTool = require("../utils/TapTapTool");
  8. const AlertManager = require('../utils/AlertManager');
  9. const ADVideo = require('../utils/ADVideo');
  10. const HomeApi = require('../net/HomeApi');
  11. // const GameRedDot = require('../utils/GameEnum').GameRedDot;
  12. // WeChat
  13. cc.Class({
  14. extends: cc.Component,
  15. properties: {
  16. userSkillButton: {
  17. tooltip: '使用技能button',
  18. default: null,
  19. type: cc.Button
  20. },
  21. titleRichText: {
  22. tooltip: 'title啦',
  23. default: null,
  24. type: cc.RichText
  25. },
  26. skillIconBg: {
  27. tooltip: '技能icon的背景',
  28. default: null,
  29. type: cc.Sprite
  30. },
  31. ///使用技能的按钮背景图片
  32. useSkillButtonBgSprite: cc.Sprite,
  33. /// 使用技能的text
  34. skillUseTitleRichText: cc.RichText,
  35. /// 描述text
  36. subTitleRichText: cc.RichText,
  37. ///技能icon
  38. skillIcon: cc.Sprite,
  39. ///总部大楼特有,等级 / 25
  40. fillBuldingNode: cc.Node,
  41. fillBuldingSprite: cc.Sprite,
  42. lightSpriteFrame: cc.SpriteFrame,
  43. graySpriteFrame: cc.SpriteFrame,
  44. /// 里程碑奖励显示的button
  45. awardButton: cc.Button,
  46. /// 升级技能的弹窗
  47. alertNode: cc.Node,
  48. ///砖石数
  49. diamondCount: 0,
  50. /// 金币数
  51. coinCount: 0,
  52. building: 0,
  53. _awardCount: 0,
  54. _isAlert: false,
  55. /// 0说明是用金币 1 说明是用分享 2 看广告
  56. _adState: 0,
  57. //// 当前使用的广告状态
  58. _useAdState: 0,
  59. _isInitAd: false
  60. },
  61. // onLoad () {
  62. // },
  63. start () {
  64. this._isAction = false;
  65. },
  66. onDestroy() {
  67. GameEvent.off("skill3_use_begain", this);
  68. GameEvent.off(GameNotificationKey.SkillThreeHasDone, this);
  69. GameEvent.off("skill_five_use", this);
  70. GameEvent.off(GameNotificationKey.UpBuildingLevel, this);
  71. GameEvent.off(GameNotificationKey.ShowShareAction, this);
  72. // GameEvent.off(GameNotificationKey.AdBuildingStateUpdate, this);
  73. },
  74. update (dt) {
  75. /// 如果说是建筑 并且没有处于响应
  76. if (this.fillBuldingNode.active && this._isAction === false) {
  77. let isCanUse = this.judgeIsCanUse();
  78. let isAd = DWTool.checkIsOldUser() && Global._upBuildingInfo.maxCount > Global._upBuildingInfo.count && Global._upBuildingInfo.cdTime <= 0;
  79. /// 如果有广告或者分享
  80. if (!this._isInitAd && isAd) {
  81. this._isInitAd = true;
  82. this.initBuildingAd();
  83. }
  84. if (isAd && !isCanUse) {
  85. if (this._useAdState != this.adState) {
  86. this._useAdState = this._adState;
  87. this.updateBuildingUsingUI();
  88. this.setupGrayBg(true);
  89. }
  90. } else {
  91. if (this._useAdState != 0) {
  92. this._useAdState = 0;
  93. this.updateBuildingUsingUI();
  94. }
  95. let inter = this.userSkillButton.interactable;
  96. if (isCanUse != inter) {
  97. this.setupGrayBg(!inter);
  98. }
  99. }
  100. }
  101. },
  102. /// 初始化第一个建筑相关的数据
  103. initBuilding(awardCount) {
  104. this.initAward(awardCount)
  105. this.userSkillButton.interactable = false;
  106. this.updateBuildingData();
  107. /// 第三个技能开始使用
  108. GameEvent.on("skill3_use_begain", this, () => {
  109. this.updateBuildingData();
  110. });
  111. /// 第三个技能结束
  112. GameEvent.on(GameNotificationKey.SkillThreeHasDone, this, () => {
  113. this.updateBuildingData();
  114. });
  115. ////第五个技能开始使用
  116. GameEvent.on("skill_five_use", this, () => {
  117. this.updateBuildingData();
  118. });
  119. // /// cd时间到了
  120. // GameEvent.on(GameNotificationKey.AdBuildingStateUpdate, this, () => {
  121. // this.initBuildingAd();
  122. // });
  123. GameEvent.on(GameNotificationKey.AdUpdateStateNotification, this, (adState, callBack) => {
  124. /// 说明是技能的关闭状态
  125. if (adState === 3 && callBack === 'skill') {
  126. this.finishAction();
  127. }
  128. if (adState === 0 || adState === 1) {
  129. this.initBuildingAd();
  130. }
  131. });
  132. GameModule.homeGuide.on('Fire_state16', this.awardBtnAction, this);
  133. // let buildingLevelInfo = buildingLevel[buildingInfo.buildingLevel - 1];
  134. },
  135. initBuildingAd() {
  136. if (!CC_WECHATGAME) {
  137. return;
  138. }
  139. //// 说明有广告
  140. if (Global._adVideoState == 0) {
  141. this._adState = 2;
  142. } else if (Global._adVideoState === 1) {
  143. this._adState = 1;
  144. }
  145. },
  146. finishAction() {
  147. HomeApi.reportInformation(1, () => {
  148. Global._upBuildingInfo.count += 1;
  149. /// 时间重置为5分钟
  150. Global._upBuildingInfo.cdTime = 5 * 60 * 1000;
  151. /// 恢复到正常的状态
  152. /// 如果已经达到当天最大的次数
  153. // if (Global._upBuildingInfo.maxCount <= Global._upBuildingInfo.count) {
  154. // if (this._video != undefined) {
  155. // /// 销毁这个对象
  156. // this._video = null;
  157. // }
  158. // return;
  159. // }
  160. /// 请求升级建筑
  161. this._adState = 0;
  162. this._useAdState = 0;
  163. this.requestUpBuildingLevel();
  164. }, (code, msg) => {
  165. console.log(msg);
  166. })
  167. },
  168. //// 初始化技能数据
  169. init(skillData) {
  170. this.fillBuldingNode.active = false;
  171. this.awardButton.node.active = false;
  172. this.loadSpriteFrame(skillData);
  173. this.skillData = skillData;
  174. this.updateData();
  175. this.setupMaxLevel();
  176. /// 更新技能相关
  177. GameEvent.on('skill_update', this, () => {
  178. this.updateData();
  179. this.setupMaxLevel();
  180. });
  181. },
  182. /// 初始化领取里程碑奖励数据
  183. initAward(awardCount) {
  184. this._awardCount = awardCount;
  185. let needAwardCount = parseInt(GameModule.userInfo.buildingLevel / 25);
  186. if (needAwardCount > this._awardCount) {
  187. this.awardButton.node.active = true;
  188. } else {
  189. this.awardButton.node.active = false;
  190. }
  191. },
  192. /// 更新建筑相关数据
  193. updateBuildingData() {
  194. let currentLevel = GameModule.userInfo.buildingLevel;
  195. let upGet = GameModule.userInfo.perpetualClickMt;
  196. this._upGet = upGet;
  197. if (currentLevel <= 25) {
  198. let buildingObj = buildingLevel.find(n => {
  199. return n.level == currentLevel;
  200. });
  201. this._upGold = {'n': buildingObj.upGold, 'e': 0};
  202. } else {
  203. let mul = TapTapTool.toPower(currentLevel - 26);
  204. this._upGold = TapTapTool.multiple({'n': 1056, 'e': 0}, mul);
  205. }
  206. this.updateBuildingUsingUI();
  207. // this.skillUseTitleRichText.string = '<color=#ffffff>+' + TapTapTool.parseToString(upGet) + '收益</c>' + `<br/><img src='coin_small'/><color=#ffffff>${TapTapTool.parseToString(this._upGold)}</c>`;
  208. this.fillBuldingNode.active = true;
  209. this.fillBuldingSprite.fillRange = (currentLevel % 25) / 25;
  210. this.diamondCount = 0;
  211. this.coinCount = this._upGold;
  212. this.building = 0;
  213. this.titleRichText.string = '<color=#df5400>等级' + currentLevel + '</c>' + '<color=#1c1c1c>' + ' 总部大楼' + '</c>';
  214. this.subTitleRichText.string = `<img src='skill_click_coin'/><color=#df5400> ${TapTapTool.parseToString(GameModule.userInfo.coinTap)}收益</c><color=#1c1c1c>/点击</c>`;
  215. },
  216. /// 根据视频 分享 升级更新使用的UI
  217. updateBuildingUsingUI() {
  218. /// 如果是直接使用金币
  219. if (this._useAdState === 0) {
  220. this.skillUseTitleRichText.string = '<color=#ffffff>+' + TapTapTool.parseToString(this._upGet) + '收益</c>' + `<br/><img src='coin_small'/><color=#ffffff>${TapTapTool.parseToString(this._upGold)}</c>`;
  221. /// 如果是分享
  222. } else if (this._useAdState === 1) {
  223. this.skillUseTitleRichText.string = '<color=#ffffff> 分享\n免费升级' + '</c>';
  224. } else {
  225. this.skillUseTitleRichText.string = '<color=#ffffff> 看视频\n免费升级' + '</c>';
  226. }
  227. },
  228. /// 更新技能相关数据
  229. updateData() {
  230. let levelInfo = Global.BuildingManager.getSkillLevelInfo(this.skillData.skillId, this.skillData.skillLevel);
  231. let skillInfo = Global.BuildingManager.getSkillInfo(this.skillData.skillId);
  232. this._skillInfo = skillInfo;
  233. //// 如果是没有拥有的
  234. if (this.skillData.isHave == 0) {
  235. /// 说明是用其它的来解锁
  236. if (skillInfo.buildingLevel == 0) {
  237. /// 用的砖石 技能4是用砖石或者金币来解锁的
  238. this.showBuySkill();
  239. } else {
  240. /// 说明总部等级不够,还没有解锁
  241. if (GameModule.userInfo.buildingLevel < skillInfo.buildingLevel) {
  242. this.coinCount = {'n': 0, 'e': 0};
  243. this.diamondCount = 0;
  244. this.building = skillInfo.buildingLevel;
  245. this.skillUseTitleRichText.string = "<img src='skill_lock'/><br/><color=#ffffff>总部大楼等级" + skillInfo.buildingLevel + '</c>';
  246. //// 如果是因为建筑锁住的
  247. this._upNoticefacation = false;
  248. GameEvent.on(GameNotificationKey.UpBuildingLevel, this, () => {
  249. if (!this._upNoticefacation && GameModule.userInfo.buildingLevel >= this.building && this.skillData.isHave == 0) {
  250. /// 实时技能直接拥有
  251. this._upNoticefacation = true;
  252. if (this.skillData.skillId < 4) {
  253. /// 直接解锁它
  254. this.unlockedSkill();
  255. } else {
  256. this.showBuySkill();
  257. this.setupGrayBg(this.judgeIsCanUse());
  258. }
  259. }
  260. });
  261. /// 那就需要去购买了
  262. } else {
  263. this.showBuySkill();
  264. }
  265. }
  266. } else {
  267. this.userSkillButton.interactable = true;
  268. let diamondCount = levelInfo.bonus[10002];
  269. /// 用的砖石
  270. if (diamondCount != undefined) {
  271. this.diamondCount = diamondCount;
  272. this.coinCount = {'n': 0, 'e': 0};
  273. this.building = 0;
  274. this.skillUseTitleRichText.string = `<color=#ffffff>升级</c><br/><img src='skill_diamond'/><color=#ffffff>${diamondCount}钻石</c>`;
  275. }
  276. }
  277. this.setupGrayBg(this.judgeIsCanUse());
  278. if (this.skillData.skillLevel > 0) {
  279. this.titleRichText.string = '<color=#df5400>等级' + + this.skillData.skillLevel + ' </c>' + '<color=#1c1c1c>' + skillInfo.name + '</c>';
  280. } else {
  281. this.titleRichText.string = '<color=#df5400>技能' + ' </c>' + '<color=#1c1c1c>' + skillInfo.name + '</c>';
  282. }
  283. if (levelInfo == undefined) {
  284. this.subTitleRichText.string = '<color=#1c1c1c>' + skillInfo.desc + '</c>';
  285. } else {
  286. this.subTitleRichText.string = '<color=#1c1c1c>' + levelInfo.desc + '</c>';
  287. }
  288. },
  289. /// 设置使用技能的背景
  290. setupGrayBg(isActive) {
  291. this.userSkillButton.interactable = isActive;
  292. this.useSkillButtonBgSprite.spriteFrame = isActive ? this.lightSpriteFrame : this.graySpriteFrame;
  293. },
  294. //// 设置技能达到最大值的时候
  295. setupMaxLevel() {
  296. if (this.skillData.skillLevel >= this.skillData.maxLevel) {
  297. this.userSkillButton.interactable = false;
  298. this.skillUseTitleRichText.node.active = false;
  299. DWTool.loadResSpriteFrame('./textures/skill/skill_max')
  300. .then((spriteFrame) => {
  301. this.useSkillButtonBgSprite.spriteFrame = spriteFrame;
  302. });
  303. }
  304. },
  305. /// 加载技能icon图片
  306. loadSpriteFrame(skillData) {
  307. if (skillData.skillId <= 3) {
  308. let bgPath = './textures/skill/400' + skillData.skillId + skillData.skillId;
  309. DWTool.loadResSpriteFrame(bgPath)
  310. .then((spriteFrame) => {
  311. this.skillIconBg.spriteFrame = spriteFrame;
  312. });
  313. }
  314. let iconPath = './textures/skill/4000' + skillData.skillId;
  315. DWTool.loadResSpriteFrame(iconPath)
  316. .then((spriteFrame) => {
  317. this.skillIcon.spriteFrame = spriteFrame;
  318. });
  319. },
  320. ///////////// ******* 网络请求 ****** //////
  321. //// 购买技能
  322. buySkill(skillId) {
  323. return new Promise((resolve, reject) => {
  324. // 获取目标用户的建筑
  325. SkillApi.buySkill(skillId, (respondData) => {
  326. resolve(respondData);
  327. }, (code, msg) => {
  328. reject({code, msg});
  329. });
  330. });
  331. },
  332. /// 升级建筑
  333. upBuildingLevel(upLevel) {
  334. return new Promise((resolve, reject) => {
  335. // 获取目标用户的建筑
  336. SkillApi.upBuildingLevel(upLevel, (respondData) => {
  337. resolve(respondData);
  338. }, (code, msg) => {
  339. reject({code, msg});
  340. });
  341. });
  342. },
  343. /// 上报里程碑奖励
  344. report() {
  345. return new Promise((resolve, reject) => {
  346. // 获取目标用户的建筑
  347. SkillApi.report(3, (respondData) => {
  348. resolve(respondData);
  349. }, (code, msg) => {
  350. reject({code, msg});
  351. });
  352. });
  353. },
  354. ///////////******* 技能升级购买相关 *********/////////////////////////
  355. //// 购买或者升级技能
  356. useSkillButtonAction() {
  357. GameModule.audioMng.playClickButton();
  358. this.userSkillButton.interactable = false;
  359. this._isAction = true;
  360. /// 如果是升级建筑
  361. if (this.fillBuldingNode.active) {
  362. this.upBuildingLevelAction();
  363. } else {
  364. this.skillAction();
  365. }
  366. },
  367. upBuildingLevelAction() {
  368. if (CC_WECHATGAME) {
  369. if (this._useAdState == 0) {
  370. this.requestUpBuildingLevel();
  371. /// 说明是分享
  372. } else if (this._useAdState == 1) {
  373. GameEvent.on(GameNotificationKey.ShowShareAction, this, (type, isOk) => {
  374. if (type == WechatShareType.UpBuilding) {
  375. if (isOk) {
  376. this.finishAction();
  377. } else {
  378. this.userSkillButton.interactable = true;
  379. this._isAction = false;
  380. }
  381. GameEvent.off(GameNotificationKey.ShowShareAction, this);
  382. }
  383. });
  384. WeChat.shareAction(WechatShareType.UpBuilding, () => {
  385. }, () => {
  386. this.userSkillButton.interactable = true;
  387. this._isAction = false;
  388. console.log('分享失败或取消');
  389. });
  390. /// 如果是看视频
  391. } else {
  392. this.userSkillButton.interactable = true;
  393. this._isAction = false;
  394. Global._adVideo.showVideo('skill');
  395. }
  396. } else {
  397. this.requestUpBuildingLevel();
  398. }
  399. },
  400. requestUpBuildingLevel() {
  401. this.upBuildingLevel(1).then((respondData) => {
  402. this.userSkillButton.interactable = true;
  403. this._isAction = false;
  404. // Global.userData.buildingLevel = respondData.level;
  405. GameModule.userInfo.buildingLevel = respondData.level;
  406. GameModule.userInfo.gold = TapTapTool.sub(GameModule.userInfo.gold, this._upGold);
  407. this.initAward(this._awardCount);
  408. GameEvent.fire(GameNotificationKey.UpBuildingLevel);
  409. Global._gold10 = respondData.gold10;
  410. this.updateBuildingData();
  411. if (GameModule.userInfo.buildingLevel > 5 && this._useAdState === 0) {
  412. this.showSkillBuidingAlert(respondData.gold10, respondData.gold100);
  413. }
  414. }).catch(({code, msg}) => {
  415. Global.commonAlert.showCommonErrorAlert(msg);
  416. console.log(code, msg);
  417. this._isAction = false;
  418. this.userSkillButton.interactable = true;
  419. });
  420. },
  421. ///点击按钮之后 技能相关的响应
  422. skillAction() {
  423. /// 那就是解锁啦
  424. let skillId = this.skillData.skillId;
  425. /// 说明是购买技能
  426. if (this.skillData.isHave == 0 && skillId > 3) {
  427. /// 购买成功
  428. this.buySkill(skillId).then(() => {
  429. this.updateGloabData();
  430. this.buyFixSkill();
  431. GameEvent.fire('skill_update');
  432. this.userSkillButton.interactable = true;
  433. console.log("技能购买成功");
  434. }).catch(({code, msg}) => {
  435. console.log(code, msg);
  436. Global.commonAlert.showCommonErrorAlert(msg);
  437. this.userSkillButton.interactable = true;
  438. });
  439. /// 升级技能
  440. } else {
  441. let levelInfo = Global.BuildingManager.getSkillLevelInfo(this.skillData.skillId, this.skillData.skillLevel);
  442. levelInfo.name = this._skillInfo.name;
  443. let nextInfo = Global.BuildingManager.getSkillLevelInfo(this.skillData.skillId, this.skillData.skillLevel + 1);
  444. nextInfo.name = this._skillInfo.name;
  445. AlertManager.showSkillBuyAlert(levelInfo, nextInfo, this);
  446. this.userSkillButton.interactable = true;
  447. }
  448. },
  449. //// 购买永久技能
  450. buyFixSkill() {
  451. this.skillData.skillLevel = 1;
  452. this.skillData.isHave = 1;
  453. let skillId = this.skillData.skillId;
  454. /// 如果升级永久技能
  455. let skillLevelInfo = Global.BuildingManager.getSkillLevelInfo(skillId, this.skillData.skillLevel);
  456. GameEvent.fire(GameNotificationKey.UpdateFixationSkill, skillLevelInfo);
  457. if (skillId == 5) {
  458. GameEvent.fire("skill_five_use");
  459. } else if (skillId == 6) {
  460. Global.rcdSkillLevel = 1;
  461. GameEvent.fire("skill_six_use");
  462. }
  463. let iconPath = './textures/skill/4000' + skillId;
  464. AlertManager.showCommonAlert(iconPath, this._skillInfo.desc, this._skillInfo.name);
  465. },
  466. /// 显示购买技能
  467. showBuySkill() {
  468. // let levelInfo = Global.BuildingManager.getSkillLevelInfo(this.skillData.skillId, 1);
  469. /// 使用金币升级
  470. let diamondCount = this._skillInfo.bonus[10002];
  471. /// 用的砖石
  472. if (diamondCount != undefined) {
  473. this.diamondCount = diamondCount;
  474. this.coinCount = {'n': 0, 'e': 0};
  475. this.building = 0;
  476. this.skillUseTitleRichText.string = `<color=#ffffff>购买</c><br/><img src='skill_diamond'/><color=#ffffff>${diamondCount}钻石</c>`;
  477. }
  478. },
  479. /// 每次升级需要弹窗
  480. showSkillBuidingAlert (gold10, gold100) {
  481. this.unschedule(this.hideBuildingAlert, this);
  482. this.scheduleOnce(this.hideBuildingAlert, 2);
  483. this.alertNode.getComponent('SkillBuildingAlert').updateData(gold10, gold100, this);
  484. this.alertNode.active = true;
  485. },
  486. hideBuildingAlert () {
  487. this.alertNode.active = false;
  488. },
  489. hiddenSkillBuidingAlert(gold10, gold100) {
  490. this.initAward(this._awardCount);
  491. this.updateBuildingData();
  492. this.showSkillBuidingAlert(gold10, gold100);
  493. },
  494. /// 解锁某一个技能
  495. unlockedSkill() {
  496. let skillId = this.skillData.skillId;
  497. this.skillData.isHave = 1;
  498. this.skillData.skillLevel = 1;
  499. this.updateData()
  500. if (skillId <= 3) {
  501. GameEvent.fire("TopSkill_unLocked", skillId);
  502. }
  503. console.log("解锁技能成功");
  504. },
  505. //// 里程碑奖励action
  506. awardBtnAction() {
  507. this.awardButton.interactable = false;
  508. GameModule.audioMng.playClickButton();
  509. this.report().then((respondData) => {
  510. this.awardButton.interactable = true;
  511. this._awardCount = respondData.awardCount;
  512. let needAwardCount = parseInt(GameModule.userInfo.buildingLevel / 25);
  513. this.awardButton.node.active = needAwardCount > this._awardCount;
  514. GameModule.userInfo.perpetualClickMt = TapTapTool.multiple(GameModule.userInfo.perpetualClickMt, {'e': 0, 'n': 2});
  515. GameEvent.fire(GameNotificationKey.UpBuildingLevel);
  516. GameEvent.fire(GameNotificationKey.GameShowAdditionTips,"总部大楼",0);
  517. this.updateBuildingData();
  518. let objct = {'cdTime': -6 * 1000, 'infoDesc': '点击提升2倍的金币产出', 'icon': 900001};
  519. Global._fixInformations.push(objct);
  520. GameEvent.fire(GameNotificationKey.GameUpdateMessageList, 1, false);
  521. console.log("领取里程碑奖励成功");
  522. }).catch(({code, msg}) => {
  523. console.log(code, msg);
  524. this.awardButton.interactable = true;
  525. });
  526. },
  527. /// 判断本地是否是解锁状态
  528. judgeIsCanUse() {
  529. if (this.coinCount.n > 0 && TapTapTool.compare(GameModule.userInfo.gold, this.coinCount)) {
  530. return true;
  531. } else if (this.diamondCount > 0 && GameModule.userInfo.diamond >= this.diamondCount) {
  532. return true;
  533. } else if (this.building > 0 && GameModule.userInfo.buildingLevel >= this.building) {
  534. return true;
  535. } else {
  536. return false;
  537. }
  538. },
  539. ///更新全局数据
  540. updateGloabData() {
  541. if (this.coinCount.n > 0) {
  542. GameModule.userInfo.gold = TapTapTool.sub(GameModule.userInfo.gold, this.coinCount);
  543. } else if (this.diamondCount > 0) {
  544. GameModule.userInfo.diamond -= this.diamondCount;
  545. }
  546. },
  547. });