信息展示 继续

This commit is contained in:
2025-06-25 17:00:43 +08:00
parent 75136d665b
commit db0a0dd19c
12 changed files with 6500 additions and 5891 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -42,14 +42,15 @@ export class SingletonModuleComp extends ecs.Comp {
hero:{ hero:{
hp:0, hp:0,
hp_max:0, hp_max:0,
hp_buff:0,
cd:3, cd:3,
damage:9999, damage:0,
ap:9999, ap:0,
equip_ap:9999, equip_ap:0,
buff_ap:9999, buff_ap:0,
debuff_ap:9999, debuff_ap:0,
def:9999, def:0,
crit:9999, crit:0,
crit_d:99, crit_d:99,
dod:99, dod:99,
dod_no:false, dod_no:false,
@@ -58,34 +59,36 @@ export class SingletonModuleComp extends ecs.Comp {
friend:{ friend:{
hp:0, hp:0,
hp_max:0, hp_max:0,
hp_buff:0,
cd:3, cd:3,
t_ap:0, damage:0,
ap:0, ap:0,
def:0,
crit:0,
crit_d:0,
dod:0,
dod_no:false,
crit_no:false,
equip_ap:0, equip_ap:0,
buff_ap:0, buff_ap:0,
debuff_ap:0, debuff_ap:0,
def:0,
crit:0,
crit_d:99,
dod:99,
dod_no:false,
crit_no:false,
}, },
boss:{ boss:{
hp:0, hp:0,
hp_max:0, hp_max:0,
hp_buff:0,
cd:3, cd:3,
t_ap:0, damage:0,
ap:0, ap:0,
def:0,
crit:0,
crit_d:0,
dod:0,
dod_no:false,
crit_no:false,
equip_ap:0, equip_ap:0,
buff_ap:0, buff_ap:0,
debuff_ap:0, debuff_ap:0,
def:0,
crit:0,
crit_d:99,
dod:99,
dod_no:false,
crit_no:false,
}, },
}; };
vmAdd() { vmAdd() {

View File

@@ -75,7 +75,6 @@ export interface EquipData {
info: string; // 装备描述 info: string; // 装备描述
special_attr: EquipSpecialAttrData[]; // 特殊属性数组 special_attr: EquipSpecialAttrData[]; // 特殊属性数组
buff: EquipAttribute[]; // 属性加成列表 buff: EquipAttribute[]; // 属性加成列表
debuff: EquipDebuffAttribute[]; // 属性减益列表
} }
export const EquipInfo: { [key: number]: EquipData } = { export const EquipInfo: { [key: number]: EquipData } = {
2001: {uuid: 2001, name: "新手剑", type: EquipType.WEAPON,quality: Quality.WHITE,info:"攻击力增加80%", 2001: {uuid: 2001, name: "新手剑", type: EquipType.WEAPON,quality: Quality.WHITE,info:"攻击力增加80%",
@@ -93,9 +92,7 @@ export const EquipInfo: { [key: number]: EquipData } = {
{ type: BuffAttr.ATK, value: 80, target: EquipAttrTarget.HERO }, { type: BuffAttr.ATK, value: 80, target: EquipAttrTarget.HERO },
{ type: BuffAttr.ATK_COUNT, value: 30, target: EquipAttrTarget.HERO }, { type: BuffAttr.ATK_COUNT, value: 30, target: EquipAttrTarget.HERO },
], ],
debuff: [
{ type: DebuffAttr.DECD, value: 50, target: EquipAttrTarget.ENEMY },
]
}, },
2002: {uuid: 2002,name: "新手剑2",type: EquipType.WEAPON,quality: Quality.WHITE,info:"攻击速度增加30%", 2002: {uuid: 2002,name: "新手剑2",type: EquipType.WEAPON,quality: Quality.WHITE,info:"攻击速度增加30%",
special_attr:[ special_attr:[
@@ -112,9 +109,6 @@ export const EquipInfo: { [key: number]: EquipData } = {
{ type: BuffAttr.ATK_CD, value: 30, target: EquipAttrTarget.HERO }, { type: BuffAttr.ATK_CD, value: 30, target: EquipAttrTarget.HERO },
{ type: BuffAttr.ATK_COUNT, value: 30, target: EquipAttrTarget.HERO }, { type: BuffAttr.ATK_COUNT, value: 30, target: EquipAttrTarget.HERO },
], ],
debuff: [
{ type: DebuffAttr.DECD, value: 50, target: EquipAttrTarget.ENEMY },
]
}, },
2003: {uuid: 2003,name: "新手剑3",type: EquipType.WEAPON,quality: Quality.WHITE,info:"攻击次数增加1次", 2003: {uuid: 2003,name: "新手剑3",type: EquipType.WEAPON,quality: Quality.WHITE,info:"攻击次数增加1次",
special_attr:[ special_attr:[
@@ -129,10 +123,8 @@ export const EquipInfo: { [key: number]: EquipData } = {
], ],
buff: [ buff: [
{ type: BuffAttr.ATK_COUNT, value: 1, target: EquipAttrTarget.HERO }, { type: BuffAttr.ATK_COUNT, value: 1, target: EquipAttrTarget.HERO },
{ type: BuffAttr.HP, value: 30, target: EquipAttrTarget.HERO },
], ],
debuff: [
{ type: DebuffAttr.DECD, value: 50, target: EquipAttrTarget.ENEMY },
]
}, },
} }

View File

@@ -45,4 +45,6 @@ export enum GameEvent {
ChangeATK = "ChangeATK", ChangeATK = "ChangeATK",
ChangeATK_FRIEND_LIVE_CD = "ChangeATK_FRIEND_LIVE_CD", ChangeATK_FRIEND_LIVE_CD = "ChangeATK_FRIEND_LIVE_CD",
ChangeATK_EQUIP_SPECIAL_ATTR = "ChangeATK_EQUIP_SPECIAL_ATTR", ChangeATK_EQUIP_SPECIAL_ATTR = "ChangeATK_EQUIP_SPECIAL_ATTR",
UpdateVMData = "UpdateVMData",
UpdateHP = "UpdateHP",
} }

View File

@@ -90,6 +90,8 @@ export enum BuffAttr {
CRITICAL_NO = 11, //暴击免疫 CRITICAL_NO = 11, //暴击免疫
DODGE = 12, //闪避 DODGE = 12, //闪避
DODGE_NO = 13, //闪避免疫 DODGE_NO = 13, //闪避免疫
DEBUFF_COUNT = 14, //debuff次数
DEBUFF_VALUE = 15, //debuff效果
} }
export const geDebuffNum=()=>{ export const geDebuffNum=()=>{
@@ -124,6 +126,8 @@ export const getBuffNum=()=>{
CRITICAL_NO:0, //暴击免疫 CRITICAL_NO:0, //暴击免疫
DODGE:0, //闪避 DODGE:0, //闪避
DODGE_NO:0, //闪避免疫 DODGE_NO:0, //闪避免疫
DEBUFF_COUNT:0, //debuff次数
DEBUFF_VALUE:0, //debuff效果
} }
} }

View File

@@ -8,6 +8,7 @@ import { BuffGet } from '../skills/BuffGet';
import { HeroViewComp } from './HeroViewComp'; import { HeroViewComp } from './HeroViewComp';
import { FightConComp } from '../map/FightConComp'; import { FightConComp } from '../map/FightConComp';
import { BuffAttr, DebuffAttr } from '../common/config/SkillSet'; import { BuffAttr, DebuffAttr } from '../common/config/SkillSet';
import { GameEvent } from '../common/config/GameEvent';
const { ccclass, property } = _decorator; const { ccclass, property } = _decorator;
@ccclass('BuffComp') @ccclass('BuffComp')
@@ -35,6 +36,9 @@ export class BuffComp extends Component {
speek_time:number=0; speek_time:number=0;
HeroView:HeroViewComp=null! HeroView:HeroViewComp=null!
FIGHTCON:FightConComp=null! FIGHTCON:FightConComp=null!
protected onLoad(): void {
oops.message.on(GameEvent.UpdateVMData,this.to_update_vmdata,this)
}
start() { start() {
this.info_init() this.info_init()
} }
@@ -53,9 +57,11 @@ export class BuffComp extends Component {
this.top_node.getChildByName("ihp").active=false this.top_node.getChildByName("ihp").active=false
this.top_node.getChildByName("iap").active=false this.top_node.getChildByName("iap").active=false
this.vmdata_update(this.HeroView.VM_TYPE.ALL) this.vmdata_update()
}
to_update_vmdata(){
this.vmdata_update(false)
} }
update(deltaTime: number) { update(deltaTime: number) {
if(smc.mission.pause) return if(smc.mission.pause) return
this.hp_show() this.hp_show()
@@ -69,6 +75,7 @@ export class BuffComp extends Component {
this.node.getChildByName("buff").active = false; this.node.getChildByName("buff").active = false;
} }
this.in_speek(deltaTime) this.in_speek(deltaTime)
// this.vmdata_update()
} }
hp_show(){ hp_show(){
// if(this.node.getComponent(HeroViewComp).fac == 0) return // if(this.node.getComponent(HeroViewComp).fac == 0) return
@@ -83,47 +90,44 @@ export class BuffComp extends Component {
this.node.getChildByName("shielded").active=val this.node.getChildByName("shielded").active=val
} }
vmdata_update(data_type:string){ vmdata_update(is_hp:boolean=false){
let target_key=null console.log("[BuffComp]:vmdata_update",is_hp)
let buff_key=null let buff=null
if(this.HeroView.is_master) {target_key="hero";buff_key="hero"} let info= null
if(this.HeroView.is_friend) {target_key="friend";buff_key="friend"} if(!this.HeroView) return
if(this.HeroView.is_boss) {target_key="boss";buff_key="enemy"} if(this.HeroView.is_master) {info=smc.vmdata.hero;buff=this.FIGHTCON.hero_buff}
if(target_key==null) return if(this.HeroView.is_friend) {info=smc.vmdata.friend;buff=this.FIGHTCON.friend_buff}
if(this.HeroView.is_boss) {info=smc.vmdata.boss;buff=this.FIGHTCON.enemy_buff}
switch(data_type){ //if(this.HeroView.is_kalami) {target_key="enemy";buff_key="enemy"} 不显示小怪
case this.HeroView.VM_TYPE.ALL: if(info==null) return
smc.vmdata[target_key].hp=this.HeroView.hp
smc.vmdata[target_key].hp_max=this.HeroView.hp_max
smc.vmdata[target_key].ap=this.HeroView.ap
break
case this.HeroView.VM_TYPE.HP:
smc.vmdata[target_key].hp=this.HeroView.hp
smc.vmdata[target_key].hp_max=this.HeroView.hp_max
break
case this.HeroView.VM_TYPE.OTHER:
let view_atk = 0 //临时buff let view_atk = 0 //临时buff
let view_deatk = 0 //临时debuff
if(is_hp){
info.hp=this.HeroView.hp
info.hp_max=this.HeroView.hp_max*(100+buff.HP)/100
info.hp_buff=buff.HP
}else{
info.hp=this.HeroView.hp
info.hp_max=this.HeroView.hp_max*(100+buff.HP)/100
info.hp_buff=buff.HP
for(let i=0;i<this.HeroView.BUFF_ATKS.length;i++){ for(let i=0;i<this.HeroView.BUFF_ATKS.length;i++){
view_atk += this.HeroView.BUFF_ATKS[i].value view_atk += this.HeroView.BUFF_ATKS[i].value
} }
let view_deatk = 0 //临时debuff
for(let i=0;i<this.HeroView.DEBUFF_DEATKS.length;i++){ for(let i=0;i<this.HeroView.DEBUFF_DEATKS.length;i++){
view_deatk += this.HeroView.DEBUFF_DEATKS[i].value view_deatk += this.HeroView.DEBUFF_DEATKS[i].value
} }
info.ap=this.HeroView.ap
let buff=this.FIGHTCON[buff_key+"_buff"] info.equip_ap=buff.ATK
info.buff_ap=view_atk
info.debuff_ap=view_deatk
smc.vmdata[target_key].ap=this.HeroView.ap info.damage=this.HeroView.ap*(100+buff.ATK)/100*(100+view_atk-view_deatk)/100
smc.vmdata[target_key].equip_ap=buff.ATK info.crit=this.HeroView.crit+buff.CRITICAL
smc.vmdata[target_key].buff_ap=view_atk info.crit_d=this.HeroView.crit_d+buff.CRITICAL_DMG
smc.vmdata[target_key].debuff_ap=view_deatk info.dod=this.HeroView.dod+buff.DODGE
smc.vmdata[target_key].damage=this.HeroView.ap*(100+buff.ATK)/100*(100+view_atk-view_deatk)/100 info.def=this.HeroView.def+buff.DEF
break
} }
} }
update_info_hp(){ update_info_hp(){

View File

@@ -52,6 +52,7 @@ export class HeroViewComp extends CCComp {
hp_up:number=0; hp_up:number=0;
hp: number = 100; /** 血量 */ hp: number = 100; /** 血量 */
hp_max: number = 100; /** 最大血量 */ hp_max: number = 100; /** 最大血量 */
hp_buff:number=0;
hp_speed: number = 0; //每秒回复量 hp_speed: number = 0; //每秒回复量
pwt:Timer = new Timer(1); //计时器 pwt:Timer = new Timer(1); //计时器
@@ -90,16 +91,10 @@ export class HeroViewComp extends CCComp {
DEBUFF_BURNS: Array<{value: number, count: number}> = [] DEBUFF_BURNS: Array<{value: number, count: number}> = []
DEBUFF_DEATKS: Array<{value: number, count: number}> = [] DEBUFF_DEATKS: Array<{value: number, count: number}> = []
DEBUFF_DECDS: Array<{value: number, count: number}> = [] DEBUFF_DECDS: Array<{value: number, count: number}> = []
DEBUFF_SLOW: number = 0; DEBUFF_SLOW: number = 0;
DEBUFF_FROST: number = 0; DEBUFF_FROST: number = 0;
DEBUFF_STUN: number = 0; DEBUFF_STUN: number = 0;
VM_TYPE:any={
ALL:0,
HP:1,
OTHER:2,
}
private damageQueue: Array<{ private damageQueue: Array<{
damage: number, damage: number,
isCrit: boolean, isCrit: boolean,
@@ -115,7 +110,7 @@ export class HeroViewComp extends CCComp {
this.FIGHTCON=this.node.parent.getComponent(FightConComp); this.FIGHTCON=this.node.parent.getComponent(FightConComp);
console.log("[HeroViewComp]:hero view comp ",this.FIGHTCON) console.log("[HeroViewComp]:hero view comp ",this.FIGHTCON)
this.on(GameEvent.ChangeATK_EQUIP_SPECIAL_ATTR,this.change_atk,this) this.on(GameEvent.ChangeATK_EQUIP_SPECIAL_ATTR,this.change_atk,this)
this.on(GameEvent.UpdateHP,this.update_hp,this)
// let anm = this.node.getChildByName("anm") // let anm = this.node.getChildByName("anm")
// anm.setScale(anm.scale.x*0.8,anm.scale.y*0.8); // anm.setScale(anm.scale.x*0.8,anm.scale.y*0.8);
} }
@@ -226,7 +221,7 @@ export class HeroViewComp extends CCComp {
this.ap += Math.floor(ap/100*this.ap); this.ap += Math.floor(ap/100*this.ap);
} }
this.BUFFCOMP.update_info_ap() this.BUFFCOMP.update_info_ap()
this.BUFFCOMP.vmdata_update(this.VM_TYPE.OTHER) this.BUFFCOMP.vmdata_update()
} }
de_ap(ap: number,is_num:boolean=true){ de_ap(ap: number,is_num:boolean=true){
@@ -237,9 +232,20 @@ export class HeroViewComp extends CCComp {
this.ap -= Math.floor(ap/100*this.ap); this.ap -= Math.floor(ap/100*this.ap);
} }
this.BUFFCOMP.update_info_ap() this.BUFFCOMP.update_info_ap()
this.BUFFCOMP.vmdata_update(this.VM_TYPE.OTHER) this.BUFFCOMP.vmdata_update()
}
update_hp(e:GameEvent,data:any){
console.log("[HeroViewComp]:update_hp",data)
if(this.is_master===data.is_master&&this.fac===FacSet.HERO){
this.hp_buff += data.hp
if(data.hp > 0){
this.hp += this.hp_max*data.hp/100
if(this.hp > this.hp_max*(100+this.hp_buff/100)){
this.hp=this.hp_max*(100+this.hp_buff/100)
}
}
}
} }
add_hp_max(hp: number=0,is_num:boolean=true){ add_hp_max(hp: number=0,is_num:boolean=true){
console.log("[HeroViewComp]:add_hp_max add:",hp,this.hp_max) console.log("[HeroViewComp]:add_hp_max add:",hp,this.hp_max)
if(is_num){ if(is_num){
@@ -260,7 +266,7 @@ export class HeroViewComp extends CCComp {
this.hp_max -= Math.floor(hp/100*this.hp_max); this.hp_max -= Math.floor(hp/100*this.hp_max);
} }
this.BUFFCOMP.update_info_hp() this.BUFFCOMP.update_info_hp()
this.BUFFCOMP.vmdata_update(this.VM_TYPE.HP) this.BUFFCOMP.vmdata_update(true)
} }
add_hp(hp: number = 0,is_num:boolean=true) { add_hp(hp: number = 0,is_num:boolean=true) {
@@ -274,7 +280,7 @@ export class HeroViewComp extends CCComp {
this.hp = this.hp_max; this.hp = this.hp_max;
} }
this.BUFFCOMP.tooltip(2,hp.toFixed(0)); this.BUFFCOMP.tooltip(2,hp.toFixed(0));
this.BUFFCOMP.vmdata_update(this.VM_TYPE.HP) this.BUFFCOMP.vmdata_update(true)
} }
@@ -345,6 +351,9 @@ export class HeroViewComp extends CCComp {
case DebuffAttr.BURN: case DebuffAttr.BURN:
this.DEBUFF_BURNS.push({value:deV,count:deC}) this.DEBUFF_BURNS.push({value:deV,count:deC})
break break
case DebuffAttr.DECD:
this.DEBUFF_DECDS.push({value:deV,count:deC})
break
case DebuffAttr.SLOW: case DebuffAttr.SLOW:
this.DEBUFF_SLOW+=deV this.DEBUFF_SLOW+=deV
break break
@@ -357,15 +366,16 @@ export class HeroViewComp extends CCComp {
this.DEBUFF_STUN+=deV this.DEBUFF_STUN+=deV
this.is_stop=true this.is_stop=true
break break
case DebuffAttr.DECD:
this.DEBUFF_DECDS.push({value:deV,count:deC})
break
case DebuffAttr.DEHP: case DebuffAttr.DEHP:
this.hp_max-=deV this.hp_max-=deV/100*this.hp_max
if(this.hp-this.hp_max>0) this.hp=this.hp_max if(this.hp-this.hp_max>0) this.hp=this.hp_max
break break
case DebuffAttr.DEATK: case DebuffAttr.DEATK: //99为具体数字 并且局内永久生效,其他为百分比
if(deC == 99){
this.ap-=deV this.ap-=deV
}else{
this.DEBUFF_DEATKS.push({value:deV,count:deC})
}
break break
case DebuffAttr.DECOUNT: case DebuffAttr.DECOUNT:
this.atk_count-=deV this.atk_count-=deV
@@ -416,7 +426,7 @@ export class HeroViewComp extends CCComp {
} }
} }
this.BUFFCOMP.update_info_hp() this.BUFFCOMP.update_info_hp()
this.BUFFCOMP.vmdata_update(this.VM_TYPE.HP) this.BUFFCOMP.vmdata_update(true)
this.showDamage(damage, is_crit); this.showDamage(damage, is_crit);
} }
@@ -439,14 +449,12 @@ export class HeroViewComp extends CCComp {
this.BUFF_DEFS.splice(i,1) this.BUFF_DEFS.splice(i,1)
} }
} }
let buff_key=null let buff=null
if(this.is_master) {buff_key="hero"} if(this.is_master) buff=this.FIGHTCON.hero_buff
if(this.is_friend) {buff_key="friend"} if(this.is_friend) buff=this.FIGHTCON.friend_buff
if(this.is_boss) {buff_key="enemy"} if(this.is_boss) buff=this.FIGHTCON.enemy_buff
if(this.is_kalami) {buff_key="enemy"} if(this.is_kalami) buff=this.FIGHTCON.enemy_buff
if(buff_key==null) return if(buff==null) return
let buff=this.FIGHTCON[buff_key+"_buff"]
damage=remainingDamage*(100-(buff.DEF+def)+Burn)/100 damage=remainingDamage*(100-(buff.DEF+def)+Burn)/100
return Math.floor(damage) return Math.floor(damage)

View File

@@ -42,7 +42,6 @@ export class SkillConComp extends CCComp {
let cd = this.get_cd(this.HeroView.cd,this.HeroView) let cd = this.get_cd(this.HeroView.cd,this.HeroView)
let count=this.get_count(1,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) // 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)) { if (this.HeroView.is_atking &&(this.HeroView.at > cd)) {
if(this.HeroView.is_dead) return if(this.HeroView.is_dead) return
@@ -133,7 +132,7 @@ export class SkillConComp extends CCComp {
} }
check_double_atk(count:number){ check_double_atk(count:number){
let random = Math.random()*100 let random = Math.random()*100
if(random < FightSet.DOUBLE_ATK_RATE*count){ if(random < FightSet.DOUBLE_ATK_RATE*count){ //多次攻击概率
return true return true
} }
return false return false
@@ -186,14 +185,10 @@ export class SkillConComp extends CCComp {
Object.values(this._timers).forEach(clearTimeout); Object.values(this._timers).forEach(clearTimeout);
} }
get_cd(cd:number,view:HeroViewComp){ get_cd(cd:number,view:HeroViewComp){
let buff_key=null
if(view.is_master) {buff_key="hero"} let buff=this.get_buff(view)
if(view.is_friend) {buff_key="friend"} let buff_cd=0
if(view.is_boss) {buff_key="enemy"} if(buff!=null) buff_cd=buff.ATK_CD
if(view.is_kalami) {buff_key="enemy"}
if(buff_key==null) return
let debuff=this.FIGHTCON[buff_key+"_debuff"]
let buff=this.FIGHTCON[buff_key+"_buff"]
// 汇总DEBUFF_DECD并处理count值 // 汇总DEBUFF_DECD并处理count值
let decd = 0; let decd = 0;
@@ -213,21 +208,21 @@ export class SkillConComp extends CCComp {
view.BUFF_CDS.splice(i, 1); view.BUFF_CDS.splice(i, 1);
} }
} }
return cd*(100-bcd-buff_cd+decd)/100
return cd*(100-bcd-buff.ATK_CD)/100
} }
get_count(count:number,view:HeroViewComp){ get_count(count:number,view:HeroViewComp){
if(view.fac==FacSet.HERO){ let buff=this.get_buff(view)
if(view.is_master){ if(buff==null) return count
return count+(this.FIGHTCON.hero_buff.ATK_COUNT) let re=count+(buff.ATK_COUNT)
}else{ if(re<1) re=1
return count+(this.FIGHTCON.friend_buff.ATK_COUNT) return re
}
}else{
return count+(this.FIGHTCON.enemy_buff.ATK_COUNT)
} }
get_buff(view:HeroViewComp){
if(view.is_master) return this.FIGHTCON.hero_buff
if(view.is_friend) return this.FIGHTCON.friend_buff
if(view.is_boss||view.is_kalami) return this.FIGHTCON.enemy_buff
return null
} }
reset() { reset() {
this.clear_timer(); this.clear_timer();

View File

@@ -19,7 +19,7 @@ export class EquipsComp extends Component {
attrs:any={ attrs:any={
hero_buff:getBuffNum(), hero_buff:getBuffNum(),
friend_buff:getBuffNum(), friend_buff:getBuffNum(),
enemy_debuff:getBuffNum(), enemy_buff:getBuffNum(),
} }
/** 视图层逻辑代码分离演示 */ /** 视图层逻辑代码分离演示 */
onLoad() { onLoad() {
@@ -117,9 +117,6 @@ export class EquipsComp extends Component {
let weapon_buffs = this.weapon.uuid ? EquipInfo[this.weapon.uuid]?.buff || [] : []; let weapon_buffs = this.weapon.uuid ? EquipInfo[this.weapon.uuid]?.buff || [] : [];
let armor_buffs = this.armor.uuid ? EquipInfo[this.armor.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 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 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 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 : []; let accessory_special_attr = this.accessory.uuid ? EquipInfo[this.accessory.uuid]?.special_attr : [];
@@ -130,9 +127,6 @@ export class EquipsComp extends Component {
console.log("[EquipsComp]:weapon_buffs", weapon_buffs); console.log("[EquipsComp]:weapon_buffs", weapon_buffs);
console.log("[EquipsComp]:防具属性", armor_buffs); console.log("[EquipsComp]:防具属性", armor_buffs);
console.log("[EquipsComp]:饰品属性", accessory_buffs); console.log("[EquipsComp]:饰品属性", accessory_buffs);
console.log("[EquipsComp]:武器减益", weapon_debuffs);
console.log("[EquipsComp]:防具减益", armor_debuffs);
console.log("[EquipsComp]:饰品减益", accessory_debuffs);
const all_special_attr=[...weapon_special_attr,...armor_special_attr,...accessory_special_attr] 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) 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 allBuff = [...weapon_buffs, ...armor_buffs, ...accessory_buffs];
const allDebuff = [...weapon_debuffs, ...armor_debuffs, ...accessory_debuffs];
console.log("[EquipsComp]:合并后的所有属性", allBuff); console.log("[EquipsComp]:合并后的所有属性", allBuff);
console.log("[EquipsComp]:合并后的所有减益", allDebuff);
// 计算每个目标的属性加成 // 计算每个目标的属性加成
allBuff.forEach(attr => { allBuff.forEach(attr => {
const target = attr.target || EquipAttrTarget.HERO; const target = attr.target || EquipAttrTarget.HERO;
@@ -158,23 +150,7 @@ export class EquipsComp extends Component {
} }
this.add_attr(targetKey,attr) 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); console.log("[EquipsComp]:debuff buff attrs ", this.attrs);
oops.message.dispatchEvent(GameEvent.EquipChange, 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 // 重置所有属性为0
private reset_attrs() { private reset_attrs() {
@@ -270,7 +221,7 @@ export class EquipsComp extends Component {
const newAttrs = { const newAttrs = {
hero_buff: getBuffNum(), hero_buff: getBuffNum(),
friend_buff: getBuffNum(), friend_buff: getBuffNum(),
enemy_debuff: getBuffNum(), enemy_buff: getBuffNum(),
}; };
// 替换整个 attrs 对象 // 替换整个 attrs 对象
@@ -279,7 +230,7 @@ export class EquipsComp extends Component {
console.log("重置属性", { console.log("重置属性", {
hero_buff: this.attrs.hero_buff, hero_buff: this.attrs.hero_buff,
friend_buff: this.attrs.friend_buff, friend_buff: this.attrs.friend_buff,
enemy_debuff: this.attrs.enemy_debuff, enemy_buff: this.attrs.enemy_buff,
}); });
} }

View File

@@ -19,9 +19,6 @@ export class FightConComp extends Component {
friend_buff=getBuffNum() friend_buff=getBuffNum()
enemy_buff=getBuffNum() enemy_buff=getBuffNum()
hero_debuff=geDebuffNum()
friend_debuff=geDebuffNum()
enemy_debuff=geDebuffNum()
//注意临时buff和debuff 每种buff的值 必须都一样 多种值 战斗处理复杂 暂时放弃 //注意临时buff和debuff 每种buff的值 必须都一样 多种值 战斗处理复杂 暂时放弃
atk_type:number=0; atk_type:number=0;
@@ -67,17 +64,38 @@ export class FightConComp extends Component {
this.atk_add_master_atk=data.atk_add_master_atk+(this.card_atk_add > 0 ? this.card_atk_add:0) //装备特殊属性 英雄/伙伴 攻击力增加 this.atk_add_master_atk=data.atk_add_master_atk+(this.card_atk_add > 0 ? this.card_atk_add:0) //装备特殊属性 英雄/伙伴 攻击力增加
this.atk_add_master_hp=data.atk_add_master_hp+(this.card_hp_add > 0 ? this.card_hp_add:0) //装备特殊属性 英雄/伙伴 生命值增加 this.atk_add_master_hp=data.atk_add_master_hp+(this.card_hp_add > 0 ? this.card_hp_add:0) //装备特殊属性 英雄/伙伴 生命值增加
this.friend_alive_cd=FightSet.FRIEND_LIVE_CD-data.friend_live_cd_less this.friend_alive_cd=FightSet.FRIEND_LIVE_CD-data.friend_live_cd_less
} }
private equip_change(e:GameEvent,equip:any){ private equip_change(e:GameEvent,equip:any){
let old_hero_hp=JSON.parse(JSON.stringify(this.hero_buff.HP))
let old_friend_hp=JSON.parse(JSON.stringify(this.friend_buff.HP))
let new_hero_hp=JSON.parse(JSON.stringify(equip.hero_buff.HP))
let new_friend_hp=JSON.parse(JSON.stringify(equip.friend_buff.HP))
this.hero_buff=equip.hero_buff this.hero_buff=equip.hero_buff
this.friend_buff=equip.friend_buff this.friend_buff=equip.friend_buff
this.enemy_buff=equip.enemy_buff
this.hero_debuff=equip.hero_debuff
this.friend_debuff=equip.friend_debuff let hero_hp_add=new_hero_hp-old_hero_hp
this.enemy_debuff=equip.enemy_debuff let friend_hp_add=new_friend_hp-old_friend_hp
console.log("[FightConComp]:old_hero_hp:"+old_hero_hp+" new_hero_hp:"+new_hero_hp+" hero_hp_add:"+hero_hp_add)
if(hero_hp_add!==0){
oops.message.dispatchEvent(GameEvent.UpdateHP,{hp:hero_hp_add,is_master:true})
}
if(friend_hp_add!==0){
oops.message.dispatchEvent(GameEvent.UpdateHP,{hp:friend_hp_add,is_master:false})
}
this.scheduleOnce(()=>{
oops.message.dispatchEvent(GameEvent.UpdateVMData)
},0.1)
} }
private fight_ready(e:GameEvent){ private fight_ready(e:GameEvent){
@@ -163,9 +181,6 @@ export class FightConComp extends Component {
this.friend_buff=getBuffNum() this.friend_buff=getBuffNum()
this.enemy_buff=getBuffNum() this.enemy_buff=getBuffNum()
this.hero_debuff=geDebuffNum()
this.friend_debuff=geDebuffNum()
this.enemy_debuff=geDebuffNum()
this.friend_alive_cd=FightSet.FRIEND_LIVE_CD this.friend_alive_cd=FightSet.FRIEND_LIVE_CD
this.atk_add_friend_atk=0 this.atk_add_friend_atk=0

View File

@@ -67,7 +67,7 @@ export class Skill extends ecs.Entity {
return; return;
} }
console.log("[Skill]:caster=>",caster,config.name+"scomp=>",SComp,"fightcon=>",FIGHTCON)
// 确保caster有必要的属性 // 确保caster有必要的属性
if (typeof caster.ap === 'undefined') { if (typeof caster.ap === 'undefined') {
@@ -80,12 +80,12 @@ export class Skill extends ecs.Entity {
return; return;
} }
SComp.ap = this.get_ap(caster,dmg) let ap_data = this.get_ap(caster,dmg,uuid,FIGHTCON)
SComp.ap = ap_data.ap
SComp.caster_crit = ap_data.crit
SComp.caster_crit_d = ap_data.crit_d
console.log("[Skill]:caster=>",caster,config.name+"scomp=>",SComp,"fightcon=>",FIGHTCON)
console.log("[Skill]:caster.box_group=>",caster.box_group,config.name+"scomp.group=>",SComp.group)
// 设置技能组件属性 // 设置技能组件属性
Object.assign(SComp, { Object.assign(SComp, {
s_uuid: uuid, s_uuid: uuid,
@@ -104,18 +104,24 @@ export class Skill extends ecs.Entity {
this.add(SComp); this.add(SComp);
} }
get_ap(view:HeroViewComp,dmg:number=0){ get_ap(view:HeroViewComp,dmg:number=0,uuid:number=0,FIGHTCON:FightConComp=null!){
let buff_key=null let ap=0
if(view.is_master) {buff_key="hero"} let crit=0
if(view.is_friend) {buff_key="friend"} let crit_d=0
if(view.is_boss) {buff_key="enemy"} let buff_ap=1
if(view.is_kalami) {buff_key="enemy"} let buff=null
if(buff_key==null) return if(view.is_master) buff=FIGHTCON.hero_buff
let debuff=this.FIGHTCON[buff_key+"_debuff"] if(view.is_friend) buff=FIGHTCON.friend_buff
let buff=this.FIGHTCON[buff_key+"_buff"] if(view.is_boss) buff=FIGHTCON.enemy_buff
let buff_ap=(100+buff.ATK-debuff.DEATK)/100 //装备区 总加成 if(view.is_kalami) buff=FIGHTCON.enemy_buff
if(!buff==null) {
buff_ap=(100+buff.ATK)/100 //装备区 总加成
}
// 汇总DEBUFF_DECD并处理count值 // 汇总DEBUFF_DECD并处理count值
let BUFF_ATK = 0; let BUFF_ATK = 0
let DEBUFF_DEATK = 0
if(view.BUFF_ATKS.length>0){
for (let i = view.BUFF_ATKS.length - 1; i >= 0; i--) { for (let i = view.BUFF_ATKS.length - 1; i >= 0; i--) {
BUFF_ATK += view.BUFF_ATKS[i].value; BUFF_ATK += view.BUFF_ATKS[i].value;
view.BUFF_ATKS[i].count--; view.BUFF_ATKS[i].count--;
@@ -123,7 +129,8 @@ export class Skill extends ecs.Entity {
view.BUFF_ATKS.splice(i, 1); view.BUFF_ATKS.splice(i, 1);
} }
} }
let DEBUFF_DEATK = 0; }
if(view.DEBUFF_DEATKS.length>0) {
for (let i = view.DEBUFF_DEATKS.length - 1; i >= 0; i--) { for (let i = view.DEBUFF_DEATKS.length - 1; i >= 0; i--) {
DEBUFF_DEATK += view.DEBUFF_DEATKS[i].value; DEBUFF_DEATK += view.DEBUFF_DEATKS[i].value;
view.DEBUFF_DEATKS[i].count--; view.DEBUFF_DEATKS[i].count--;
@@ -131,8 +138,14 @@ export class Skill extends ecs.Entity {
view.DEBUFF_DEATKS.splice(i, 1); view.DEBUFF_DEATKS.splice(i, 1);
} }
} }
}
let BUFF_AP=(100-DEBUFF_DEATK+BUFF_ATK+dmg)/100 //buff区 总加成 let BUFF_AP=(100-DEBUFF_DEATK+BUFF_ATK+dmg)/100 //buff区 总加成
return view.ap*buff_ap*BUFF_AP ap=view.ap*buff_ap*BUFF_AP*SkillSet[uuid].ap/100
crit=view.crit+buff.CRITICAL
crit_d=view.crit_d+buff.CRITICAL_DMG
console.log("[Skill]:ap=>",ap,"crit=>",crit,"crit_d=>",crit_d)
return {ap,crit,crit_d}
} }
} }

View File

@@ -70,18 +70,8 @@ export class SkillCom extends CCComp {
oops.message.on(GameEvent.MissionEnd, this.doDestroy, this); oops.message.on(GameEvent.MissionEnd, this.doDestroy, this);
this.node.active = true; this.node.active = true;
console.log("[SkillCom]:caster",this.caster) console.log("[SkillCom]:caster",this.caster)
if(this.caster.fac==FacSet.HERO){
if(this.caster.is_master){
this.caster_crit = this.caster.crit+this.FIGHTCON.hero_buff.CRITICAL+this.FIGHTCON.hero_debuff.CRITICAL
this.caster_crit_d = this.caster.crit_d+this.FIGHTCON.hero_buff.CRITICAL_DMG
}else{
this.caster_crit = this.caster.crit+this.FIGHTCON.friend_buff.CRITICAL+this.FIGHTCON.hero_debuff.CRITICAL
this.caster_crit_d = this.caster.crit_d+this.FIGHTCON.friend_buff.CRITICAL_DMG
}
}else{
this.caster_crit = this.caster.crit+this.FIGHTCON.enemy_buff.CRITICAL+this.FIGHTCON.enemy_debuff.CRITICAL
this.caster_crit_d = this.caster.crit_d+this.FIGHTCON.enemy_buff.CRITICAL_DMG
}
let collider = this.getComponent(Collider2D); let collider = this.getComponent(Collider2D);
if(collider) { if(collider) {
collider.group = this.group; collider.group = this.group;
@@ -161,7 +151,8 @@ export class SkillCom extends CCComp {
if(target == null) return; if(target == null) return;
target.do_atked(this.ap,crit,crit_d) target.do_atked(this.ap,crit,crit_d)
if(SkillSet[this.s_uuid].debuff>0){ if(SkillSet[this.s_uuid].debuff>0){
target.add_debuff(SkillSet[this.s_uuid].debuff,SkillSet[this.s_uuid].deV,SkillSet[this.s_uuid].deC) let debuff =this.get_debuff()
target.add_debuff(SkillSet[this.s_uuid].debuff,debuff.deV,debuff.deC)
} }
} }
@@ -174,7 +165,17 @@ export class SkillCom extends CCComp {
// this.ent.destroy() // this.ent.destroy()
} }
} }
get_debuff(){ //debuff 加成
let debuff = {deV:0,deC:0}
let buff=null
if(this.caster.is_master) buff = this.FIGHTCON.hero_buff
if(this.caster.is_friend) buff = this.FIGHTCON.friend_buff
if(this.caster.is_boss||this.caster.is_kalami) buff = this.FIGHTCON.enemy_buff
if(buff==null) return debuff
debuff.deV=buff.DEBUFF_VALUE
debuff.deC=buff.DEBUFF_COUNT
return debuff
}
private startLinearMove(dt: number) { private startLinearMove(dt: number) {
if (!this.speed || this.is_destroy) return; if (!this.speed || this.is_destroy) return;