逐步 去掉 主英雄设定

This commit is contained in:
2025-08-05 10:32:18 +08:00
parent b6228f7747
commit 3db3cc78eb
6 changed files with 138 additions and 137 deletions

View File

@@ -36,6 +36,8 @@ export class HeroViewComp extends CCComp {
type: number = 0; /**角色类型 0近战-需要贴身 1远程-保持距离 2辅助 */
fac:number=0; //阵营 0hero 1monster
vmHero:any={}
box_group:number = BoxSet.HERO;
is_dead:boolean = false; //是否摧毁
@@ -152,7 +154,6 @@ export class HeroViewComp extends CCComp {
onLoad() {
this.as = this.getComponent(HeroSpine);
//console.log("[HeroViewComp]:hero view comp ",this.FIGHTCON)
this.on(GameEvent.ChangeATK_EQUIP_SPECIAL_ATTR,this.change_atk,this)
this.on(GameEvent.EXPUP,this.exp_up,this)
const collider = this.node.getComponent(BoxCollider2D);
this.scheduleOnce(()=>{
@@ -165,7 +166,7 @@ export class HeroViewComp extends CCComp {
start () {
this.as.idle()
this.BUFFCOMP=this.node.getComponent(BuffComp);
if(this.is_master) this.BUFFCOMP.vmdata_update()
// if(this.is_master) this.BUFFCOMP.vmdata_update()
/** 方向 */
this.node.setScale(this.scale,1);
this.node.getChildByName("top").setScale(this.scale,1);
@@ -201,10 +202,7 @@ export class HeroViewComp extends CCComp {
this.processDamageQueue();
}
change_atk(e:GameEvent,data:any){
if(!this.is_master) return
}
get isActive() {
return this.ent.has(HeroViewComp) && this.node?.isValid;
@@ -236,70 +234,70 @@ export class HeroViewComp extends CCComp {
change_wfuny(wfuny: number){
this.wfuny+=wfuny
if(this.wfuny<0) this.wfuny=0
if(this.is_master) this.BUFFCOMP.vmdata_update()
// if(this.is_master) this.BUFFCOMP.vmdata_update()
}
change_puncture(puncture: number){
this.puncture+=puncture
if(this.puncture<1) this.puncture=1
if(this.is_master) this.BUFFCOMP.vmdata_update()
// if(this.is_master) this.BUFFCOMP.vmdata_update()
}
change_puncture_damage(puncture_damage: number){
this.puncture_damage+=puncture_damage
if(this.puncture_damage<0) this.puncture_damage=0
if(this.puncture_damage>80) this.puncture_damage=80
if(this.is_master) this.BUFFCOMP.vmdata_update()
// if(this.is_master) this.BUFFCOMP.vmdata_update()
}
change_dodge(dodge: number){
this.dod+=dodge
if(this.dod<0) this.dod=0
if(this.dod>90) this.dod=90
if(this.is_master) this.BUFFCOMP.vmdata_update()
// if(this.is_master) this.BUFFCOMP.vmdata_update()
}
change_frost_ratto(frost_ratto: number){
this.frost_ratto+=frost_ratto
if(this.frost_ratto<0) this.frost_ratto=0
if(this.frost_ratto>90) this.frost_ratto=90
if(this.is_master) this.BUFFCOMP.vmdata_update()
// if(this.is_master) this.BUFFCOMP.vmdata_update()
}
change_knockback(knockback: number){
this.knockback+=knockback
if(this.knockback<0) this.knockback=0
if(this.is_master) this.BUFFCOMP.vmdata_update()
// if(this.is_master) this.BUFFCOMP.vmdata_update()
}
change_stun_ratto(stun_ratto: number){
this.stun_ratto+=stun_ratto
if(this.stun_ratto<0) this.stun_ratto=0
if(this.is_master) this.BUFFCOMP.vmdata_update()
// if(this.is_master) this.BUFFCOMP.vmdata_update()
}
change_def(def: number){
this.def+=def
if(this.def>90) this.def=90
if(this.def<0) this.def=0
if(this.is_master) this.BUFFCOMP.vmdata_update()
// if(this.is_master) this.BUFFCOMP.vmdata_update()
// this.BUFFCOMP.tooltip(TooltipTypes.defup,def.toFixed(0));
}
change_crit(crit: number){
this.crit+=crit
if(this.crit<0) this.crit=0
if(this.is_master) this.BUFFCOMP.vmdata_update()
// if(this.is_master) this.BUFFCOMP.vmdata_update()
}
change_crit_d(crit_d: number){
this.crit_d+=crit_d
if(this.crit_d<0) this.crit_d=0
if(this.is_master) this.BUFFCOMP.vmdata_update()
// if(this.is_master) this.BUFFCOMP.vmdata_update()
}
change_reflect(reflect: number){
this.reflect+=reflect
if(this.reflect<0) this.reflect=0
if(this.is_master) this.BUFFCOMP.vmdata_update()
// if(this.is_master) this.BUFFCOMP.vmdata_update()
}
change_lifesteal(lifesteal: number){
this.lifesteal+=lifesteal
if(this.lifesteal<0) this.lifesteal=0
if(this.is_master) this.BUFFCOMP.vmdata_update()
// if(this.is_master) this.BUFFCOMP.vmdata_update()
}
check_atrr(buff:BuffAttr){
@@ -318,20 +316,19 @@ export class HeroViewComp extends CCComp {
switch(buff){
case BuffAttr.ATK:
this.ap=this.check_atrr(BuffAttr.ATK)
if(this.is_master) {
this.BUFFCOMP.vmdata_update();
oops.message.dispatchEvent(GameEvent.APChange,{is_master:this.is_master,fac:this.fac})
}
// if(this.is_master) {
// // this.BUFFCOMP.vmdata_update();
// }
break
case BuffAttr.ATK_CD:
this.cd=this.check_atrr(BuffAttr.ATK_CD)
if(this.is_master) this.BUFFCOMP.vmdata_update()
// if(this.is_master) this.BUFFCOMP.vmdata_update()
break
case BuffAttr.HP:
let diff=this.check_atrr(BuffAttr.HP)-this.hp_max
this.hp_max=this.check_atrr(BuffAttr.HP)
this.hp+=diff
if(this.is_master) this.BUFFCOMP.vmdata_update(true)
// if(this.is_master) this.BUFFCOMP.vmdata_update(true)
break
}
}
@@ -379,7 +376,7 @@ export class HeroViewComp extends CCComp {
//console.log("[HeroViewComp]:de_hp_max de:",hp,this.hp_max)
this.hp_base -= Math.floor(hp) ;
this.count_atrr(BuffAttr.HP)
if(this.is_master) this.BUFFCOMP.vmdata_update(true)
// if(this.is_master) this.BUFFCOMP.vmdata_update(true)
}
add_hp(hp: number = 0,is_num:boolean=true) {
@@ -404,7 +401,7 @@ export class HeroViewComp extends CCComp {
this.hp+=real_hp;
this.BUFFCOMP.tooltip(TooltipTypes.health,real_hp.toFixed(0));
}
if(this.is_master) this.BUFFCOMP.vmdata_update(true)
// if(this.is_master) this.BUFFCOMP.vmdata_update(true)
}
@@ -418,24 +415,9 @@ export class HeroViewComp extends CCComp {
}
}
}
count_atk_count(){ //主将攻击次数 主要有装备加成,需要单独处理
if(!this.is_master) return
count_atk_count(){ //主将攻击
if(this.fac==FacSet.MON) return
this.atk_count+=1
if(this.atk_count< FightSet.ATK_ADD_COUNT) return
let master=ecs.query(ecs.allOf(MasterModelComp))
master.forEach(master=>{
let master_view=master.get(HeroViewComp)
if(this.atk_add_master_atk>0) {
master_view.add_ap(this.atk_add_master_atk,true)
}
if(this.atk_add_master_hp>0) {
master_view.add_hp_max(this.atk_add_master_hp,true)
}
})
this.atk_count=0
}
@@ -451,14 +433,13 @@ export class HeroViewComp extends CCComp {
this.is_count_dead=true
this.scheduleOnce(()=>{
oops.message.dispatchEvent(GameEvent.MonDead)
},0.1)
}
if(this.fac==FacSet.HERO){
//console.log("[HeroViewComp]:英雄死亡")
oops.message.dispatchEvent(GameEvent.FightEnd,{victory:false})
// oops.message.dispatchEvent(GameEvent.FightEnd,{victory:false})
}
@@ -645,7 +626,7 @@ export class HeroViewComp extends CCComp {
this.ent.destroy();
}
}
if(this.is_master) this.BUFFCOMP.vmdata_update(true)
// if(this.is_master) this.BUFFCOMP.vmdata_update(true)
this.showDamage(damage, is_crit);
}
@@ -719,14 +700,14 @@ export class HeroViewComp extends CCComp {
// this.to_drop()
// }
do_dead_trigger(){
if(this.is_dead||this.fac==FacSet.MON||this.is_master) return
do_dead_trigger(){ //双倍死亡设定
if(this.is_dead||this.fac==FacSet.MON) return
let count = 1
for(let i=0;i<count;i++){
//console.log("[HeroViewComp]:dead"+i+"次")
}
}
do_atked_trigger(){
do_atked_trigger(){ //双倍攻击设定
if(this.is_dead||this.fac==FacSet.MON) return
let count = 1
if(this.double_atked) {
@@ -801,11 +782,11 @@ export class HeroViewComp extends CCComp {
to_update(){
// console.log("[HeroViewComp]:to_update",this.is_master)
if(!this.is_master) return
smc.vmdata.hero.exp = smc.vmdata.hero.exp-smc.vmdata.hero.next_exp
smc.vmdata.hero.lv = smc.vmdata.hero.lv+1
smc.vmdata.hero.next_exp=getUpExp(smc.vmdata.hero.lv)
oops.message.dispatchEvent(GameEvent.HeroLvUp,{lv:smc.vmdata.hero.lv})
// if(!this.is_master) return
// smc.vmdata.hero.exp = smc.vmdata.hero.exp-smc.vmdata.hero.next_exp
// smc.vmdata.hero.lv = smc.vmdata.hero.lv+1
// smc.vmdata.hero.next_exp=getUpExp(smc.vmdata.hero.lv)
// oops.message.dispatchEvent(GameEvent.HeroLvUp,{lv:smc.vmdata.hero.lv})
this.BUFFCOMP.lv_up()
// this.BUFFCOMP.tooltip(TooltipTypes.lvup)
}