go_dreamfactory/modules/battle/fight/attribute/attributenumeric.go
2022-09-13 17:59:40 +08:00

53 lines
1.2 KiB
Go

package attribute
func NewAttributeNumeric(pData float32) *AttributeNumeric {
attribute := &AttributeNumeric{
BaseValue: NewFixedNumeric(pData),
ProValue: NewFixedNumeric(pData),
AppendValue: NewFixedNumeric(pData),
BuffProValue: NewFixedNumeric(pData),
BuffValue: NewFixedNumeric(pData),
}
attribute.SetBase(pData)
return attribute
}
type AttributeNumeric struct {
fixedValue *FixedPoint
/// <summary>
/// 基础数值
/// </summary>
BaseValue *FixedNumeric
/// <summary>
/// 附加数值
/// </summary>
AppendValue *FixedNumeric
/// <summary>
/// 附加百分比数值
/// </summary>
ProValue *FixedNumeric
/// <summary>
/// Buff附加数值
/// </summary>
BuffValue *FixedNumeric
/// <summary>
/// Buff附加百分比数值
/// </summary>
BuffProValue *FixedNumeric
}
func (this *AttributeNumeric) Value() float32 {
return this.fixedValue.Scalar()
}
func (this *AttributeNumeric) SetBase(value float32) float32 {
this.BaseValue.Set(value)
this.onChange()
return this.BaseValue.Value()
}
func (this *AttributeNumeric) onChange() {
// this.FixedValue = (BaseValue.Fixed*(1+ProValue.Fixed)+AppendValue.Fixed)*(1+BuffProValue.Fixed) + BuffValue.Fixed
}