Compare commits
2 Commits
94d5aa8920
...
oh/1017
| Author | SHA1 | Date | |
|---|---|---|---|
| e36abeb380 | |||
| 6386d6bd80 |
@@ -111,6 +111,7 @@ export enum DBuff {
|
||||
DODGE = 12, //-闪避 - 对应Attrs.DODGE (闪避), BType.RATIO
|
||||
DBUFFUP=13, //edbuff效果提升
|
||||
BUFF_DOWN = 14,// buff效果减弱
|
||||
SPEED = 15, //移动速度下降 - 对应Attrs.MOVE_SPEED (移动速度), BType.RATIO
|
||||
}
|
||||
|
||||
|
||||
@@ -142,6 +143,7 @@ export enum Attrs {
|
||||
BUFF_UP = 24, //buff效果提升
|
||||
DBUFF_UP=25, //debuff效果提升
|
||||
DIS=26, //攻击距离
|
||||
SPEED = 27, //移动速度加成,默认都是百分比
|
||||
}
|
||||
|
||||
export const getAttrs=()=>{
|
||||
@@ -172,9 +174,7 @@ export const getAttrFieldFromDebuff = (debuffType: DBuff): number => {
|
||||
// 状态类 debuff(只需缓存,不影响属性)
|
||||
const stateDebuffSet = new Set<DBuff>([
|
||||
DBuff.STUN,
|
||||
DBuff.SLOW,
|
||||
DBuff.FROST,
|
||||
DBuff.BURN,
|
||||
]);
|
||||
|
||||
// 检查是否是状态类 debuff
|
||||
@@ -200,6 +200,8 @@ export const getAttrFieldFromDebuff = (debuffType: DBuff): number => {
|
||||
[DBuff.DODGE]: Attrs.DODGE, // -闪避 -> 闪避
|
||||
[DBuff.DBUFFUP]: Attrs.DBUFF_UP, // debuff提升 -> debuff提升
|
||||
[DBuff.BUFF_DOWN]: Attrs.BUFF_UP, // buff减弱 -> buff效果
|
||||
[DBuff.SPEED]: Attrs.SPEED, // 移动速度下降 -> 移动速度
|
||||
|
||||
};
|
||||
|
||||
const attrField = debuffAttrMap[debuffType];
|
||||
@@ -287,9 +289,9 @@ export const HeroSkillList = [6001,6001,6001,6001,6001,6001]
|
||||
export interface DbuffConf {
|
||||
debuff: DBuff; // debuff类型
|
||||
BType:BType //buff是数值型还是百分比型
|
||||
dev: number; // 效果值 (原deV)
|
||||
deV: number; // 效果值
|
||||
deC: number; // 持续时间
|
||||
deR: number; // 触发概率 (原deR)
|
||||
deR: number; // 触发概率
|
||||
}
|
||||
export interface BuffConf {
|
||||
buff:Attrs;
|
||||
|
||||
@@ -91,8 +91,10 @@ export class BattleMoveSystem extends ecs.ComblockSystem implements ecs.ISystemU
|
||||
// 如果不在目标位置,移动到目标位置
|
||||
if (Math.abs(currentX - finalTargetX) > 1) {
|
||||
// 确定移动方向
|
||||
let B_SPEED=view.R_BUFFS[Attrs.SPEED]?view.R_BUFFS[Attrs.SPEED]:0;
|
||||
let D_SPEED=view.R_DBUFFS[Attrs.SPEED]?view.R_DBUFFS[Attrs.SPEED]:0;
|
||||
const direction = currentX > finalTargetX ? -1 : 1;
|
||||
const delta = ((view.speed-view.DEBUFF_SLOW)/3) * this.dt * direction;
|
||||
const delta = ((view.speed*(100+B_SPEED+D_SPEED))/3) * this.dt * direction;
|
||||
const newX = view.node.position.x + delta;
|
||||
|
||||
// 设置朝向
|
||||
|
||||
@@ -40,7 +40,7 @@ const { ccclass, property } = _decorator;
|
||||
* const dbuffConf: DbuffConf = {
|
||||
* debuff: DBuff.STUN, // 眩晕
|
||||
* BType: BType.VALUE, // 数值型
|
||||
* dev: 20, // 减少值
|
||||
* deV: 20, // 减少值
|
||||
* deC: 3, // 持续3秒
|
||||
* deR: 100 // 触发概率(100%)
|
||||
* };
|
||||
@@ -107,18 +107,17 @@ export class HeroViewComp extends CCComp {
|
||||
base_mp: number = 100;
|
||||
|
||||
Attrs:any=[]
|
||||
//数值型debuff
|
||||
V_DBUFF:any[]=[] //持久
|
||||
V_DBUFFS:any[]=[] //临时 带时间
|
||||
//百分比型debuff
|
||||
R_DBUFF:any[]=[] //持久
|
||||
R_DBUFFS:any[]=[] //临时 带时间
|
||||
//数值型buff
|
||||
V_BUFF:any[]=[] //持久
|
||||
V_BUFFS:any[]=[] //临时 带时间
|
||||
//百分比型buff
|
||||
R_BUFF:any[]=[] //持久
|
||||
R_BUFFS:any[]=[] //临时 带时间
|
||||
//数值型debuff - 改为键值对形式,可通过 V_DBUFF[Attrs.HP_MAX] 直接访问
|
||||
V_DBUFF:Record<number, any> = {} //持久
|
||||
R_DBUFF:Record<number, any> = {} //持久
|
||||
V_BUFF:Record<number, any> = {} //持久
|
||||
R_BUFF:Record<number, any> = {} //持久
|
||||
|
||||
|
||||
V_DBUFFS:Record<number, any> = {} //临时 带时间
|
||||
R_DBUFFS:Record<number, any> = {} //临时 带时间
|
||||
V_BUFFS:Record<number, any> = {} //临时 带时间
|
||||
R_BUFFS:Record<number, any> = {} //临时 带时间
|
||||
|
||||
atk_count: number = 0;
|
||||
atked_count: number = 0;
|
||||
@@ -173,14 +172,14 @@ export class HeroViewComp extends CCComp {
|
||||
if (!heroInfo) return;
|
||||
|
||||
// 清空现有 buff/debuff
|
||||
this.V_BUFF = [];
|
||||
this.V_BUFFS = [];
|
||||
this.R_BUFF = [];
|
||||
this.R_BUFFS = [];
|
||||
this.V_DBUFF = [];
|
||||
this.V_DBUFFS = [];
|
||||
this.R_DBUFF = [];
|
||||
this.R_DBUFFS = [];
|
||||
this.V_BUFF = {};
|
||||
this.V_BUFFS = {};
|
||||
this.R_BUFF = {};
|
||||
this.R_BUFFS = {};
|
||||
this.V_DBUFF = {};
|
||||
this.V_DBUFFS = {};
|
||||
this.R_DBUFF = {};
|
||||
this.R_DBUFFS = {};
|
||||
|
||||
// 加载初始 buff
|
||||
if (heroInfo.buff && heroInfo.buff.length > 0) {
|
||||
@@ -206,30 +205,50 @@ export class HeroViewComp extends CCComp {
|
||||
* @param buffConf buff 配置 (来自 SkillSet.BuffConf 或 heroSet.buff)
|
||||
*/
|
||||
addBuff(buffConf: BuffConf) {
|
||||
// 基于类型和持续时间分类存储
|
||||
// 基于类型和持续时间分类存储,使用属性作为键
|
||||
const attrKey = buffConf.buff;
|
||||
|
||||
if (buffConf.BType === BType.VALUE) {
|
||||
// 数值型 buff
|
||||
if (buffConf.buC === 0) {
|
||||
// 持久型
|
||||
this.V_BUFF.push({...buffConf});
|
||||
// 持久型 - 如果已存在,累加数值
|
||||
if (this.V_BUFF[attrKey]) {
|
||||
this.V_BUFF[attrKey].buV += buffConf.buV;
|
||||
} else {
|
||||
this.V_BUFF[attrKey] = {...buffConf};
|
||||
}
|
||||
} else {
|
||||
// 临时型 - 添加剩余时间属性
|
||||
this.V_BUFFS.push({
|
||||
...buffConf,
|
||||
remainTime: buffConf.buC
|
||||
});
|
||||
// 临时型 - 如果已存在,累加数值并重置时间
|
||||
if (this.V_BUFFS[attrKey]) {
|
||||
this.V_BUFFS[attrKey].buV += buffConf.buV;
|
||||
this.V_BUFFS[attrKey].remainTime = Math.max(this.V_BUFFS[attrKey].remainTime, buffConf.buC);
|
||||
} else {
|
||||
this.V_BUFFS[attrKey] = {
|
||||
...buffConf,
|
||||
remainTime: buffConf.buC
|
||||
};
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// 百分比型 buff
|
||||
if (buffConf.buC === 0) {
|
||||
// 持久型
|
||||
this.R_BUFF.push({...buffConf});
|
||||
// 持久型 - 如果已存在,累加百分比
|
||||
if (this.R_BUFF[attrKey]) {
|
||||
this.R_BUFF[attrKey].buV += buffConf.buV;
|
||||
} else {
|
||||
this.R_BUFF[attrKey] = {...buffConf};
|
||||
}
|
||||
} else {
|
||||
// 临时型 - 添加剩余时间属性
|
||||
this.R_BUFFS.push({
|
||||
...buffConf,
|
||||
remainTime: buffConf.buC
|
||||
});
|
||||
// 临时型 - 如果已存在,累加百分比并重置时间
|
||||
if (this.R_BUFFS[attrKey]) {
|
||||
this.R_BUFFS[attrKey].buV += buffConf.buV;
|
||||
this.R_BUFFS[attrKey].remainTime = Math.max(this.R_BUFFS[attrKey].remainTime, buffConf.buC);
|
||||
} else {
|
||||
this.R_BUFFS[attrKey] = {
|
||||
...buffConf,
|
||||
remainTime: buffConf.buC
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
// 立即重新计算属性
|
||||
@@ -250,39 +269,60 @@ export class HeroViewComp extends CCComp {
|
||||
// attrField = -1 表示状态类 debuff(只缓存,不修改属性)
|
||||
// attrField >= 0 表示属性类 debuff(会修改属性)
|
||||
const attrField = getAttrFieldFromDebuff(dbuffConf.debuff);
|
||||
|
||||
// 使用 debuff 类型作为键(支持状态类 debuff,attrField = -1)
|
||||
const debuffKey = dbuffConf.debuff;
|
||||
|
||||
// 基于类型和持续时间分类存储
|
||||
if (dbuffConf.BType === BType.VALUE) {
|
||||
// 数值型 debuff
|
||||
if (dbuffConf.deC === 0) {
|
||||
// 持久型
|
||||
this.V_DBUFF.push({
|
||||
...dbuffConf,
|
||||
attrField: attrField
|
||||
});
|
||||
// 持久型 - 如果已存在,累加数值
|
||||
if (this.V_DBUFF[debuffKey]) {
|
||||
this.V_DBUFF[debuffKey].deV += dbuffConf.deV;
|
||||
} else {
|
||||
this.V_DBUFF[debuffKey] = {
|
||||
...dbuffConf,
|
||||
attrField: attrField
|
||||
};
|
||||
}
|
||||
} else {
|
||||
// 临时型 - 添加剩余时间属性
|
||||
this.V_DBUFFS.push({
|
||||
...dbuffConf,
|
||||
attrField: attrField,
|
||||
remainTime: dbuffConf.deC
|
||||
});
|
||||
// 临时型 - 如果已存在,累加数值并重置时间
|
||||
if (this.V_DBUFFS[debuffKey]) {
|
||||
this.V_DBUFFS[debuffKey].deV += dbuffConf.deV;
|
||||
this.V_DBUFFS[debuffKey].remainTime = Math.max(this.V_DBUFFS[debuffKey].remainTime, dbuffConf.deC);
|
||||
} else {
|
||||
this.V_DBUFFS[debuffKey] = {
|
||||
...dbuffConf,
|
||||
attrField: attrField,
|
||||
remainTime: dbuffConf.deC
|
||||
};
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// 百分比型 debuff
|
||||
if (dbuffConf.deC === 0) {
|
||||
// 持久型
|
||||
this.R_DBUFF.push({
|
||||
...dbuffConf,
|
||||
attrField: attrField
|
||||
});
|
||||
// 持久型 - 如果已存在,累加百分比
|
||||
if (this.R_DBUFF[debuffKey]) {
|
||||
this.R_DBUFF[debuffKey].deV += dbuffConf.deV;
|
||||
} else {
|
||||
this.R_DBUFF[debuffKey] = {
|
||||
...dbuffConf,
|
||||
attrField: attrField
|
||||
};
|
||||
}
|
||||
} else {
|
||||
// 临时型 - 添加剩余时间属性
|
||||
this.R_DBUFFS.push({
|
||||
...dbuffConf,
|
||||
attrField: attrField,
|
||||
remainTime: dbuffConf.deC
|
||||
});
|
||||
// 临时型 - 如果已存在,累加百分比并重置时间
|
||||
if (this.R_DBUFFS[debuffKey]) {
|
||||
this.R_DBUFFS[debuffKey].deV += dbuffConf.deV;
|
||||
this.R_DBUFFS[debuffKey].remainTime = Math.max(this.R_DBUFFS[debuffKey].remainTime, dbuffConf.deC);
|
||||
} else {
|
||||
this.R_DBUFFS[debuffKey] = {
|
||||
...dbuffConf,
|
||||
attrField: attrField,
|
||||
remainTime: dbuffConf.deC
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
// 立即重新计算属性
|
||||
@@ -334,14 +374,16 @@ export class HeroViewComp extends CCComp {
|
||||
*/
|
||||
private applyValueBuffs() {
|
||||
// 持久型 buff
|
||||
for (const buff of this.V_BUFF) {
|
||||
for (const attrKey in this.V_BUFF) {
|
||||
const buff = this.V_BUFF[attrKey];
|
||||
if (buff.buff !== undefined) {
|
||||
this.Attrs[buff.buff] += buff.buV;
|
||||
}
|
||||
}
|
||||
|
||||
// 临时型 buff
|
||||
for (const buff of this.V_BUFFS) {
|
||||
for (const attrKey in this.V_BUFFS) {
|
||||
const buff = this.V_BUFFS[attrKey];
|
||||
if (buff.buff !== undefined) {
|
||||
this.Attrs[buff.buff] += buff.buV;
|
||||
}
|
||||
@@ -362,7 +404,8 @@ export class HeroViewComp extends CCComp {
|
||||
baseValues[Attrs.MAP] = this.base_map;
|
||||
|
||||
// 持久型 buff
|
||||
for (const buff of this.R_BUFF) {
|
||||
for (const attrKey in this.R_BUFF) {
|
||||
const buff = this.R_BUFF[attrKey];
|
||||
if (buff.buff !== undefined) {
|
||||
const baseVal = baseValues[buff.buff] || this.Attrs[buff.buff];
|
||||
this.Attrs[buff.buff] += Math.floor(baseVal * (buff.buV / 100));
|
||||
@@ -370,7 +413,8 @@ export class HeroViewComp extends CCComp {
|
||||
}
|
||||
|
||||
// 临时型 buff
|
||||
for (const buff of this.R_BUFFS) {
|
||||
for (const attrKey in this.R_BUFFS) {
|
||||
const buff = this.R_BUFFS[attrKey];
|
||||
if (buff.buff !== undefined) {
|
||||
const baseVal = baseValues[buff.buff] || this.Attrs[buff.buff];
|
||||
this.Attrs[buff.buff] += Math.floor(baseVal * (buff.buV / 100));
|
||||
@@ -383,18 +427,20 @@ export class HeroViewComp extends CCComp {
|
||||
*/
|
||||
private applyValueDebuffs() {
|
||||
// 持久型 debuff
|
||||
for (const debuff of this.V_DBUFF) {
|
||||
for (const debuffKey in this.V_DBUFF) {
|
||||
const debuff = this.V_DBUFF[debuffKey];
|
||||
// 跳过状态类 debuff(attrField === -1)
|
||||
if (debuff.attrField !== undefined && debuff.attrField >= 0) {
|
||||
this.Attrs[debuff.attrField] -= debuff.dev;
|
||||
this.Attrs[debuff.attrField] -= debuff.deV;
|
||||
}
|
||||
}
|
||||
|
||||
// 临时型 debuff
|
||||
for (const debuff of this.V_DBUFFS) {
|
||||
for (const debuffKey in this.V_DBUFFS) {
|
||||
const debuff = this.V_DBUFFS[debuffKey];
|
||||
// 跳过状态类 debuff(attrField === -1)
|
||||
if (debuff.attrField !== undefined && debuff.attrField >= 0) {
|
||||
this.Attrs[debuff.attrField] -= debuff.dev;
|
||||
this.Attrs[debuff.attrField] -= debuff.deV;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -413,20 +459,22 @@ export class HeroViewComp extends CCComp {
|
||||
baseValues[Attrs.MAP] = this.base_map;
|
||||
|
||||
// 持久型 debuff
|
||||
for (const debuff of this.R_DBUFF) {
|
||||
for (const debuffKey in this.R_DBUFF) {
|
||||
const debuff = this.R_DBUFF[debuffKey];
|
||||
// 跳过状态类 debuff(attrField === -1)
|
||||
if (debuff.attrField !== undefined && debuff.attrField >= 0) {
|
||||
const baseVal = baseValues[debuff.attrField] || this.Attrs[debuff.attrField];
|
||||
this.Attrs[debuff.attrField] -= Math.floor(baseVal * (debuff.dev / 100));
|
||||
this.Attrs[debuff.attrField] -= Math.floor(baseVal * (debuff.deV / 100));
|
||||
}
|
||||
}
|
||||
|
||||
// 临时型 debuff
|
||||
for (const debuff of this.R_DBUFFS) {
|
||||
for (const debuffKey in this.R_DBUFFS) {
|
||||
const debuff = this.R_DBUFFS[debuffKey];
|
||||
// 跳过状态类 debuff(attrField === -1)
|
||||
if (debuff.attrField !== undefined && debuff.attrField >= 0) {
|
||||
const baseVal = baseValues[debuff.attrField] || this.Attrs[debuff.attrField];
|
||||
this.Attrs[debuff.attrField] -= Math.floor(baseVal * (debuff.dev / 100));
|
||||
this.Attrs[debuff.attrField] -= Math.floor(baseVal * (debuff.deV / 100));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -461,37 +509,37 @@ export class HeroViewComp extends CCComp {
|
||||
let needRecalculate = false;
|
||||
|
||||
// 更新临时型数值 buff
|
||||
for (let i = this.V_BUFFS.length - 1; i >= 0; i--) {
|
||||
this.V_BUFFS[i].remainTime -= dt;
|
||||
if (this.V_BUFFS[i].remainTime <= 0) {
|
||||
this.V_BUFFS.splice(i, 1);
|
||||
for (const attrKey in this.V_BUFFS) {
|
||||
this.V_BUFFS[attrKey].remainTime -= dt;
|
||||
if (this.V_BUFFS[attrKey].remainTime <= 0) {
|
||||
delete this.V_BUFFS[attrKey];
|
||||
needRecalculate = true;
|
||||
}
|
||||
}
|
||||
|
||||
// 更新临时型百分比 buff
|
||||
for (let i = this.R_BUFFS.length - 1; i >= 0; i--) {
|
||||
this.R_BUFFS[i].remainTime -= dt;
|
||||
if (this.R_BUFFS[i].remainTime <= 0) {
|
||||
this.R_BUFFS.splice(i, 1);
|
||||
for (const attrKey in this.R_BUFFS) {
|
||||
this.R_BUFFS[attrKey].remainTime -= dt;
|
||||
if (this.R_BUFFS[attrKey].remainTime <= 0) {
|
||||
delete this.R_BUFFS[attrKey];
|
||||
needRecalculate = true;
|
||||
}
|
||||
}
|
||||
|
||||
// 更新临时型数值 debuff
|
||||
for (let i = this.V_DBUFFS.length - 1; i >= 0; i--) {
|
||||
this.V_DBUFFS[i].remainTime -= dt;
|
||||
if (this.V_DBUFFS[i].remainTime <= 0) {
|
||||
this.V_DBUFFS.splice(i, 1);
|
||||
for (const debuffKey in this.V_DBUFFS) {
|
||||
this.V_DBUFFS[debuffKey].remainTime -= dt;
|
||||
if (this.V_DBUFFS[debuffKey].remainTime <= 0) {
|
||||
delete this.V_DBUFFS[debuffKey];
|
||||
needRecalculate = true;
|
||||
}
|
||||
}
|
||||
|
||||
// 更新临时型百分比 debuff
|
||||
for (let i = this.R_DBUFFS.length - 1; i >= 0; i--) {
|
||||
this.R_DBUFFS[i].remainTime -= dt;
|
||||
if (this.R_DBUFFS[i].remainTime <= 0) {
|
||||
this.R_DBUFFS.splice(i, 1);
|
||||
for (const debuffKey in this.R_DBUFFS) {
|
||||
this.R_DBUFFS[debuffKey].remainTime -= dt;
|
||||
if (this.R_DBUFFS[debuffKey].remainTime <= 0) {
|
||||
delete this.R_DBUFFS[debuffKey];
|
||||
needRecalculate = true;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user