11000+款5星资源
8.5万+用户参与评分
10万+社区成员鼎力支持
每款资源都经过 Unity 审核
There comes a time when many a gamedev sets out for adventure but first must create their own stat class. That is to say a class which captures a game "stat", or "statistic" for lack of a better word, like health, attack, defense, etc. This one is mine. Oh wait! there is a better word: "attribute." But I don't want to take "attribute" from your game, so I'll call mine IModifiableValue<T>. Consider it a sound building block for you to create your own attribute class.
These attributes and their derivatives may affect and be effected by a multitude of transient things, e.g, a sword that bestows an attack advantage; a shield that raises one's defense; a ring that regenerates health. Because of that attributes ought to respect the following requirements:
- An attribute's value shall be altered non-destructively.
- Because so many things may alter an attribute, it shall notify us when changed.
See sample scene here.