go_dreamfactory/modules/battle/fight/fightrole.go
2022-09-15 15:56:39 +08:00

46 lines
1011 B
Go

package fight
import (
"go_dreamfactory/modules/battle/fight/attribute"
"go_dreamfactory/modules/battle/fight/core"
cfg "go_dreamfactory/sys/configure/structs"
)
type FightRole struct {
/// <summary>
/// 战斗实例
/// </summary>
fight core.IFight
/// <summary>
/// 角色数据
/// </summary>
data core.FightRoleData
CurrentHealth attribute.HealthPoint
}
/// <summary>
/// 接收伤害
/// </summary>
func (this *FightRole) ReceiveDamage(DamageValue float32) {
this.CurrentHealth.Minus(DamageValue)
// FightDebug.Log($"========接收伤害:{Data.UniqueId} 变化值={DamageValue} 当前血量={CurrentHealth.Value}");
if this.IsDead() {
//有不死buff生命值设置为1
for _, v := range this.data.BuffStore.HasBuffTypes {
if v == cfg.GameBuffType_UNDEAD {
this.CurrentHealth.Hp.Set(1)
break
}
}
this.Dead()
}
}
func (this *FightRole) IsDead() bool {
return this.CurrentHealth.Value() <= 0
}
func (this *FightRole) Dead() {
this.data.ALive = false
}