Class PlayerColors

Namespace
Unity.Multiplayer.Core

Player colours (UM-T55): the palette every MindAttic game offers, the colour a player who never picked one is drawn in (their seat's palette colour, so neighbours differ), and the format a colour change must have. Engine-free so dotnet test covers it; the adapter and the front end convert to Unity colours.

public static class PlayerColors
Inheritance
PlayerColors
Inherited Members

Properties

Palette

Eight opaque colours that stay distinct from one another and readable on dark and light backgrounds (the same palette Unity.Shared picks a default from), in seat order.

public static IReadOnlyList<PlayerColor> Palette { get; }

Property Value

IReadOnlyList<PlayerColor>

PaletteNames

The names of Palette's colours, in order.

public static IReadOnlyList<string> PaletteNames { get; }

Property Value

IReadOnlyList<string>

Methods

ForSeat(int)

The palette colour for seat seat (wrapping round after eight).

public static PlayerColor ForSeat(int seat)

Parameters

seat int

Returns

PlayerColor

IsUnset(PlayerColor)

True when color means "not picked": opaque white (White, what a PlayerIdentity carries by default) or fully transparent.

public static bool IsUnset(PlayerColor color)

Parameters

color PlayerColor

Returns

bool

NearestPaletteIndex(PlayerColor)

The index of the palette colour nearest color.

public static int NearestPaletteIndex(PlayerColor color)

Parameters

color PlayerColor

Returns

int

Resolve(PlayerColor, int)

The colour a player in seat seat is drawn in: chosen made opaque, or the seat's palette colour when they never picked one (IsUnset(PlayerColor)).

public static PlayerColor Resolve(PlayerColor chosen, int seat)

Parameters

chosen PlayerColor
seat int

Returns

PlayerColor

ToHex(PlayerColor)

color as #RRGGBB (alpha left out), upper case.

public static string ToHex(PlayerColor color)

Parameters

color PlayerColor

Returns

string

TryParse(string, out PlayerColor)

Reads #RRGGBB or #RRGGBBAA (the # optional, any case). False for anything else.

public static bool TryParse(string text, out PlayerColor color)

Parameters

text string
color PlayerColor

Returns

bool

Validate(PlayerColor)

Why color cannot be a player's colour (it must be opaque), or null when it can.

public static string Validate(PlayerColor color)

Parameters

color PlayerColor

Returns

string