信息展示 继续

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

View File

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

View File

@@ -52,6 +52,7 @@ export class HeroViewComp extends CCComp {
hp_up:number=0;
hp: number = 100; /** 血量 */
hp_max: number = 100; /** 最大血量 */
hp_buff:number=0;
hp_speed: number = 0; //每秒回复量
pwt:Timer = new Timer(1); //计时器
@@ -90,16 +91,10 @@ export class HeroViewComp extends CCComp {
DEBUFF_BURNS: Array<{value: number, count: number}> = []
DEBUFF_DEATKS: Array<{value: number, count: number}> = []
DEBUFF_DECDS: Array<{value: number, count: number}> = []
DEBUFF_SLOW: number = 0;
DEBUFF_FROST: number = 0;
DEBUFF_STUN: number = 0;
VM_TYPE:any={
ALL:0,
HP:1,
OTHER:2,
}
private damageQueue: Array<{
damage: number,
isCrit: boolean,
@@ -115,7 +110,7 @@ export class HeroViewComp extends CCComp {
this.FIGHTCON=this.node.parent.getComponent(FightConComp);
console.log("[HeroViewComp]:hero view comp ",this.FIGHTCON)
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")
// 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.BUFFCOMP.update_info_ap()
this.BUFFCOMP.vmdata_update(this.VM_TYPE.OTHER)
this.BUFFCOMP.vmdata_update()
}
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.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){
console.log("[HeroViewComp]:add_hp_max add:",hp,this.hp_max)
if(is_num){
@@ -260,7 +266,7 @@ export class HeroViewComp extends CCComp {
this.hp_max -= Math.floor(hp/100*this.hp_max);
}
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) {
@@ -274,7 +280,7 @@ export class HeroViewComp extends CCComp {
this.hp = this.hp_max;
}
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:
this.DEBUFF_BURNS.push({value:deV,count:deC})
break
case DebuffAttr.DECD:
this.DEBUFF_DECDS.push({value:deV,count:deC})
break
case DebuffAttr.SLOW:
this.DEBUFF_SLOW+=deV
break
@@ -357,15 +366,16 @@ export class HeroViewComp extends CCComp {
this.DEBUFF_STUN+=deV
this.is_stop=true
break
case DebuffAttr.DECD:
this.DEBUFF_DECDS.push({value:deV,count:deC})
break
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
break
case DebuffAttr.DEATK:
this.ap-=deV
case DebuffAttr.DEATK: //99为具体数字 并且局内永久生效,其他为百分比
if(deC == 99){
this.ap-=deV
}else{
this.DEBUFF_DEATKS.push({value:deV,count:deC})
}
break
case DebuffAttr.DECOUNT:
this.atk_count-=deV
@@ -416,7 +426,7 @@ export class HeroViewComp extends CCComp {
}
}
this.BUFFCOMP.update_info_hp()
this.BUFFCOMP.vmdata_update(this.VM_TYPE.HP)
this.BUFFCOMP.vmdata_update(true)
this.showDamage(damage, is_crit);
}
@@ -439,14 +449,12 @@ export class HeroViewComp extends CCComp {
this.BUFF_DEFS.splice(i,1)
}
}
let buff_key=null
if(this.is_master) {buff_key="hero"}
if(this.is_friend) {buff_key="friend"}
if(this.is_boss) {buff_key="enemy"}
if(this.is_kalami) {buff_key="enemy"}
if(buff_key==null) return
let buff=this.FIGHTCON[buff_key+"_buff"]
let buff=null
if(this.is_master) buff=this.FIGHTCON.hero_buff
if(this.is_friend) buff=this.FIGHTCON.friend_buff
if(this.is_boss) buff=this.FIGHTCON.enemy_buff
if(this.is_kalami) buff=this.FIGHTCON.enemy_buff
if(buff==null) return
damage=remainingDamage*(100-(buff.DEF+def)+Burn)/100
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 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)) {
if(this.HeroView.is_dead) return
@@ -133,7 +132,7 @@ export class SkillConComp extends CCComp {
}
check_double_atk(count:number){
let random = Math.random()*100
if(random < FightSet.DOUBLE_ATK_RATE*count){
if(random < FightSet.DOUBLE_ATK_RATE*count){ //多次攻击概率
return true
}
return false
@@ -186,15 +185,11 @@ export class SkillConComp extends CCComp {
Object.values(this._timers).forEach(clearTimeout);
}
get_cd(cd:number,view:HeroViewComp){
let buff_key=null
if(view.is_master) {buff_key="hero"}
if(view.is_friend) {buff_key="friend"}
if(view.is_boss) {buff_key="enemy"}
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"]
let buff=this.get_buff(view)
let buff_cd=0
if(buff!=null) buff_cd=buff.ATK_CD
// 汇总DEBUFF_DECD并处理count值
let decd = 0;
for (let i = view.DEBUFF_DECDS.length - 1; i >= 0; i--) {
@@ -213,21 +208,21 @@ export class SkillConComp extends CCComp {
view.BUFF_CDS.splice(i, 1);
}
}
return cd*(100-bcd-buff.ATK_CD)/100
return cd*(100-bcd-buff_cd+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)
}else{
return count+(this.FIGHTCON.friend_buff.ATK_COUNT)
}
}else{
return count+(this.FIGHTCON.enemy_buff.ATK_COUNT)
}
let buff=this.get_buff(view)
if(buff==null) return count
let re=count+(buff.ATK_COUNT)
if(re<1) re=1
return re
}
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() {
this.clear_timer();