about 2 minutes unity
Item Attribute System
Some games have a lot of items with unique stats. This is the besy way I found to handle it.
In Rifle Storm and I’m sure many other games have the issue of assigning special properties to many items. Since this property could be used on only one item, it doesn’t make sense to add a new column for all the other items.
The solution is to create a generic class with just an enum and a value. And hold all of them inside an array.
This allows any type of stat to be assigned to an item.
And since these are just enums in an array. It’s possible to combine stat lists from other items to an entity.
The Stat Enum
First, I created a generic StatVal class, which simply holds a Stat enum and an integer.
// StatVal.cs
public
public
Define all your custom enums here. It’s simple to add more stats when needed.
Adding Stats to Items

All stats are assigned in Excel and imported automatically. More info here.
Using Them For Descriptions
Here is an example of how these values are used for tooltips and item descriptions.
// TextUtil.cs
public static string
Assigning Stats To Entities
Stats are easily assigned to entities. Any data from it’s class or items will automatically be applied to the entities single statList.
// Equip.cs
// init the entities base stats
statList = GameConfig.BASE_JUMP;
statList = GameConfig.BASE_MOVE;
statList = GameConfig.BASE_EVASION;
statList = GameConfig.BASE_COVER;
statList = GameConfig.BASE_SPEED;
statList = klass.Health;
// load in stats from it's class
statList.;
// add stat bonuses
statList.;
Using Their Values
Their values can easily be used like for modifying the damage of an entity.
// Equip.cs
public float DamageMod
Some times a stat just provides a bonus if it’s there.
if
Comments
No comments yet.