105 lines
3.3 KiB
JavaScript
105 lines
3.3 KiB
JavaScript
import GameModel from "../ts/core/GameModel";
|
|
import MsgAlert from "../ts/game/msg/MsgAlert";
|
|
import SkillUtil from "../ts/game/skill/core/SkillUtil";
|
|
import Report from "../ts/gear_2.3.4/net/Report";
|
|
|
|
cc.Class({
|
|
extends: cc.Component,
|
|
|
|
properties: {
|
|
typeNodes: [cc.Sprite],
|
|
skillNodes: [cc.Node],
|
|
nameLab: cc.Label,
|
|
expLab: cc.Label,
|
|
blueLab: cc.Label,
|
|
faLab: cc.Label,
|
|
infoLab: cc.Label,
|
|
nextLab: cc.Label,
|
|
consumeLab: cc.Label,
|
|
typeTxtAtlas: cc.SpriteAtlas,
|
|
addLongSkill: false
|
|
},
|
|
|
|
onLoad() {
|
|
this.curItemLogic = null;
|
|
this.loadGameData();
|
|
},
|
|
|
|
loadGameData() {
|
|
let skillList = GameModel.player.gameData.skill ? JSON.parse(GameModel.player.gameData.skill) : {};
|
|
let roleindex = (GameModel.player.race - 1) * 2 + GameModel.player.sex - 1;
|
|
let curids = SkillUtil.getRoleSkillIds(roleindex);
|
|
let curtypes = SkillUtil.getRoleESkillTypes(roleindex);
|
|
for (let index = 0; index < curtypes.length; index++) {
|
|
this.typeNodes[index].spriteFrame = this.typeTxtAtlas.getSpriteFrame(`skill_type_${curtypes[index]}`);
|
|
}
|
|
var isLong = curids.length == 7;
|
|
if (isLong) {
|
|
cc.find("ui_common_skill_titleLong", this.node).active = true;
|
|
cc.find("ui_common_skill_title1", this.node).y = 46;
|
|
cc.find("ui_common_skill_title2", this.node).y = -62;
|
|
var skill0 = cc.find("RoleSkillItemLong", this.node);
|
|
skill0.active = true;
|
|
if (!this.addLongSkill) {
|
|
this.skillNodes.unshift(skill0);
|
|
this.addLongSkill = true
|
|
}
|
|
this.skillNodes[1].y = 46;
|
|
this.skillNodes[2].y = 46;
|
|
this.skillNodes[3].y = -62;
|
|
this.skillNodes[4].y = -62;
|
|
}
|
|
|
|
|
|
for (let index = 0; index < curids.length; index++) {
|
|
let node = this.skillNodes[index];
|
|
let item = node.getComponent('RoleSkillItem');
|
|
item.loadInfo(curids[index], skillList[curids[index]]);
|
|
let btn = this.skillNodes[index].getComponent(cc.Button);
|
|
var clickEventHandler = new cc.Component.EventHandler();
|
|
clickEventHandler.target = this.node;
|
|
clickEventHandler.component = "RoleSkillPanel";
|
|
clickEventHandler.handler = "skillItemClicked";
|
|
btn.clickEvents.push(clickEventHandler);
|
|
}
|
|
if (this.curItemLogic == null) {
|
|
this.curItemLogic = this.skillNodes[0].getComponent('RoleSkillItem');
|
|
this.curItemLogic.selected();
|
|
}
|
|
this.showSkillInfo();
|
|
},
|
|
|
|
showSkillInfo() {
|
|
let skill = this.curItemLogic.skillLogic;
|
|
this.expLab.string = '【熟練度】' + skill.curExp + '/' + skill.maxExp;
|
|
this.blueLab.string = '【耗法值】' + skill.getCostMP();
|
|
this.faLab.string = '【法術系】' + skill.getFaxiName();
|
|
this.nameLab.string = skill.getName();
|
|
this.infoLab.string = skill.getDetail();
|
|
this.nextLab.string = skill.getNextLevelDetail();
|
|
this.consumeLab.string = skill.getExpPrice();
|
|
},
|
|
|
|
skillItemClicked(e, d) {
|
|
this.curItemLogic.unSelected();
|
|
this.curItemLogic = e.target.getComponent('RoleSkillItem');
|
|
this.curItemLogic.selected();
|
|
this.showSkillInfo();
|
|
},
|
|
|
|
onUpgradeBtnClicked(e, d) {
|
|
if (GameModel.player.gameData.money < this.consumeLab.string) {
|
|
MsgAlert.addMsg('銀兩不足');
|
|
return;
|
|
}
|
|
let params = {
|
|
roleId: Report.roleId,
|
|
skillId: this.curItemLogic.skillid,
|
|
costMoney: this.consumeLab.string,//本次升級技能所消耗的金幣
|
|
};
|
|
GameModel.send('c2s_player_upskill', params);
|
|
this.curItemLogic.upgradeExp();
|
|
this.showSkillInfo();
|
|
}
|
|
});
|