56 lines
1.3 KiB
Go
56 lines
1.3 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) 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) onChange() {
|
|
// this.fixedValue = (this.BaseValue.Fixed()*(1+this.ProValue.Fixed())+this.AppendValue.Fixed())*(1+this.BuffProValue.Fixed()) + this.BuffValue.Fixed()
|
|
}
|