Scaling Value
📈 ScalingValue Class
A numeric value that can scale with level.
Namespace:
Esper.Inventool.Stats
Access:public
Type:class
Attributes:[Serializable]
📦 Fields
public
numericType
NumericValue.NumericType
The numeric type.
public
value
NumericValue
The current value.
protected
excessValue
NumericValue
The last calculated excess value.
public
scalingSource
ScalingSource
The scaling source.
public
level
int
The current level.
public
maxLevel
int
The maximum level.
public
lowValue
NumericValue
The minimum value at the current level.
🔍 Properties
public
HighValue
NumericValue
The maximum value at the current level.
public
NextValue
NumericValue
The maximum value if leveled up.
public
MaxValue
NumericValue
The maximum value at the maximum level.
public
IsLevelMaxed
bool
If the level is maxed.
public
IsLow
bool
If the current value is equal to the low value.
public
IsHigh
bool
If the current value is equal to the high value.
📢 Events
public
onChanged
UnityEvent<NumericValue, NumericValue>
Invoked when the value changes. Arguments: new value, previous value.
public
onReachedHigh
UnityEvent
Invoked when the value reaches the high value.
public
onReachedLow
UnityEvent
Invoked when the value reaches the low value.
public
onLeveledUp
UnityEvent
Invoked when the level increases.
public
onLeveledDown
UnityEvent
Invoked when the level decreases.
🧰 Constructors
public
ScalingValue()
Default constructor.
public
ScalingValue(ScalingValue scalingValue)
Copy constructor.
public
ScalingValue(NumericValue value, NumericValue initialValue)
Creates a non-scaling value.
public
ScalingValue(NumericValue value, NumericValue initialValue, NumericValue increment)
Creates a linearly scaling value.
public
ScalingValue(NumericValue value, NumericValue initialValue, NumericValue min, NumericValue max, AnimationCurve curve)
Creates a curve-scaling value.
public
ScalingValue(NumericValue value, ScalingSource scalingSource)
Creates a scaling value with a given source.
🧰 Methods
public
SetMaxLevel(int maxLevel)
void
Sets the maximum level.
public
SetLevel(int level)
void
Sets the current level.
public
LevelUp(int amount = 1)
int
Increases the level. Returns excess amount.
public
LevelDown(int amount = 1)
int
Decreases the level. Returns excess amount.
public
Deplete()
void
Sets the current level to 1.
public
Add(ScalingValue other)
void
Adds another scaling value.
public
Add(NumericValue other)
void
Adds a numeric value.
public
Add(int amount)
void
Adds an integer.
public
Add(float amount)
void
Adds a float.
public
Subtract(ScalingValue other)
void
Subtracts another scaling value.
public
Subtract(NumericValue other)
void
Subtracts a numeric value.
public
Subtract(int amount)
void
Subtracts an integer.
public
Subtract(float amount)
void
Subtracts a float.
public
Multiply(ScalingValue other)
void
Multiplies by another scaling value.
public
Multiply(NumericValue other)
void
Multiplies by a numeric value.
public
Multiply(int amount)
void
Multiplies by an integer.
public
Multiply(float amount)
void
Multiplies by a float.
public
Divide(ScalingValue other)
void
Divides by another scaling value.
public
Divide(NumericValue other)
void
Divides by a numeric value.
public
Divide(int amount)
void
Divides by an integer.
public
Divide(float amount)
void
Divides by a float.
public
GetExcessValue()
NumericValue
Gets the last calculated excess value.
public
ToString()
string
Returns the value as a string.
public
ToFloat()
float
Converts the value to a float.
public
ToInt()
int
Converts the value to an int.
➗ Operator Overloads
+
ScalingValue + ScalingValue
ScalingValue
Adds two scaling values.
+
ScalingValue + NumericValue
ScalingValue
Adds a numeric value.
+
ScalingValue + int
ScalingValue
Adds an integer.
+
ScalingValue + float
ScalingValue
Adds a float.
-
ScalingValue - ScalingValue
ScalingValue
Subtracts two scaling values.
-
ScalingValue - NumericValue
ScalingValue
Subtracts a numeric value.
-
ScalingValue - int
ScalingValue
Subtracts an integer.
-
ScalingValue - float
ScalingValue
Subtracts a float.
*
ScalingValue * ScalingValue
ScalingValue
Multiplies two scaling values.
*
ScalingValue * NumericValue
ScalingValue
Multiplies by a numeric value.
*
ScalingValue * int
ScalingValue
Multiplies by an integer.
*
ScalingValue * float
ScalingValue
Multiplies by a float.
/
ScalingValue / ScalingValue
ScalingValue
Divides two scaling values.
/
ScalingValue / NumericValue
ScalingValue
Divides by a numeric value.
/
ScalingValue / int
ScalingValue
Divides by an integer.
/
ScalingValue / float
ScalingValue
Divides by a float.
Creating a Scaling Value
To create a ScalingValue
, you need to define the scaling. This can be done by creating and providing the Scaling Source or by simply providing the appropriate values in the constructor.
The default current level set is 1 and the default max level set is the 'Default Max Level' value that you can set from Settings.
No Scaling
// Parameters: current, intitial
ScalingValue myScalingValue = new ScalingValue(100, 100);
Linear Scaling
// Parameters: current, intitial, increment
ScalingValue myScalingValue = new ScalingValue(100, 100, 10);
Curve Scaling
// Parameters: current, intitial, min, max, animation curve
ScalingValue myScalingValue = new ScalingValue(100, 100, 1, 100, myAnimationCurve);
Managing Levels
Setting the Level
To set the max value, use the SetMaxLevel
method.
myScalingValue.SetMaxLevel(100);
The SetLevel
will set the current level to a specific value.
myScalingValue.SetLevel(1);
Increasing the Level
Use the LevelUp
method to increase the level by a given amount. This method returns the unused excess amount. The level cannot go over the max level.
myScalingValue.LevelUp(1);
Decreasing the Level
Use the LevelDown
method to decrease the level by a given amount. This method returns the unused excess amount. The level cannot go lower than 1.
myScalingValue.LevelDown(1);
Optionally, you can use the Deplete
method to set the level to 1.
myScalingValue.Deplete();
Last updated