BomberUnits
...a Unity learning project
ColorScheme Class Reference

Holds one of the colors players can choose. More...

+ Collaboration diagram for ColorScheme:

Public Member Functions

 ColorScheme (Color color)
 Constructor, taking the single relevant property wrapped by this class. More...
 
void Register ()
 
bool IsInUse ()
 
void Use ()
 
void Free ()
 
void UseInsteadOf (ColorScheme previous)
 
Color GetValue ()
 

Static Public Member Functions

static ColorScheme FromKey (int dictKey)
 Returns the saved instance of this class with the fitting key.
 
static IEnumerable< ColorSchemeGetAll ()
 Returns all instances of this class.
 
static ColorScheme GetNextUnused ()
 Returns the first instance of this class, which is not marked as taken.
 
static implicit operator Color (ColorScheme c)
 Implicit conversion to the held property made possible. Cool.
 

Public Attributes

Color color
 The Unity color represented by this player property.
 

Properties

int dictKey [get, private set]
 

Private Attributes

bool inUse
 Whether this has been chosen already by a player.
 

Static Private Attributes

static Dictionary< int, ColorSchemeinstances = new Dictionary<int, ColorScheme>()
 The dict for this property holds all instances, referenced by their int keys.
 

Detailed Description

Holds one of the colors players can choose.

A list of available colors is kept in player management One color is assigned to each local player, marking this color as taken in the process. Each instance is registered by the GameSettings during setup and is assigned a key as ID. This allows saving and restoring, as well as slim transmission of these properties via their key.

Definition at line 11 of file ColorScheme.cs.

Constructor & Destructor Documentation

◆ ColorScheme()

ColorScheme ( Color  color)
inline

Constructor, taking the single relevant property wrapped by this class.

Todo:
: Use templates to create these player property classes! (Define versions e.g. in the settings)

Definition at line 71 of file ColorScheme.cs.

Member Function Documentation

◆ Register()

void Register ( )
inline
Todo:
Can this not be done by the constructor?

Definition at line 77 of file ColorScheme.cs.


The documentation for this class was generated from the following file: