装备改为 buff 和 debuff 2种加成

This commit is contained in:
2025-06-14 22:54:07 +08:00
parent d01b98f9c3
commit cb91e66646
8 changed files with 162 additions and 144 deletions

View File

@@ -1,5 +1,5 @@
import { app } from "electron";
import { BuffAttr } from "./SkillSet";
import { BuffAttr, DebuffAttr } from "./SkillSet";
// 装备类型
export enum EquipType {
@@ -10,7 +10,6 @@ export enum EquipType {
//装备属性起效对象
export enum EquipAttrTarget {
ALL = 0, // 所有
HERO = 1, // 自身
FRIEND = 2, // 伙伴
ENEMY = 3, // 敌人
@@ -45,6 +44,11 @@ export interface EquipAttribute {
value: number; // 属性值
target?: EquipAttrTarget; // 属性作用目标(可选)
}
export interface EquipDebuffAttribute {
type: DebuffAttr; // 属性类型
value: number; // 属性值
target?: EquipAttrTarget; // 属性作用目标(可选)
}
// 装备基础接口
export interface EquipData {
@@ -52,32 +56,48 @@ export interface EquipData {
name: string; // 装备名称
type: EquipType; // 装备类型
info: string; // 装备描述
attributes: EquipAttribute[]; // 属性加成列表
buff: EquipAttribute[]; // 属性加成列表
debuff: EquipDebuffAttribute[]; // 属性减益列表
}
export const EquipInfo: { [key: number]: EquipData } = {
2001: {uuid: 2001, name: "新手剑", type: EquipType.WEAPON,info:"攻击力增加80%",
attributes: [
buff: [
{ type: BuffAttr.ATK, value: 80, target: EquipAttrTarget.HERO },
],
debuff: [
{ type: DebuffAttr.DECD, value: 50, target: EquipAttrTarget.ENEMY },
]
},
2002: {uuid: 2002,name: "新手剑2",type: EquipType.WEAPON,info:"攻击速度增加30%",
attributes: [
buff: [
{ type: BuffAttr.ATK_CD, value: 30, target: EquipAttrTarget.HERO },
],
debuff: [
{ type: DebuffAttr.DECD, value: 50, target: EquipAttrTarget.ENEMY },
]
},
2003: {uuid: 2003,name: "新手剑3",type: EquipType.WEAPON,info:"攻击次数增加1次",
attributes: [
buff: [
{ type: BuffAttr.ATK_COUNT, value: 1, target: EquipAttrTarget.HERO },
],
debuff: [
{ type: DebuffAttr.DECD, value: 50, target: EquipAttrTarget.ENEMY },
]
},
2004: {uuid: 2004,name: "防具1",type: EquipType.ARMOR,info:"生命值增加100%",
attributes: [
buff: [
{ type: BuffAttr.HP, value: 100, target: EquipAttrTarget.HERO },
],
debuff: [
{ type: DebuffAttr.DECD, value: 50, target: EquipAttrTarget.ENEMY },
]
},
2005: {uuid: 2005,name: "防具2",type: EquipType.ARMOR,info:"免伤增加50%",
attributes: [
buff: [
{ type: BuffAttr.DEF, value: 50, target: EquipAttrTarget.HERO },
],
debuff: [
{ type: DebuffAttr.DECD, value: 50, target: EquipAttrTarget.ENEMY },
]
},

View File

@@ -66,6 +66,18 @@ export enum DebuffAttr {
DECOUNT = 8, //减攻击次数
}
export enum BuffAttr {
ATK = 1, // 攻击力
ATK_COUNT = 2, // 攻击个数
ATK_CD = 3, // 攻击速度
HP = 4, // 生命值
DEF = 5, // 免伤
SKILL_DMG = 6, // 技能效果
SKILL_CD = 7, // 技能冷却缩减
CARD_EFFECT = 8, // 卡牌效果
CARD_COUNT = 8, // 卡牌起效次数,每3次多起效一次
}
export const geDebuffNum=()=>{
return {
STUN:0, //眩晕
@@ -79,17 +91,6 @@ export const geDebuffNum=()=>{
}
}
export enum BuffAttr {
ATK = 1, // 攻击力
ATK_COUNT = 2, // 攻击个数
ATK_CD = 3, // 攻击速度
HP = 4, // 生命值
DEF = 5, // 免伤
SKILL_DMG = 6, // 技能效果
SKILL_CD = 7, // 技能冷却缩减
CARD_EFFECT = 8, // 卡牌效果
CARD_COUNT = 8, // 卡牌起效次数,每3次多起效一次
}
export const getBuffNum=()=>{
return {

View File

@@ -37,20 +37,8 @@ export class SkillConComp extends CCComp {
if(!smc.mission.play||smc.mission.pause) return
this.HeroView.at += dt;
let cd = this.HeroView.cd
let count=1
if(this.HeroView.fac==FacSet.HERO){
if(this.HeroView.is_master){
count+=this.FIGHTCON.hero.ATK_COUNT+this.FIGHTCON.ally.ATK_COUNT-this.FIGHTCON.hero_debuff.DECOUNT-this.FIGHTCON.ally_debuff.DECOUNT
cd=this.HeroView.cd*(100-this.FIGHTCON.hero.ATK_CD-this.FIGHTCON.ally.ATK_CD+this.FIGHTCON.hero_debuff.DECD+this.FIGHTCON.ally_debuff.DECD)/100
}else{
count+=this.FIGHTCON.friend.ATK_COUNT+this.FIGHTCON.ally.ATK_COUNT-this.FIGHTCON.friend_debuff.DECOUNT-this.FIGHTCON.ally_debuff.DECOUNT
cd=this.HeroView.cd*(100-this.FIGHTCON.friend.ATK_CD-this.FIGHTCON.ally.ATK_CD+this.FIGHTCON.friend_debuff.DECD+this.FIGHTCON.ally_debuff.DECD)/100
}
}else{
count+=this.FIGHTCON.enemy.ATK_COUNT-this.FIGHTCON.enemy_debuff.DECOUNT
cd=this.HeroView.cd*(100-this.FIGHTCON.enemy.ATK_CD+this.FIGHTCON.enemy_debuff.DECD)/100
}
let cd = this.get_cd(this.HeroView.cd,this.HeroView)
let count=this.get_count(1,this.HeroView)
if(count<1) count=1
// console.log(this.HeroView.hero_name+(this.HeroView.is_master?"[主]":"[从] 准备释放")+SkillSet[this.HeroView.atk_skill].name+"=>"+"=>cd:"+cd+"=> count:"+count)
if (this.HeroView.is_atking &&(this.HeroView.at > cd)) {
@@ -61,13 +49,35 @@ export class SkillConComp extends CCComp {
this.HeroView.at = 0;
}
}
get_cd(cd:number,view:HeroViewComp){
if(view.fac==FacSet.HERO){
if(view.is_master){
return cd*(100-this.FIGHTCON.hero_buff.ATK_CD+this.FIGHTCON.hero_debuff.DECD)/100
}else{
return cd*(100-this.FIGHTCON.friend_buff.ATK_CD+this.FIGHTCON.hero_debuff.DECD)/100
}
}else{
return cd*(100-this.FIGHTCON.enemy_buff.ATK_CD+this.FIGHTCON.enemy_debuff.DECD)/100
}
}
get_count(count:number,view:HeroViewComp){
if(view.fac==FacSet.HERO){
if(view.is_master){
return count+(this.FIGHTCON.hero_buff.ATK_COUNT-this.FIGHTCON.hero_debuff.DECOUNT)
}else{
return count+(this.FIGHTCON.friend_buff.ATK_COUNT-this.FIGHTCON.hero_debuff.DECOUNT)
}
}else{
return count+(this.FIGHTCON.enemy_buff.ATK_COUNT-this.FIGHTCON.enemy_debuff.DECOUNT)
}
}
cast_master_skill(e:string,uuid:any){
if(!this.HeroView) return
if(!this.HeroView.is_master) return
console.log("hart cast_skill",uuid ,e)
const config = SkillSet[uuid];
this.castSkill(config,1,this.FIGHTCON.hero.SKILL_DMG)
this.castSkill(config,1,this.FIGHTCON.hero_buff.SKILL_DMG)
}
/** 施放技能 */

View File

@@ -65,7 +65,7 @@ export class EquipSkillComp extends CCComp {
update(dt: number): void {
if(!smc.mission.play||smc.mission.pause) return
if(this.skill1.uuid!=0){
if(this.skill1.cd_time < (this.skill1.cd-this.equips.attrs.hero.SKILL_CD)){
if(this.skill1.cd_time < (this.skill1.cd-this.equips.attrs.hero_buff.SKILL_CD)){
this.skill1.cd_time+=dt
}else{
this.skill1.cd_time=0
@@ -76,7 +76,7 @@ export class EquipSkillComp extends CCComp {
this.boxs.getChildByName("skill1").getChildByName("icon").getChildByName("cd").getComponent(ProgressBar).progress=(1-this.skill1.cd_time/this.skill1.cd)
}
if(this.skill2.uuid!=0){
if(this.skill2.cd_time < (this.skill2.cd-this.equips.attrs.hero.SKILL_CD)){
if(this.skill2.cd_time < (this.skill2.cd-this.equips.attrs.hero_buff.SKILL_CD)){
this.skill2.cd_time+=dt
}else{
this.skill2.cd_time=0
@@ -87,7 +87,7 @@ export class EquipSkillComp extends CCComp {
this.boxs.getChildByName("skill2").getChildByName("icon").getChildByName("cd").getComponent(ProgressBar).progress=(1-this.skill2.cd_time/this.skill2.cd)
}
if(this.skill3.uuid!=0){
if(this.skill3.cd_time < (this.skill3.cd-this.equips.attrs.hero.SKILL_CD)){
if(this.skill3.cd_time < (this.skill3.cd-this.equips.attrs.hero_buff.SKILL_CD)){
this.skill3.cd_time+=dt
}else{
this.skill3.cd_time=0

View File

@@ -3,7 +3,7 @@ import { oops } from 'db://oops-framework/core/Oops';
import { GameEvent } from '../common/config/GameEvent';
import { smc } from '../common/SingletonModuleComp';
import { EquipInfo, EquipType, EquipAttrTarget} from '../common/config/Equips';
import { BuffAttr, getBuffNum } from '../common/config/SkillSet';
import { BuffAttr, DebuffAttr, geDebuffNum, getBuffNum } from '../common/config/SkillSet';
const { ccclass, property } = _decorator;
@ccclass('EquipsComp')
@@ -16,10 +16,11 @@ export class EquipsComp extends Component {
skill3:any=null
boxs:Node=null
attrs:any={
hero:getBuffNum(),
ally:getBuffNum(),
enemy:getBuffNum(),
friend:getBuffNum(),
hero_buff:getBuffNum(),
friend_buff:getBuffNum(),
hero_debuff:geDebuffNum(),
friend_debuff:geDebuffNum(),
enemy_debuff:geDebuffNum(),
}
/** 视图层逻辑代码分离演示 */
onLoad() {
@@ -114,106 +115,92 @@ export class EquipsComp extends Component {
console.log("重置后的属性", this.attrs);
// 获取所有装备的属性
let weapon_attrs = this.weapon.uuid ? EquipInfo[this.weapon.uuid]?.attributes || [] : [];
let armor_attrs = this.armor.uuid ? EquipInfo[this.armor.uuid]?.attributes || [] : [];
let accessory_attrs = this.accessory.uuid ? EquipInfo[this.accessory.uuid]?.attributes || [] : [];
console.log("武器属性", weapon_attrs);
console.log("防具属性", armor_attrs);
console.log("饰品属性", accessory_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 || [] : [];
console.log("武器属性", weapon_buffs);
console.log("防具属性", armor_buffs);
console.log("饰品属性", accessory_buffs);
console.log("武器减益", weapon_debuffs);
console.log("防具减益", armor_debuffs);
console.log("饰品减益", accessory_debuffs);
// 合并所有装备属性
const allAttrs = [...weapon_attrs, ...armor_attrs, ...accessory_attrs];
console.log("合并后的所有属性", allAttrs);
const allBuff = [...weapon_buffs, ...armor_buffs, ...accessory_buffs];
const allDebuff = [...weapon_debuffs, ...armor_debuffs, ...accessory_debuffs];
console.log("合并后的所有属性", allBuff);
console.log("合并后的所有减益", allDebuff);
// 计算每个目标的属性加成
allAttrs.forEach(attr => {
const target = attr.target || EquipAttrTarget.ALL;
allBuff.forEach(attr => {
const target = attr.target || EquipAttrTarget.HERO;
let targetKey = null;
// 根据目标类型获取对应的key
switch (target) {
case EquipAttrTarget.ALL:
targetKey = 'ally';
break;
case EquipAttrTarget.HERO:
targetKey = 'hero';
targetKey = 'hero_buff';
break;
case EquipAttrTarget.FRIEND:
targetKey = 'friend';
targetKey = 'friend_buff';
break;
}
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_debuff';
break;
case EquipAttrTarget.FRIEND:
targetKey = 'friend_debuff';
break;
case EquipAttrTarget.ENEMY:
targetKey = 'enemy';
targetKey = 'enemy_debuff';
break;
}
console.log("处理属性加成", {
target: target,
targetKey: targetKey,
attr: attr,
beforeValue: targetKey ? this.attrs[targetKey][BuffAttr[attr.type]] : null
this.add_debuff(targetKey,attr)
});
if (targetKey) {
switch (attr.type) {
case BuffAttr.ATK:
this.attrs[targetKey].ATK += attr.value;
break;
case BuffAttr.ATK_COUNT:
this.attrs[targetKey].ATK_COUNT += attr.value;
break;
case BuffAttr.ATK_CD:
this.attrs[targetKey].ATK_CD += attr.value;
break;
case BuffAttr.HP:
this.attrs[targetKey].HP += attr.value;
break;
case BuffAttr.DEF:
this.attrs[targetKey].DEF += attr.value;
break;
case BuffAttr.SKILL_DMG:
this.attrs[targetKey].SKILL_DMG += attr.value;
break;
case BuffAttr.SKILL_CD:
this.attrs[targetKey].SKILL_CD += attr.value;
break;
case BuffAttr.CARD_EFFECT:
this.attrs[targetKey].CARD_EFFECT += attr.value;
break;
case BuffAttr.CARD_COUNT:
this.attrs[targetKey].CARD_COUNT += attr.value;
break;
}
console.log("属性加成后", {
targetKey: targetKey,
attrType: BuffAttr[attr.type],
afterValue: this.attrs[targetKey][BuffAttr[attr.type]]
});
}
});
console.log("最终属性加成", this.attrs);
oops.message.dispatchEvent(GameEvent.EquipChange, this.attrs);
}
add_attr(targetKey:string,attr:any){
if(targetKey){
this.attrs[targetKey][BuffAttr[attr.type]] += attr.value;
}
}
add_debuff(targetKey:string,attr:any){
if(targetKey){
this.attrs[targetKey][DebuffAttr[attr.type]] += attr.value;
}
}
// 重置所有属性为0
private reset_attrs() {
// 创建新的属性对象
const newAttrs = {
hero: getBuffNum(),
ally: getBuffNum(),
enemy: getBuffNum(),
friend: getBuffNum()
hero_buff: getBuffNum(),
friend_buff: getBuffNum(),
hero_debuff: geDebuffNum(),
friend_debuff: geDebuffNum(),
enemy_debuff: geDebuffNum(),
};
// 替换整个 attrs 对象
this.attrs = newAttrs;
console.log("重置属性", {
hero: this.attrs.hero,
ally: this.attrs.ally,
enemy: this.attrs.enemy,
friend: this.attrs.friend
hero_buff: this.attrs.hero_buff,
hero_debuff: this.attrs.hero_debuff,
friend_buff: this.attrs.friend_buff,
friend_debuff: this.attrs.friend_debuff,
enemy_debuff: this.attrs.enemy_debuff,
});
}

View File

@@ -7,23 +7,21 @@ const { ccclass, property } = _decorator;
@ccclass('FightConComp')
export class FightConComp extends Component {
hero=getBuffNum()
ally=getBuffNum()
enemy=getBuffNum()
friend=getBuffNum()
hero_buff=getBuffNum()
friend_buff=getBuffNum()
enemy_buff=getBuffNum()
hero_debuff=geDebuffNum()
ally_debuff=geDebuffNum()
enemy_debuff=geDebuffNum()
friend_debuff=geDebuffNum()
enemy_debuff=geDebuffNum()
//注意临时buff和debuff 每种buff的值 必须都一样 多种值 战斗处理复杂 暂时放弃
temp_hero_buff = this.getInitTempBuff();
temp_ally_buff = this.getInitTempBuff();
temp_enemy_buff = this.getInitTempBuff();
temp_friend_buff = this.getInitTempBuff();
temp_enemy_buff = this.getInitTempBuff();
temp_hero_debuff = this.getInitTempDebuff();
temp_ally_debuff = this.getInitTempDebuff();
temp_enemy_debuff = this.getInitTempDebuff();
temp_friend_debuff = this.getInitTempDebuff();
temp_enemy_debuff = this.getInitTempDebuff();
onLoad(){
// console.log("fight con start")
@@ -32,11 +30,14 @@ export class FightConComp extends Component {
}
private equip_change(e:GameEvent,equip:any){
this.hero=equip.hero
this.ally=equip.ally
this.enemy=equip.enemy
this.friend=equip.friend
this.hero_buff=equip.hero_buff
this.friend_buff=equip.friend_buff
this.hero_debuff=equip.hero_debuff
this.friend_debuff=equip.friend_debuff
this.enemy_debuff=equip.enemy_debuff
}
private fight_ready(e:GameEvent){
this.clearAlls()
}
@@ -84,22 +85,21 @@ export class FightConComp extends Component {
}
private clearAlls() {
this.hero=getBuffNum()
this.ally=getBuffNum()
this.enemy=getBuffNum()
this.friend=getBuffNum()
this.hero_buff=getBuffNum()
this.friend_buff=getBuffNum()
this.enemy_buff=getBuffNum()
this.hero_debuff=geDebuffNum()
this.ally_debuff=geDebuffNum()
this.enemy_debuff=geDebuffNum()
this.friend_debuff=geDebuffNum()
this.enemy_debuff=geDebuffNum()
this.temp_hero_buff = this.getInitTempBuff()
this.temp_ally_buff = this.getInitTempBuff()
this.temp_enemy_buff = this.getInitTempBuff()
this.temp_friend_buff = this.getInitTempBuff()
this.temp_enemy_buff = this.getInitTempBuff()
this.temp_hero_debuff = this.getInitTempDebuff()
this.temp_ally_debuff = this.getInitTempDebuff()
this.temp_enemy_debuff = this.getInitTempDebuff()
this.temp_friend_debuff = this.getInitTempDebuff()
this.temp_enemy_debuff = this.getInitTempDebuff()
}
update(deltaTime: number) {

View File

@@ -50,12 +50,12 @@ export class Skill extends ecs.Entity {
skillComp.ap = caster.ap+dmg;
if(caster.fac==0){
if(caster.is_master){
skillComp.ap=Math.floor(skillComp.ap*(100+FIGHTCON.hero.ATK+FIGHTCON.ally.ATK)/100);
skillComp.ap=Math.floor(skillComp.ap*(100+FIGHTCON.hero_buff.ATK)/100);
}else{
skillComp.ap=Math.floor(skillComp.ap*(100+FIGHTCON.friend.ATK+FIGHTCON.ally.ATK)/100);
skillComp.ap=Math.floor(skillComp.ap*(100+FIGHTCON.friend_buff.ATK)/100);
}
}else{
skillComp.ap=Math.floor(skillComp.ap*(100-FIGHTCON.enemy.ATK)/100);
skillComp.ap=Math.floor(skillComp.ap*(100-FIGHTCON.enemy_buff.ATK)/100);
}
skillComp.s_uuid = uuid;
skillComp.animType = config.AnimType;

View File

@@ -118,7 +118,7 @@ export class SkillCom extends CCComp {
if(target == null) return;
let remainingDamage = this.ap;
if(target.fac == BoxSet.HERO ){
remainingDamage=remainingDamage*(100-this.FIGHTCON.hero.DEF+this.FIGHTCON.hero_debuff.BURN)/100
remainingDamage=remainingDamage*(100-this.FIGHTCON.hero_buff.DEF+this.FIGHTCON.hero_debuff.BURN)/100
}
target.do_atked(remainingDamage)
this.ent.destroy()