信息展示 继续
This commit is contained in:
@@ -19,7 +19,7 @@ export class EquipsComp extends Component {
|
||||
attrs:any={
|
||||
hero_buff:getBuffNum(),
|
||||
friend_buff:getBuffNum(),
|
||||
enemy_debuff:getBuffNum(),
|
||||
enemy_buff:getBuffNum(),
|
||||
}
|
||||
/** 视图层逻辑代码分离演示 */
|
||||
onLoad() {
|
||||
@@ -112,14 +112,11 @@ export class EquipsComp extends Component {
|
||||
// 重置所有属性
|
||||
this.reset_attrs();
|
||||
console.log("[EquipsComp]:重置后的属性", this.attrs);
|
||||
|
||||
|
||||
// 获取所有装备的属性
|
||||
let weapon_buffs = this.weapon.uuid ? EquipInfo[this.weapon.uuid]?.buff || [] : [];
|
||||
let armor_buffs = this.armor.uuid ? EquipInfo[this.armor.uuid]?.buff || [] : [];
|
||||
let accessory_buffs = this.accessory.uuid ? EquipInfo[this.accessory.uuid]?.buff || [] : [];
|
||||
let weapon_debuffs = this.weapon.uuid ? EquipInfo[this.weapon.uuid]?.debuff || [] : [];
|
||||
let armor_debuffs = this.armor.uuid ? EquipInfo[this.armor.uuid]?.debuff || [] : [];
|
||||
let accessory_debuffs = this.accessory.uuid ? EquipInfo[this.accessory.uuid]?.debuff || [] : [];
|
||||
let weapon_special_attr = this.weapon.uuid ? EquipInfo[this.weapon.uuid]?.special_attr : [];
|
||||
let armor_special_attr = this.armor.uuid ? EquipInfo[this.armor.uuid]?.special_attr : [];
|
||||
let accessory_special_attr = this.accessory.uuid ? EquipInfo[this.accessory.uuid]?.special_attr : [];
|
||||
@@ -129,10 +126,7 @@ export class EquipsComp extends Component {
|
||||
console.log("[EquipsComp]:accessory_special_attr", accessory_special_attr);
|
||||
console.log("[EquipsComp]:weapon_buffs", weapon_buffs);
|
||||
console.log("[EquipsComp]:防具属性", armor_buffs);
|
||||
console.log("[EquipsComp]:饰品属性", accessory_buffs);
|
||||
console.log("[EquipsComp]:武器减益", weapon_debuffs);
|
||||
console.log("[EquipsComp]:防具减益", armor_debuffs);
|
||||
console.log("[EquipsComp]:饰品减益", accessory_debuffs);
|
||||
console.log("[EquipsComp]:饰品属性", accessory_buffs);
|
||||
const all_special_attr=[...weapon_special_attr,...armor_special_attr,...accessory_special_attr]
|
||||
|
||||
let equip_special_attr=this.count_equip_special_attr(all_special_attr)
|
||||
@@ -140,9 +134,7 @@ export class EquipsComp extends Component {
|
||||
|
||||
// 合并所有装备属性
|
||||
const allBuff = [...weapon_buffs, ...armor_buffs, ...accessory_buffs];
|
||||
const allDebuff = [...weapon_debuffs, ...armor_debuffs, ...accessory_debuffs];
|
||||
console.log("[EquipsComp]:合并后的所有属性", allBuff);
|
||||
console.log("[EquipsComp]:合并后的所有减益", allDebuff);
|
||||
// 计算每个目标的属性加成
|
||||
allBuff.forEach(attr => {
|
||||
const target = attr.target || EquipAttrTarget.HERO;
|
||||
@@ -158,23 +150,7 @@ export class EquipsComp extends Component {
|
||||
}
|
||||
this.add_attr(targetKey,attr)
|
||||
});
|
||||
allDebuff.forEach(attr => {
|
||||
const target = attr.target || EquipAttrTarget.HERO;
|
||||
let targetKey = null;
|
||||
// 根据目标类型获取对应的key
|
||||
switch (target) {
|
||||
case EquipAttrTarget.HERO:
|
||||
targetKey = 'hero_buff';
|
||||
break;
|
||||
case EquipAttrTarget.FRIEND:
|
||||
targetKey = 'friend_buff';
|
||||
break;
|
||||
case EquipAttrTarget.ENEMY:
|
||||
targetKey = 'enemy_debuff'; //都是敌人的减益
|
||||
break;
|
||||
}
|
||||
this.add_debuff(targetKey,attr)
|
||||
});
|
||||
|
||||
|
||||
console.log("[EquipsComp]:debuff buff attrs ", this.attrs);
|
||||
oops.message.dispatchEvent(GameEvent.EquipChange, this.attrs);
|
||||
@@ -238,31 +214,6 @@ export class EquipsComp extends Component {
|
||||
}
|
||||
}
|
||||
|
||||
add_debuff(targetKey:string,attr:any){
|
||||
switch(attr.type){
|
||||
case DebuffAttr.BURN:
|
||||
this.attrs[targetKey][BuffAttr.DEF] -= attr.value; //免伤, 负的免伤 就是加伤害
|
||||
break
|
||||
case DebuffAttr.DECD:
|
||||
this.attrs[targetKey][BuffAttr.ATK_CD] -= attr.value; //加cd值 技能释放中 按-cd 计算 所以 cd 值负数实际是加cd
|
||||
break
|
||||
case DebuffAttr.DEHP:
|
||||
this.attrs[targetKey][BuffAttr.HP] -= attr.value;
|
||||
break
|
||||
case DebuffAttr.DEATK:
|
||||
this.attrs[targetKey][BuffAttr.ATK] -= attr.value;
|
||||
break
|
||||
case DebuffAttr.DECOUNT:
|
||||
this.attrs[targetKey][BuffAttr.ATK_COUNT] -= attr.value;
|
||||
break
|
||||
case DebuffAttr.CRITICAL:
|
||||
this.attrs[targetKey][BuffAttr.CRITICAL] -= attr.value;
|
||||
break
|
||||
case DebuffAttr.DODGE:
|
||||
this.attrs[targetKey][BuffAttr.DODGE] -= attr.value;
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
// 重置所有属性为0
|
||||
private reset_attrs() {
|
||||
@@ -270,7 +221,7 @@ export class EquipsComp extends Component {
|
||||
const newAttrs = {
|
||||
hero_buff: getBuffNum(),
|
||||
friend_buff: getBuffNum(),
|
||||
enemy_debuff: getBuffNum(),
|
||||
enemy_buff: getBuffNum(),
|
||||
};
|
||||
|
||||
// 替换整个 attrs 对象
|
||||
@@ -279,7 +230,7 @@ export class EquipsComp extends Component {
|
||||
console.log("重置属性", {
|
||||
hero_buff: this.attrs.hero_buff,
|
||||
friend_buff: this.attrs.friend_buff,
|
||||
enemy_debuff: this.attrs.enemy_debuff,
|
||||
enemy_buff: this.attrs.enemy_buff,
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user