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
///
/// 基础数值
///
BaseValue *FixedNumeric
///
/// 附加数值
///
AppendValue *FixedNumeric
///
/// 附加百分比数值
///
ProValue *FixedNumeric
///
/// Buff附加数值
///
BuffValue *FixedNumeric
///
/// Buff附加百分比数值
///
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 = (this.BaseValue.Fixed()*(1+this.ProValue.Fixed())+this.AppendValue.Fixed())*(1+this.BuffProValue.Fixed()) + this.BuffValue.Fixed()
}