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) Fixed() FixedPoint {
return this.fixedValue
}
func (this *AttributeNumeric) Value() float32 {
return this.fixedValue.Scalar()
}
///基础数值
func (this *AttributeNumeric) SetBase(value float32) float32 {
this.BaseValue.SetFloat(value)
this.onChange()
return this.BaseValue.Value()
}
func (this *AttributeNumeric) AddBase(value float32) float32 {
this.BaseValue.Add(value)
this.onChange()
return this.BaseValue.Value()
}
func (this *AttributeNumeric) MinusBase(value float32) float32 {
this.BaseValue.Minus(value)
this.onChange()
return this.BaseValue.Value()
}
///附加数值
func (this *AttributeNumeric) SetAppend(value float32) float32 {
this.AppendValue.SetFloat(value)
this.onChange()
return this.AppendValue.Value()
}
func (this *AttributeNumeric) AddAppend(value float32) float32 {
this.AppendValue.Add(value)
this.onChange()
return this.AppendValue.Value()
}
func (this *AttributeNumeric) MinusAppend(value float32) float32 {
this.AppendValue.Minus(value)
this.onChange()
return this.AppendValue.Value()
}
///附加百分比数值
func (this *AttributeNumeric) SetPro(value float32) float32 {
this.ProValue.SetFloat(value)
this.onChange()
return this.ProValue.Value()
}
func (this *AttributeNumeric) AddPro(value float32) float32 {
this.ProValue.Add(value)
this.onChange()
return this.ProValue.Value()
}
func (this *AttributeNumeric) MinusPro(value float32) float32 {
this.ProValue.Minus(value)
this.onChange()
return this.ProValue.Value()
}
/// Buff附加数值
func (this *AttributeNumeric) SetBuff(value float32) float32 {
this.BuffValue.SetFloat(value)
this.onChange()
return this.BuffValue.Value()
}
func (this *AttributeNumeric) AddBuff(value float32) float32 {
this.BuffValue.Add(value)
this.onChange()
return this.BuffValue.Value()
}
func (this *AttributeNumeric) MinusBuff(value float32) float32 {
this.BuffValue.Minus(value)
this.onChange()
return this.BuffValue.Value()
}
/// Buff附加百分比数值
func (this *AttributeNumeric) SetBuffPro(value float32) float32 {
this.BuffProValue.SetFloat(value)
this.onChange()
return this.BuffProValue.Value()
}
func (this *AttributeNumeric) AddBuffPro(value float32) float32 {
this.BuffProValue.Add(value)
this.onChange()
return this.BuffProValue.Value()
}
func (this *AttributeNumeric) MinusBuffPro(value float32) float32 {
this.BuffProValue.Minus(value)
this.onChange()
return this.BuffProValue.Value()
}
func (this *AttributeNumeric) onChange() {
this.fixedValue = (FixedPoint_Multiply(this.BaseValue.Fixed(), (NewFixedPoint(1)+this.ProValue.Fixed())) + FixedPoint_Multiply(this.AppendValue.Fixed(), (NewFixedPoint(1)+this.BuffProValue.Fixed())) + this.BuffValue.Fixed())
}