Created
April 4, 2025 14:41
-
-
Save noahjames404/95729779f047bdde2652ce81fb4d7f8f to your computer and use it in GitHub Desktop.
Unity stat/attribute
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| using UnityEngine; | |
| namespace kokomeron | |
| { | |
| [System.Serializable] | |
| public class Stat | |
| { | |
| [SerializeField] | |
| private float baseValue; | |
| [SerializeField] | |
| private float addons; | |
| [SerializeField] | |
| private float multiplier = 1; | |
| public float BaseValue { | |
| get => baseValue; | |
| set | |
| { | |
| baseValue = value; | |
| onStatUpdate?.Invoke(getValue()); | |
| } | |
| } | |
| public float Addons { | |
| get => addons; | |
| set | |
| { | |
| addons = value; | |
| onStatUpdate?.Invoke(getValue()); | |
| } | |
| } | |
| public float Multiplier { | |
| get => multiplier; | |
| set | |
| { | |
| multiplier = value; | |
| onStatUpdate?.Invoke(getValue()); | |
| } | |
| } | |
| public delegate void OnStatUpdate(float value); | |
| public event OnStatUpdate onStatUpdate; | |
| public float getValue() | |
| { | |
| return BaseValue * Multiplier + Addons; | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment