123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596 |
- const SkillApi = require('../net/SkillApi');
- const GameNotificationKey = require('../utils/GameEnum').GameNotificationKey;
- const GameModule = require("../utils/GameModule");
- 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 = Global.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) {
- Global.rcdSkillLevel += 1;
- GameEvent.fire("skill_six_use");
- }
- }
- this.node.destroy();
- console.log("升级技能成功");
- }).catch(({code, msg}) => {
- console.log(code, msg);
- Global.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) {},
- });
|