142 lines
3.5 KiB
Go
142 lines
3.5 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
|
|
}
|
|
|
|
/// <summary>
|
|
/// 属性数值
|
|
/// </summary>
|
|
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) 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())
|
|
}
|