SamsaraGame/assets/Script/panel/RoleDefendPanel.js

265 lines
7.5 KiB
JavaScript
Raw Normal View History

2025-04-24 17:03:28 +08:00
import GameModel from "../ts/core/GameModel";
import GameUtil from "../ts/core/GameUtil";
import { EAttrTypeL1 } from "../ts/core/EEnum";
/**
* 屬性面板顯示
*/
let DefendFa = [
EAttrTypeL1.K_CONFUSION, // 抗混亂
EAttrTypeL1.K_SEAL, // 抗封印
EAttrTypeL1.K_SLEEP, // 抗昏睡
EAttrTypeL1.K_POISON, // 抗毒
EAttrTypeL1.K_WIND, // 抗風
EAttrTypeL1.K_FIRE, // 抗火
EAttrTypeL1.K_WATER, // 抗水
EAttrTypeL1.K_THUNDER, // 抗雷
EAttrTypeL1.K_WILDFIRE, // 抗鬼火
EAttrTypeL1.K_FORGET, // 抗遺忘
EAttrTypeL1.K_BLOODRETURN, // 抗三尸
EAttrTypeL1.K_DETER, // 抗震懾
];
let DefendWuli = [
EAttrTypeL1.PHY_GET, // 物理吸收
EAttrTypeL1.PHY_HIT, // 命中
EAttrTypeL1.PHY_DODGE, // 閃避
EAttrTypeL1.K_PHY_GET, // 抗物理
EAttrTypeL1.HK_PHY_GET, // 忽視抗物理
EAttrTypeL1.SWEEP_EHAN,// 加強橫掃
EAttrTypeL1.BREAK_EHAN,// 加強破甲
EAttrTypeL1.THUD_EHAN, // 加強震擊
EAttrTypeL1.PHY_DEADLY, //狂暴
EAttrTypeL1.PHY_BREAK, //破防程度
EAttrTypeL1.PHY_BREAK_PROB,//破防率
EAttrTypeL1.PHY_COMBO, //連擊
EAttrTypeL1.PHY_COMBO_PROB, //連擊率
EAttrTypeL1.PHY_REBOUND, //反震
EAttrTypeL1.PHY_REBOUND_PROB, //反震率
];
let DefendZeng = [
EAttrTypeL1.HK_CONFUSION, // 忽視抗混亂
EAttrTypeL1.HK_SEAL, // 忽視抗封印
EAttrTypeL1.HK_SLEEP, // 忽視抗昏睡
EAttrTypeL1.HK_POISON, // 忽視抗毒
EAttrTypeL1.HK_WIND, // 忽視抗風
EAttrTypeL1.HK_FIRE, // 忽視抗火
EAttrTypeL1.HK_WATER, // 忽視抗水
EAttrTypeL1.HK_THUNDER, // 忽視抗雷
EAttrTypeL1.HK_WILDFIRE, // 忽視抗鬼火
EAttrTypeL1.HK_FORGET, // 忽視抗遺忘
EAttrTypeL1.HK_BLOODRETURN, // 忽視抗三尸
EAttrTypeL1.HK_DETER, // 忽視抗震懾
EAttrTypeL1.Q_WIND, // 風狂暴
EAttrTypeL1.KB_WIND, // 風狂暴率
EAttrTypeL1.Q_FIRE, // 火狂暴
EAttrTypeL1.KB_FIRE, // 火狂暴率
EAttrTypeL1.Q_WATER, // 水狂暴
EAttrTypeL1.KB_WATER, // 水狂暴率
EAttrTypeL1.Q_THUNDER, // 雷狂暴
EAttrTypeL1.KB_THUNDER, // 雷狂暴率
EAttrTypeL1.Q_BLOODRETURN, //三尸狂暴
EAttrTypeL1.KB_BLOODRETURN, // 三尸狂暴率
EAttrTypeL1.Q_WILDFIRE, //鬼火狂暴
EAttrTypeL1.KB_WILDFIRE, // 鬼火狂暴率
EAttrTypeL1.SLEEP_EHAN, //加強睡
EAttrTypeL1.DETER_EHAN, //加強震懾
EAttrTypeL1.TOXIN_EHAN, // 加強毒
EAttrTypeL1.SPD_ADD_EHAN, //加強加速
EAttrTypeL1.DEFEND_ADD_EHAN, //加強加防
EAttrTypeL1.BLOODRETURN_EHAN, //強三尸
EAttrTypeL1.CURE_EHAN, // 加強治愈
EAttrTypeL1.CHARM_ADD, //加強魅惑
EAttrTypeL1.WILDFIRE, //加強鬼火
EAttrTypeL1.ICE_EHAN, //加強冰
EAttrTypeL1.SEAL_EHAN, //加強封印
EAttrTypeL1.CHAOS_EHAN, //加強混亂
EAttrTypeL1.WIND_EHAN, //加強風
EAttrTypeL1.FIRE_EHAN, //加強火
EAttrTypeL1.WATER_EHAN, //加強水
EAttrTypeL1.THUNDER_EHAN, //加強雷
EAttrTypeL1.FORGET_EHAN, //加強遺忘
];
let DefendWuXing = [
EAttrTypeL1.GOLD, // 金
EAttrTypeL1.WOOD, // 木
EAttrTypeL1.WATER, // 水
EAttrTypeL1.FIRE, // 火
EAttrTypeL1.SOIL, // 土
EAttrTypeL1.S_GOLD,// 強力克金
EAttrTypeL1.S_WOOD,// 強力克木
EAttrTypeL1.S_WATER,// 強力克水
EAttrTypeL1.S_FIRE,// 強力克火
EAttrTypeL1.S_SOIL,// 強力剋土
];
cc.Class({
extends: cc.Component,
properties: {
faNode: cc.Node,
wuliNode: cc.Node,
zengNode: cc.Node,
wuxingNode: cc.Node,
itemNode: cc.Node,
line1Node: cc.Node,
line2Node: cc.Node,
line3Node: cc.Node,
infoContent: cc.Node,
},
onLoad() {
this.items = [];
this.loadGameData();
},
loadGameData() {
this.wuliNode.active = false;
this.zengNode.active = false;
this.wuxingNode.active = false;
this.itemNode.active = false;
this.line1Node.active = false;
this.line2Node.active = false;
this.line3Node.active = false;
this.curY = -55;
this.curX = -215;
this.leftItem = true;
if (this.items) {
for (const item of this.items) {
item.destroy();
}
}
this.items = [];
let attr1 = GameModel.player.gameData.attr1;
for (let key of DefendFa) {
if (attr1[key] != null && attr1[key] != 0) {
let item = cc.instantiate(this.itemNode);
this.items.push(item);
let title = GameUtil.getAttrTypeL1Name(key);
let value = attr1[key].toFixed(1) + '%';
item.getChildByName('title').getComponent(cc.Label).string = title;
item.getChildByName('value').getComponent(cc.Label).string = value;
item.parent = this.infoContent;
item.active = true;
item.x = this.curX;
item.y = this.curY;
this.leftItem = !this.leftItem;
this.curX = 15;
if (this.leftItem) {
this.curX = -215;
this.curY -= 40;
}
}
}
if (!this.leftItem) {
this.curX = -215;
this.curY -= 40;
this.leftItem = true;
}
for (let key of DefendWuli) {
if (attr1[key] != null && attr1[key] != 0) {
if (this.wuliNode.active == false) {
this.line1Node.active = true;
this.line1Node.y = this.curY + 20;
this.wuliNode.active = true;
this.wuliNode.y = this.curY - 10;
this.curY -= 45;
}
let item = cc.instantiate(this.itemNode);
this.items.push(item);
let title = GameUtil.getAttrTypeL1Name(key);
let value = attr1[key].toFixed(1) + '%';
item.getChildByName('title').getComponent(cc.Label).string = title;
item.getChildByName('value').getComponent(cc.Label).string = value;
item.parent = this.infoContent;
item.active = true;
item.x = this.curX;
item.y = this.curY;
this.leftItem = !this.leftItem;
this.curX = 15;
if (this.leftItem) {
this.curX = -215;
this.curY -= 40;
}
}
}
if (!this.leftItem) {
this.curX = -215;
this.curY -= 40;
this.leftItem = true;
}
for (let key of DefendZeng) {
if (attr1[key] != null && attr1[key] != 0) {
if (this.zengNode.active == false) {
this.line2Node.active = true;
this.line2Node.y = this.curY + 20;
this.zengNode.active = true;
this.zengNode.y = this.curY - 10;
this.curY -= 45;
}
let item = cc.instantiate(this.itemNode);
this.items.push(item);
let title = GameUtil.getAttrTypeL1Name(key);
let value = attr1[key].toFixed(1) + '%';
item.getChildByName('title').getComponent(cc.Label).string = title;
item.getChildByName('value').getComponent(cc.Label).string = value;
item.parent = this.infoContent;
item.active = true;
item.x = this.curX;
item.y = this.curY;
this.leftItem = !this.leftItem;
this.curX = 15;
if (this.leftItem) {
this.curX = -215;
this.curY -= 40;
}
}
}
if (!this.leftItem) {
this.curX = -215;
this.curY -= 40;
this.leftItem = true;
}
for (let key of DefendWuXing) {
if (attr1[key] != null && attr1[key] != 0) {
if (this.wuxingNode.active == false) {
this.line3Node.active = true;
this.line3Node.y = this.curY + 20;
this.wuxingNode.active = true;
this.wuxingNode.y = this.curY - 10;
this.curY -= 45;
}
let item = cc.instantiate(this.itemNode);
this.items.push(item);
let title = GameUtil.getAttrTypeL1Name(key);
let value = attr1[key].toFixed(1) + `${(key >= 70 && key <= 74) ? '' : '%'}`;
item.getChildByName('title').getComponent(cc.Label).string = title;
item.getChildByName('value').getComponent(cc.Label).string = value;
item.parent = this.infoContent;
item.active = true;
item.x = this.curX;
item.y = this.curY;
this.leftItem = !this.leftItem;
this.curX = 15;
if (this.leftItem) {
this.curX = -215;
this.curY -= 40;
}
}
}
if (!this.leftItem) {
this.curY -= 40;
}
this.infoContent.height = -this.curY;
if (this.infoContent.height < this.infoContent.parent.height) {
this.infoContent.height = this.infoContent.parent.height;
}
},
});