go_dreamfactory/modules/battle/fight/fightrole.go
2022-09-21 14:44:44 +08:00

55 lines
1.3 KiB
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
}
func (this *FightRole) Initialize(pData core.FightRoleData) {
// this.data = pData
// this.CurrentHealth = attribute.NewHealthPoint(this.data.Hp)
// this.CurrentHealth.Reset()
// this.data.BuffStore.OwnerRole = this
// this.data.PassiveStore.OwnerRole = this
}
/// <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.SetFloat(1)
break
}
}
this.Dead()
}
}
func (this *FightRole) IsDead() bool {
return this.CurrentHealth.Value() <= 0
}
func (this *FightRole) Dead() {
this.data.ALive = false
}