继续完善 装备buff

This commit is contained in:
2025-06-12 16:24:23 +08:00
parent 4c0d1023a0
commit cb38aa55a4
12 changed files with 227 additions and 190 deletions

View File

@@ -2,7 +2,8 @@ import { _decorator, Component, Node, resources, Sprite, SpriteAtlas } from 'cc'
import { oops } from 'db://oops-framework/core/Oops';
import { GameEvent } from '../common/config/GameEvent';
import { smc } from '../common/SingletonModuleComp';
import { EquipInfo, EquipType, EquipAttr, EquipAttrTarget } from '../common/config/Equips';
import { EquipInfo, EquipType, EquipAttrTarget} from '../common/config/Equips';
import { BuffAttr, getBuffNum } from '../common/config/SkillSet';
const { ccclass, property } = _decorator;
@ccclass('EquipsComp')
@@ -15,50 +16,10 @@ export class EquipsComp extends Component {
skill3:any=null
boxs:Node=null
attrs:any={
hero:{
ATK:0, // 攻击力
ATK_COUNT:0, // 攻击个数
ATK_CD:0, // 攻击速度
HP:0, // 生命值
DEF:0, // 免伤
SKILL_DMG:0, // 技能效果
SKILL_CD:0, // 技能冷却缩减
CARD_EFFECT:0, // 卡牌效果
CARD_COUNT:0, // 卡牌起效次数,每3次多起效一次
},
ally:{
ATK:0, // 攻击力
ATK_COUNT:0, // 攻击个数
ATK_CD:0, // 攻击速度
HP:0, // 生命值
DEF:0, // 免伤
SKILL_DMG:0, // 技能效果
SKILL_CD:0, // 技能冷却缩减
CARD_EFFECT:0, // 卡牌效果
CARD_COUNT:0, // 卡牌起效次数,每3次多起效一次
},
enemy:{
ATK:0, // 攻击力
ATK_COUNT:0, // 攻击个数
ATK_CD:0, // 攻击速度
HP:0, // 生命值
DEF:0, // 免伤
SKILL_DMG:0, // 技能效果
SKILL_CD:0, // 技能冷却缩减
CARD_EFFECT:0, // 卡牌效果
CARD_COUNT:0, // 卡牌起效次数,每3次多起效一次
},
friend:{
ATK:0, // 攻击力
ATK_COUNT:0, // 攻击个数
ATK_CD:0, // 攻击速度
HP:0, // 生命值
DEF:0, // 免伤
SKILL_DMG:0, // 技能效果
SKILL_CD:0, // 技能冷却缩减
CARD_EFFECT:0, // 卡牌效果
CARD_COUNT:0, // 卡牌起效次数,每3次多起效一次
}
hero:getBuffNum(),
ally:getBuffNum(),
enemy:getBuffNum(),
friend:getBuffNum(),
}
/** 视图层逻辑代码分离演示 */
onLoad() {
@@ -166,31 +127,31 @@ export class EquipsComp extends Component {
if (targetKey) {
switch (attr.type) {
case EquipAttr.ATK:
case BuffAttr.ATK:
this.attrs[targetKey].ATK += attr.value;
break;
case EquipAttr.ATK_COUNT:
case BuffAttr.ATK_COUNT:
this.attrs[targetKey].ATK_COUNT += attr.value;
break;
case EquipAttr.ATK_CD:
case BuffAttr.ATK_CD:
this.attrs[targetKey].ATK_CD += attr.value;
break;
case EquipAttr.HP:
case BuffAttr.HP:
this.attrs[targetKey].HP += attr.value;
break;
case EquipAttr.DEF:
case BuffAttr.DEF:
this.attrs[targetKey].DEF += attr.value;
break;
case EquipAttr.SKILL_DMG:
case BuffAttr.SKILL_DMG:
this.attrs[targetKey].SKILL_DMG += attr.value;
break;
case EquipAttr.SKILL_CD:
case BuffAttr.SKILL_CD:
this.attrs[targetKey].SKILL_CD += attr.value;
break;
case EquipAttr.CARD_EFFECT:
case BuffAttr.CARD_EFFECT:
this.attrs[targetKey].CARD_EFFECT += attr.value;
break;
case EquipAttr.CARD_COUNT:
case BuffAttr.CARD_COUNT:
this.attrs[targetKey].CARD_COUNT += attr.value;
break;
}
@@ -202,11 +163,7 @@ export class EquipsComp extends Component {
// 重置所有属性为0
private reset_attrs() {
Object.keys(this.attrs).forEach(key => {
Object.keys(this.attrs[key]).forEach(attrKey => {
this.attrs[key][attrKey] = 0;
});
});
this.attrs.hero=this.attrs.ally=this.attrs.enemy=this.attrs.friend=getBuffNum()
}
// 根据目标类型获取对应的key

View File

@@ -1,84 +1,108 @@
import { _decorator, Component, Node } from 'cc';
import { oops } from 'db://oops-framework/core/Oops';
import { GameEvent } from '../common/config/GameEvent';
import { geDebuffNum, getBuffNum, BuffAttr, DebuffAttr } from '../common/config/SkillSet';
const { ccclass, property } = _decorator;
@ccclass('FightConComp')
export class FightConComp extends Component {
hero:{
ATK:0, // 攻击力
ATK_COUNT:0, // 攻击个数
ATK_CD:0, // 攻击速度
HP:0, // 生命值
DEF:0, // 免伤
SKILL_DMG:0, // 技能效果
SKILL_CD:0, // 技能冷却缩减
CARD_EFFECT:0, // 卡牌效果
CARD_COUNT:0, // 卡牌起效次数,每3次多起效一次
}
ally:{
ATK:0, // 攻击力
ATK_COUNT:0, // 攻击个数
ATK_CD:0, // 攻击速度
HP:0, // 生命值
DEF:0, // 免伤
SKILL_DMG:0, // 技能效果
SKILL_CD:0, // 技能冷却缩减
CARD_EFFECT:0, // 卡牌效果
CARD_COUNT:0, // 卡牌起效次数,每3次多起效一次
}
enemy:{
ATK:0, // 攻击力
ATK_COUNT:0, // 攻击个数
ATK_CD:0, // 攻击速度
HP:0, // 生命值
DEF:0, // 免伤
SKILL_DMG:0, // 技能效果
SKILL_CD:0, // 技能冷却缩减
CARD_EFFECT:0, // 卡牌效果
CARD_COUNT:0, // 卡牌起效次数,每3次多起效一次
}
friend:{
ATK:0, // 攻击力
ATK_COUNT:0, // 攻击个数
ATK_CD:0, // 攻击速度
HP:0, // 生命值
DEF:0, // 免伤
SKILL_DMG:0, // 技能效果
SKILL_CD:0, // 技能冷却缩减
CARD_EFFECT:0, // 卡牌效果
CARD_COUNT:0, // 卡牌起效次数,每3次多起效一次
}
hero=getBuffNum()
ally=getBuffNum()
enemy=getBuffNum()
friend=getBuffNum()
hero_debuff=geDebuffNum()
ally_debuff=geDebuffNum()
enemy_debuff=geDebuffNum()
friend_debuff=geDebuffNum()
//注意临时buff和debuff 每种buff的值 必须都一样 多种值 战斗处理复杂 暂时放弃
temp_hero_buff = this.getInitTempDebuff();
temp_ally_buff = this.getInitTempDebuff();
temp_enemy_buff = this.getInitTempDebuff();
temp_friend_buff = this.getInitTempDebuff();
temp_hero_debuff = this.getInitTempBuffDebuff();
temp_ally_debuff = this.getInitTempBuffDebuff();
temp_enemy_debuff = this.getInitTempBuffDebuff();
temp_friend_debuff = this.getInitTempBuffDebuff();
onLoad(){
// console.log("fight con start")
oops.message.on(GameEvent.EquipChange,this.equip_change,this)
oops.message.on(GameEvent.FightReady,this.fight_ready,this)
}
equip_change(e:GameEvent,equip:any){
private equip_change(e:GameEvent,equip:any){
this.hero=equip.hero
this.ally=equip.ally
this.enemy=equip.enemy
this.friend=equip.friend
}
fight_ready(e:GameEvent){
this.hero=this.ally=this.enemy=this.friend={
ATK:0, // 攻击力
ATK_COUNT:0, // 攻击个数
ATK_CD:0, // 攻击速度
HP:0, // 生命值
DEF:0, // 免伤
SKILL_DMG:0, // 技能效果
SKILL_CD:0, // 技能冷却缩减
CARD_EFFECT:0, // 卡牌效果
CARD_COUNT:0, // 卡牌起效次数,每3次多起效一次
private fight_ready(e:GameEvent){
this.hero=this.ally=this.enemy=this.friend=getBuffNum()
this.hero_debuff=this.ally_debuff=this.enemy_debuff=this.friend_debuff=geDebuffNum()
this.clearAllTempBuffs()
// console.log("临时英雄buff:",this.temp_hero_buff)
// console.log("临时英雄debuff:",this.temp_hero_debuff)
// console.log("临时全部buff:",this.temp_ally_buff)
// console.log("临时全部debuff:",this.temp_ally_debuff)
// console.log("临时敌方buff:",this.temp_enemy_buff)
// console.log("临时敌方debuff:",this.temp_enemy_debuff)
// console.log("临时友军buff:",this.temp_friend_buff)
// console.log("临时友军debuff:",this.temp_friend_debuff)
}
// 添加临时buff
addTempBuff(target: 'hero'|'ally'|'enemy'|'friend', buffId: number, value: number, count: number) {
const key = `temp_${target}_buff`;
if (!this[key][buffId]) {
this[key][buffId] = { value, count };
} else {
this[key][buffId].value += value;
this[key][buffId].count += count;
}
}
// 触发一次buff效果后减少次数
triggerTempBuff(target: 'hero'|'ally'|'enemy'|'friend', buffId: number) {
const key = `temp_${target}_buff`;
if (this[key][buffId]) {
this[key][buffId].count -= 1;
if (this[key][buffId].count <= 0) {
delete this[key][buffId];
}
}
}
// 初始化所有buff/debuff为0
private getInitTempBuffDebuff() {
const obj = {};
for (const key in BuffAttr) {
if (!isNaN(Number(key))) {
obj[Number(key)] = { value: 0, count: 0 };
}
}
return obj;
}
private getInitTempDebuff() {
const obj = {};
for (const key in DebuffAttr) {
if (!isNaN(Number(key))) {
obj[Number(key)] = { value: 0, count: 0 };
}
}
return obj;
}
private clearAllTempBuffs() {
this.temp_hero_buff = this.temp_ally_buff = this.temp_enemy_buff = this.temp_friend_buff = this.getInitTempBuffDebuff();
this.temp_hero_debuff = this.temp_ally_debuff = this.temp_enemy_debuff = this.temp_friend_debuff = this.getInitTempDebuff();
}
update(deltaTime: number) {
}
}