SamsaraGame/assets/Script/game/SummonDetail.js
2025-04-24 17:03:28 +08:00

315 lines
11 KiB
JavaScript

import SKUIUtil from "../ts/gear_2.3.4/util/SKUIUtil";
import GameModel from "../ts/core/GameModel";
import Report from "../ts/gear_2.3.4/net/Report";
import SKDataUtil from "../ts/gear_2.3.4/util/SKDataUtil";
import SkillUtil from "../ts/game/skill/core/SkillUtil";
import AudioUtil from "../ts/core/AudioUtil";
import PetUtil from "../ts/game/pet/PetUtil";
import { EAttrTypeL1 } from "../ts/core/EEnum";
import GameUtil from "../ts/core/GameUtil";
import ItemUtil from "../ts/core/ItemUtil";
import MsgAlert from "../ts/game/msg/MsgAlert";
import SKLogger from "../ts/gear_2.3.4/util/SKLogger";
import ChangeNameAlert from "../ts/game/role/ChangeNameAlert";
let logic = require('../game/PetLogic');
cc.Class({
extends: cc.Component,
properties: {
typeIcon: cc.Sprite,
typeicons: [cc.SpriteFrame],
petNode: cc.Node,
nameLabel: cc.Label,
reliveLabel: cc.Label,
qinmiLabel: cc.Label,
scoreLabel: cc.Label,
rateLabel: cc.Label,
longguLabel: cc.Label,
colorLabel: cc.Label,
xLevelLabel: cc.Label,
aptitLabel: cc.RichText,
skillItem: cc.Node,
skillContent: cc.Node,
horseSkillItem: cc.Node,
horseSkillContent: cc.Node,
horseSkillContentParent: cc.Node,
propertyItem: cc.Node,
propertyContent: cc.Node,
hpLabel: cc.Label,
mpLabel: cc.Label,
attLabel: cc.Label,
speLabel: cc.Label,
hpNode: cc.Node,
mpNode: cc.Node,
attNode: cc.Node,
speedNode: cc.Node,
belongLabel: cc.Label,
},
onLoad() {
this.aptits = ["<color=#009F3C>資質平平</color>", "<color=#5666F4>出類拔萃</color>", "<color=#D887F5>妙領天機</color>", "<color=#B2521B>萬中無一</color>"];
this.petLogic = new logic.PetLogic();
},
loadInfo(info) {
this.petLogic.setInfo(info);
this.attr1 = this.petLogic.attr1;
this.nameLabel.string = info.PetName;
this.scoreLabel.string = "1965";
this.aptitLabel.string = this.aptits[info.aptitude] || this.aptits[0];
this.belongLabel.string = "擁有者:" + info.name + "(" + info.roleid + ")" || "";
this.typeIcon.spriteFrame = this.typeicons[this.petLogic.grade];
this.showInfo();
},
showInfo() {
let info = {
rate: this.petLogic.rate,
cur_hp: this.petLogic.hp,
cur_mp: this.petLogic.mp,
cur_atk: this.petLogic.atk,
cur_spd: this.petLogic.spd,
max_rate: this.petLogic.maxRate
};
for (let key in GameModel.conf_pet) {
if (SKDataUtil.hasProperty(GameModel.conf_pet, key)) {
let item = GameModel.conf_pet[key];
if (item.id == this.petLogic.dataid) {
//info.max_rate = SKDataUtil.jsonBy(item.rate)[1];
info.max_hp = SKDataUtil.jsonBy(item.hp)[1];
info.max_mp = SKDataUtil.jsonBy(item.mp)[1];
info.max_atk = SKDataUtil.jsonBy(item.atk)[1];
info.max_spd = SKDataUtil.jsonBy(item.spd)[1];
}
}
}
let hp_progress = this.hpNode.getChildByName('ImageLoadingBg');
let hp_label = hp_progress.getChildByName('progressLabel').getComponent(cc.Label);
let hpProgress = (info.cur_hp == 0) ? 0 : (info.cur_hp / info.max_hp);
hp_progress.getComponent(cc.ProgressBar).progress = hpProgress > 1 ? 1 : hpProgress;
hp_label.string = info.cur_hp + '/' + info.max_hp;
let mp_progress = this.mpNode.getChildByName('ImageLoadingBg');
let mp_label = mp_progress.getChildByName('progressLabel').getComponent(cc.Label);
let mpProgress = (info.cur_mp == 0) ? 0 : (info.cur_mp / info.max_mp);
mp_progress.getComponent(cc.ProgressBar).progress = mpProgress > 1 ? 1 : mpProgress;
mp_label.string = info.cur_mp + '/' + info.max_mp;
let att_progress = this.attNode.getChildByName('ImageLoadingBg');
let att_label = att_progress.getChildByName('progressLabel').getComponent(cc.Label);
let atkProgress = (info.cur_atk == 0) ? 0 : (info.cur_atk / info.max_atk);
att_progress.getComponent(cc.ProgressBar).progress = atkProgress > 1 ? 1 : atkProgress;
att_label.string = info.cur_atk + '/' + info.max_atk;
let spe_progress = this.speedNode.getChildByName('ImageLoadingBg');
let spe_label = spe_progress.getChildByName('progressLabel').getComponent(cc.Label);
let spdProgress = (info.cur_spd == 0) ? 0 : (info.cur_spd / info.max_spd);
spe_progress.getComponent(cc.ProgressBar).progress = spdProgress > 1 ? 1 : spdProgress;
spe_label.string = info.cur_spd + '/' + info.max_spd;
//let currate = info.rate + this.petLogic.longgu * 0.01;
this.rateLabel.string = "成長率 " + info.rate.toFixed(3) + '/' + info.max_rate.toFixed(3);
let petcolor = null;
if (this.petLogic && this.petLogic.petinfo) {
petcolor = this.petLogic.petinfo.color;
} else {
cc.warn(`$警告:召喚獸變色信息異常!`);
}
this.petNode.getComponent('UIRole').setInfo({
resid: this.petLogic.resid,
name: '',
petcolor: petcolor
});
this.hpLabel.string = "氣血 " + this.petLogic.cur_hp;
this.mpLabel.string = "法力 " + this.petLogic.cur_mp;
this.attLabel.string = "攻擊 " + this.petLogic.cur_atk;
this.speLabel.string = "速度 " + this.petLogic.cur_spd;
this.qinmiLabel.string = "親密度 " + this.petLogic.qinmi;
this.reliveLabel.string = this.petLogic.relive + "轉" + this.petLogic.level + "級";
this.xLevelLabel.string = "修煉等級 " + this.petLogic.xlevel;
this.longguLabel.string = `龍骨x${this.petLogic.longgu}`;
this.colorLabel.string = "變色數量 " + "0/7";
// 技能
this.showSkillList();
this.showPropertyList();
this.showHorseSkillList();
},
showSkillList() {
let skillCnt = this.petLogic.maxskillcnt;
let skillItem = this.skillItem;
let skillinfolist = null;
if (this.petLogic && this.petLogic.petinfo) {
skillinfolist = this.petLogic.petinfo.skill;
}
if (!skillinfolist) {
skillinfolist = [];
}
let tmpskilllist = [];
for (let skillid in skillinfolist) {
if (SKDataUtil.hasProperty(skillinfolist, skillid)) {
let skillinfo = skillinfolist[skillid];
skillinfo.skillid = skillid;
tmpskilllist.push(skillinfo);
}
}
tmpskilllist.sort((a, b) => {
return a.idx - b.idx;
});
this.skillContent.removeAllChildren();
for (let index = 0; index < skillCnt; index++) {
let skillinfo = tmpskilllist[index];
let item = cc.instantiate(skillItem);
item.active = true;
item.name = 'skillItem';
item.parent = this.skillContent;
if (index < SKDataUtil.getLength(this.petLogic.skill)) {
item.getChildByName('base').active = true;
item.getChildByName('lock').active = false;
if (skillinfo) {
let skillid = skillinfo.skillid;
let skill = SkillUtil.getSkill(skillid);
if (!skill) {
item.getChildByName('TextName').getComponent(cc.Label).string = "已解封";
continue;
}
let key = skill.icon;
let spriteFrame = SkillUtil.getSkillIcon(key);
if (!spriteFrame) {
cc.warn(`$警告:召喚獸缺少技能圖標:${key}`);
} else {
cc.find('base/icon', item).getComponent(cc.Sprite).spriteFrame = spriteFrame;
}
item.getChildByName('TextName').getComponent(cc.Label).string = skill.name;
// item.getChildByName('lockflag').active = (skillinfo.lck == 1);
}
} else {
item.getChildByName('base').active = false;
item.getChildByName('lock').active = true;
item.getChildByName('TextName').getComponent(cc.Label).string = "未解封";
}
}
},
showHorseSkillList() {
let skillCnt = 0
let horseSkillItem = this.horseSkillItem;
let skillinfolist = null;
if (this.petLogic && this.petLogic.petinfo && this.petLogic.petinfo.horseSkill) {
skillinfolist = this.petLogic.petinfo.horseSkill;
skillCnt = this.petLogic.petinfo.horseSkill.length;
}
if (!skillinfolist || !skillCnt) {
this.horseSkillContentParent.active = false;
return;
}
let tmpskilllist = [];
for (let i in skillinfolist) {
let skillinfo = skillinfolist[i]
skillinfo.skillid = skillinfolist[i].skill_id;
tmpskilllist.push(skillinfo)
}
this.horseSkillContent.removeAllChildren();
for (let index = 0; index < skillCnt; index++) {
let skillinfo = tmpskilllist[index];
let item = cc.instantiate(horseSkillItem);
item.active = true;
item.name = 'horseSkillItem';
item.parent = this.horseSkillContent;
if (skillinfo) {
let skillid = skillinfo.skillid;
let skill = SkillUtil.getHorseSkill(skillid);
let key = skill.icon;
let spriteFrame = SkillUtil.getSkillIcon(key);
if (!spriteFrame) {
cc.warn(`$警告:召喚獸缺少技能圖標:${key}`);
} else {
cc.find('base/icon', item).getComponent(cc.Sprite).spriteFrame = spriteFrame;
}
item.getChildByName('TextName').getComponent(cc.Label).string = skill.name;
}
}
},
showPropertyList() {
this.dshangxian = this.attr1[EAttrTypeL1.K_SEAL_CONFUSION_SLEEP_FORGET_LIMIT];
this.dfengyin = this.attr1[EAttrTypeL1.K_SEAL];
this.dhunlun = this.attr1[EAttrTypeL1.K_CONFUSION];
this.dhunshui = this.attr1[EAttrTypeL1.K_SLEEP];
this.dyiwang = this.attr1[EAttrTypeL1.K_FORGET];
this.dfeng = this.attr1[EAttrTypeL1.K_WIND];
this.dlei = this.attr1[EAttrTypeL1.K_THUNDER];
this.dshui = this.attr1[EAttrTypeL1.K_WATER];
this.dhuo = this.attr1[EAttrTypeL1.K_FIRE];
this.dguihuo = this.attr1[EAttrTypeL1.K_WILDFIRE];
this.dsanshi = this.attr1[EAttrTypeL1.K_BLOODRETURN];
this.ddu = this.attr1[EAttrTypeL1.K_POISON];
this.pxishou = this.attr1[EAttrTypeL1.PHY_GET];
this.propertyContent.removeAllChildren();
if (this.dfengyin > 0) this.addProperty("抗封印", this.dfengyin.toFixed(1) + "%");
if (this.dhunlun > 0) this.addProperty("抗混亂", this.dhunlun.toFixed(1) + "%");
if (this.dhunshui > 0) this.addProperty("抗昏睡", this.dhunshui.toFixed(1) + "%");
if (this.dyiwang > 0) this.addProperty("抗遺忘", this.dyiwang.toFixed(1) + "%");
if (this.dfeng > 0) this.addProperty("抗風", this.dfeng.toFixed(1) + "%");
if (this.dlei > 0) this.addProperty("抗雷", this.dlei.toFixed(1) + "%");
if (this.dshui > 0) this.addProperty("抗水", this.dshui.toFixed(1) + "%");
if (this.dhuo > 0) this.addProperty("抗火", this.dhuo.toFixed(1) + "%");
if (this.dguihuo > 0) this.addProperty("抗鬼火", this.dguihuo.toFixed(1) + "%");
if (this.ddu > 0) this.addProperty("抗毒", this.ddu.toFixed(1) + "%");
if (this.dsanshi > 0) this.addProperty("抗三尸", this.dsanshi.toFixed(1) + "%");
if (this.petLogic.plianjilv > 0) this.addProperty("連擊率", this.petLogic.plianjilv.toFixed(1) + "%");
if (this.petLogic.plianjilv > 0) this.addProperty("連擊次數", this.petLogic.plianji);
if (this.petLogic.dzhenshe > 0) this.addProperty("抗震懾", this.petLogic.dzhenshe.toFixed(1) + "%");
if (this.petLogic.pkuangbao > 0) this.addProperty("狂暴率", this.petLogic.pkuangbao.toFixed(1) + "%");
if (this.petLogic.pmingzhong > 0) this.addProperty("命中率", this.petLogic.pmingzhong.toFixed(1) + "%");
let wuxing = this.petLogic.wuxing;
let wuxingname = ["金", "木", "水", "火", "土"];
let wuxingindex = 0;
for (let k in wuxing) {
if (wuxing[k]) this.addProperty(wuxingname[wuxingindex], wuxing[k]);
wuxingindex++;
}
},
addProperty(name, value) {
let item = cc.instantiate(this.propertyItem);
item.parent = this.propertyContent;
item.getChildByName("TextName").getComponent(cc.Label).string = name;
item.getChildByName("TextVal").getComponent(cc.Label).string = "+" + value;
},
Close() {
this.node.destroy();
},
// LIFE-CYCLE CALLBACKS:
// onLoad () {},
start() {
},
// update (dt) {},
});