统一属性计算函数
This commit is contained in:
@@ -97,10 +97,11 @@ export class HeroConComp extends CCComp {
|
|||||||
switch(data.buffType){
|
switch(data.buffType){
|
||||||
case BuffAttr.ATK:
|
case BuffAttr.ATK:
|
||||||
this.heroView.TALENT[BuffAttr.ATK]+=data.value
|
this.heroView.TALENT[BuffAttr.ATK]+=data.value
|
||||||
this.heroView.count_ap()
|
this.heroView.count_atrr(BuffAttr.ATK)
|
||||||
break
|
break
|
||||||
case BuffAttr.ATK_CD:
|
case BuffAttr.ATK_CD:
|
||||||
this.heroView.TALENT[BuffAttr.ATK_CD]+=data.value
|
this.heroView.TALENT[BuffAttr.ATK_CD]+=data.value
|
||||||
|
this.heroView.count_atrr(BuffAttr.ATK_CD)
|
||||||
break
|
break
|
||||||
case BuffAttr.HP:
|
case BuffAttr.HP:
|
||||||
this.heroView.TALENT[BuffAttr.HP]+=data.value
|
this.heroView.TALENT[BuffAttr.HP]+=data.value
|
||||||
|
|||||||
@@ -236,37 +236,55 @@ export class HeroViewComp extends CCComp {
|
|||||||
*/
|
*/
|
||||||
add_def(def: number){
|
add_def(def: number){
|
||||||
this.def+=def
|
this.def+=def
|
||||||
if(this.is_master) this.BUFFCOMP.vmdata_update()
|
this.count_atrr(BuffAttr.DEF)
|
||||||
|
|
||||||
// this.BUFFCOMP.tooltip(TooltipTypes.defup,def.toFixed(0));
|
// this.BUFFCOMP.tooltip(TooltipTypes.defup,def.toFixed(0));
|
||||||
}
|
}
|
||||||
|
|
||||||
add_speed(cd: number){
|
check_atrr(buff:BuffAttr){
|
||||||
this.buff_cd+=cd
|
switch(buff){
|
||||||
this.count_cd()
|
case BuffAttr.ATK:
|
||||||
// this.BUFFCOMP.tooltip(TooltipTypes.speedup,speed.toFixed(0));
|
|
||||||
}
|
|
||||||
|
|
||||||
check_cd(){
|
|
||||||
return this.cd/((this.buff_cd+this.TALENT[BuffAttr.ATK_CD])/100+1)
|
|
||||||
}
|
|
||||||
count_cd(){
|
|
||||||
this.cd=this.check_cd()
|
|
||||||
if(this.is_master) {
|
|
||||||
this.BUFFCOMP.vmdata_update();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
check_ap(){
|
|
||||||
return Math.floor(this.ap_base*(100+this.buff_ap+this.TALENT[BuffAttr.ATK])/100)
|
return Math.floor(this.ap_base*(100+this.buff_ap+this.TALENT[BuffAttr.ATK])/100)
|
||||||
|
case BuffAttr.ATK_CD:
|
||||||
|
return this.cd/((this.buff_cd+this.TALENT[BuffAttr.ATK_CD])/100+1)
|
||||||
|
case BuffAttr.HP:
|
||||||
|
return Math.floor(this.hp_base*(100+this.buff_hp+this.TALENT[BuffAttr.HP])/100)
|
||||||
|
case BuffAttr.DEF:
|
||||||
|
return this.def+this.TALENT[BuffAttr.DEF]
|
||||||
}
|
}
|
||||||
|
}
|
||||||
count_ap(){
|
count_atrr(buff:BuffAttr){
|
||||||
this.ap=this.check_ap()
|
switch(buff){
|
||||||
|
case BuffAttr.ATK:
|
||||||
|
this.ap=this.check_atrr(BuffAttr.ATK)
|
||||||
if(this.is_master) {
|
if(this.is_master) {
|
||||||
this.BUFFCOMP.vmdata_update();
|
this.BUFFCOMP.vmdata_update();
|
||||||
oops.message.dispatchEvent(GameEvent.APChange,{is_master:this.is_master,fac:this.fac})
|
oops.message.dispatchEvent(GameEvent.APChange,{is_master:this.is_master,fac:this.fac})
|
||||||
}
|
}
|
||||||
|
break
|
||||||
|
case BuffAttr.ATK_CD:
|
||||||
|
this.cd=this.check_atrr(BuffAttr.ATK_CD)
|
||||||
|
break
|
||||||
|
case BuffAttr.HP:
|
||||||
|
this.hp_max=this.check_atrr(BuffAttr.HP)
|
||||||
|
if(this.is_master) this.BUFFCOMP.vmdata_update(true)
|
||||||
|
break
|
||||||
|
case BuffAttr.DEF:
|
||||||
|
this.def=this.check_atrr(BuffAttr.DEF)
|
||||||
|
if(this.is_master) this.BUFFCOMP.vmdata_update()
|
||||||
|
break
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
add_speed(cd: number){
|
||||||
|
this.buff_cd+=cd
|
||||||
|
this.count_atrr(BuffAttr.ATK_CD)
|
||||||
|
// this.BUFFCOMP.tooltip(TooltipTypes.speedup,speed.toFixed(0));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
add_ap(ap: number,is_num:boolean=true){
|
add_ap(ap: number,is_num:boolean=true){
|
||||||
// console.log("[HeroViewComp]:add_ap add:",ap,this.ap)
|
// console.log("[HeroViewComp]:add_ap add:",ap,this.ap)
|
||||||
if(is_num){
|
if(is_num){
|
||||||
@@ -274,8 +292,8 @@ export class HeroViewComp extends CCComp {
|
|||||||
}else{
|
}else{
|
||||||
this.buff_ap += Math.floor(ap);
|
this.buff_ap += Math.floor(ap);
|
||||||
}
|
}
|
||||||
let diff=this.check_ap()-this.ap
|
let diff=this.check_atrr(BuffAttr.ATK)-this.ap
|
||||||
this.count_ap()
|
this.count_atrr(BuffAttr.ATK)
|
||||||
// this.BUFFCOMP.tooltip(TooltipTypes.apup,diff.toFixed(0));
|
// this.BUFFCOMP.tooltip(TooltipTypes.apup,diff.toFixed(0));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -286,8 +304,8 @@ export class HeroViewComp extends CCComp {
|
|||||||
}else{
|
}else{
|
||||||
this.buff_ap -= Math.floor(ap/100*this.ap);
|
this.buff_ap -= Math.floor(ap/100*this.ap);
|
||||||
}
|
}
|
||||||
let diff=this.check_ap()-this.ap
|
let diff=this.check_atrr(BuffAttr.ATK)-this.ap
|
||||||
this.count_ap()
|
this.count_atrr(BuffAttr.ATK)
|
||||||
}
|
}
|
||||||
|
|
||||||
add_hp_max(hp: number=0,is_num:boolean=false){
|
add_hp_max(hp: number=0,is_num:boolean=false){
|
||||||
@@ -297,18 +315,17 @@ export class HeroViewComp extends CCComp {
|
|||||||
}else{
|
}else{
|
||||||
this.buff_hp+=hp
|
this.buff_hp+=hp
|
||||||
}
|
}
|
||||||
let diff=Math.floor(this.hp_base*(100+this.buff_hp)/100)-this.hp_max
|
let diff=this.check_atrr(BuffAttr.HP)-this.hp_max
|
||||||
this.hp_max =Math.floor(this.hp_base*(100+this.buff_hp)/100)
|
this.count_atrr(BuffAttr.HP)
|
||||||
this.hp+=diff
|
this.hp+=diff
|
||||||
if(this.is_master) this.BUFFCOMP.vmdata_update(true)
|
|
||||||
// this.BUFFCOMP.tooltip(TooltipTypes.hpup,diff.toFixed(0));
|
// this.BUFFCOMP.tooltip(TooltipTypes.hpup,diff.toFixed(0));
|
||||||
}
|
}
|
||||||
|
|
||||||
de_hp_max(hp: number=0,is_num:boolean=true){ //最大值 只存在数值添加, 比例通过buff_hp处理
|
de_hp_max(hp: number=0,is_num:boolean=true){ //最大值 只存在数值添加, 比例通过buff_hp处理
|
||||||
//console.log("[HeroViewComp]:de_hp_max de:",hp,this.hp_max)
|
//console.log("[HeroViewComp]:de_hp_max de:",hp,this.hp_max)
|
||||||
this.hp_base -= Math.floor(hp) ;
|
this.hp_base -= Math.floor(hp) ;
|
||||||
let diff=Math.floor(this.hp_base*(100+this.buff_hp)/100)-this.hp_max
|
let diff=this.check_atrr(BuffAttr.HP)-this.hp_max
|
||||||
this.hp_max =Math.floor(this.hp_base*(100+this.buff_hp)/100)
|
this.count_atrr(BuffAttr.HP)
|
||||||
this.hp+=diff
|
this.hp+=diff
|
||||||
if(this.is_master) this.BUFFCOMP.vmdata_update(true)
|
if(this.is_master) this.BUFFCOMP.vmdata_update(true)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user