Unity BaseStatsManager (C#)
Most games have characters with stats. The goal of the BaseStatsManager is to provide a template for setting up relevant stats and being able to easily apply them to any new character inserted into a scene. This class is easily modifiable for any type of game and is basically a set of variable declarations.
BaseStatsManager.cs
using UnityEngine; using System.Collections; // Used to manipulate the stats of an object. For interpreting these stats, // communicate with the BaseObjManager. public class BaseStatsManager : MonoBehaviour { Â Â Â Â Â Â // this is the display name of the character. Â Â Â public string characterName =""; Â Â Â Â Â Â public int score; Â Â Â public int level; Â Â Â public int health; Â Â Â public int maxHealth; Â Â Â }
The BaseStatsManager, or some variation of it, should be attached to each object in a scene that has stats. Note that the BaseStatsManager is purely for the manipulation of stats – interpreting the stats (which includes destroying the object or pooling it) is intended to be handled in BaseObjManager.