12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697 |
- const SkillApi = require('../net/SkillApi');
- const GameNotificationKey = require('../utils/GameEnum').GameNotificationKey;
- const GameModule = require("../utils/GameModule");
- var Promise = require('../lib/es6-promise').Promise;
- cc.Class({
- extends: cc.Component,
- properties: {
- skillNameRichText: cc.RichText,
- // 262424
- desc1RichText: cc.RichText,
- // #FD4700
- desc2RichText: cc.RichText,
- buyButton: cc.Button,
- buySprite: cc.Sprite,
- buyRichText: cc.RichText,
- },
- // LIFE-CYCLE CALLBACKS:
- // onLoad () {},
- /// 上一级和下一级的技能信息
- init(skillInfo, nextSkillInfo, starItem) {
- this._skillId = skillInfo.skillId;
- this._starItem = starItem;
- let diamondCount = skillInfo.bonus[10002];
- /// 用的砖石
- if (diamondCount != undefined) {
- this.diamondCount = diamondCount;
- this.coinCount = {'n': 0, 'e': 0};
- this.building = 0;
- this.buyRichText.string = `<color=#ffffff>升级</c><br/><img src='skill_diamond'/><color=#ffffff>${diamondCount}钻石</c>`;
- }
- this.desc1RichText.string = `<color=#262424>立即获得\n${skillInfo.desc}</c>`;
- this.desc2RichText.string = `<color=#FD4700>立即获得\n${nextSkillInfo.desc}</c>`;
- this.skillNameRichText.string = `<b><color=#540904>${skillInfo.name}</c></b>`;
- },
- start () {
- },
- buyAction() {
- this.buyButton.interactable = false;
- GameModule.audioMng.playClickButton();
- this.upSkill(this._skillId).then(() => {
- this.buyButton.interactable = true;
- this._starItem.skillData.skillLevel += 1;
- this._starItem.updateGloabData();
- GameEvent.fire('skill_update');
- let skillLevelInfo = GameGlobal.BuildingManager.getSkillLevelInfo(this._skillId, this._starItem.skillData.skillLevel);
- if (this._skillId <= 3) {
- GameEvent.fire(GameNotificationKey.UpdateTimeSkill, skillLevelInfo);
- } else {
- /// 如果升级永久技能
- GameEvent.fire(GameNotificationKey.UpdateFixationSkill, skillLevelInfo);
- if (this._skillId == 5) {
- GameEvent.fire("skill_five_use");
- /// 使用最后一个减cd的
- } else if (this._skillId == 6) {
- GameGlobal.rcdSkillLevel += 1;
- GameEvent.fire("skill_six_use");
- }
- }
- this.node.destroy();
- console.log("升级技能成功");
- }).catch(({code, msg}) => {
- console.log(code, msg);
- GameGlobal.commonAlert.showCommonErrorAlert(msg);
- this.buyButton.interactable = true;
- });
- },
- closeAction() {
- GameModule.audioMng.playClickButton();
- this.node.destroy();
- },
- upSkill(skillId) {
- return new Promise((resolve, reject) => {
- // 获取目标用户的建筑
- SkillApi.upSkill(skillId, (respondData) => {
- resolve(respondData);
- }, (code, msg) => {
- reject({code, msg});
- });
- });
- },
- // update (dt) {},
- });
|