CharacterSelect
namespace Griff.Modules.Fighting;
public sealed class CharacterSelect : Component, IPlaytestReportA fighting game’s character select, with no code: each player at this machine moves their own cursor over the characters’ cards (the entity’s children, in order, one for each of its Characters) with their own keys or controller and picks one with a button; once everyone has, the picks are kept in the save data and Scene loads, where a VersusMatch puts them in. With one player and Computer, the computer takes the character after the player’s. A click (or a tap) on a card picks it for the first player still choosing.
Each player’s cursor is an entity it moves over the card picked (FirstCursor, SecondCursor), and a preview of what each has on (FirstPreview, SecondPreview) takes the character’s picture and clips. The players’ controls are shared out as Game.LocalPlayers says (two at one keyboard, two controllers, or one of each); its Swap Controls action swaps the first two’s.
This is a component: its saved properties are on its component page.
Properties
Section titled “Properties”BackAction
Section titled “BackAction”public string? BackAction { get; set; }The input action that takes a pick back.
CharacterList
Section titled “CharacterList”public IReadOnlyList<string> CharacterList { get; }Its Characters, one by one.
Characters
Section titled “Characters”public string? Characters { get; set; }The characters to pick from, by their fighters’ prefabs, separated by commas, in the order of its cards: “Kenta, Mira”.
Columns
Section titled “Columns”public int Columns { get; set; }How many cards to a row: the cursors move across and down them. 0 puts them all in one row.
Computer
Section titled “Computer”public bool Computer { get; set; }With one player: the computer takes the second fighter (the character after the player’s), and the match gives it to the computer.
Controllable
Section titled “Controllable”public bool Controllable { get; set; }Untick it to ignore the players’ controls and clicks (its Pick action still picks). Its Focus action ticks it and unticks it on everything else the players play.
public float Delay { get; set; }Seconds after the last pick before the scene loads, to see who’s fighting whom.
FirstControls
Section titled “FirstControls”public string FirstControls { get; }What the first player plays with: “Left keys (WASD)”, “Gamepad 1”… Set by the game.
FirstCursor
Section titled “FirstCursor”public string? FirstCursor { get; set; }The first player’s cursor, by name: moved over the card they’re on.
FirstIndex
Section titled “FirstIndex”public int FirstIndex { get; set; }The card the first player is on, from 0. Set by the game.
FirstName
Section titled “FirstName”public string FirstName { get; }The character the first player is on (or picked): its name.
FirstPicked
Section titled “FirstPicked”public bool FirstPicked { get; set; }True once the first player has picked. Set by the game.
FirstPreview
Section titled “FirstPreview”public string? FirstPreview { get; set; }What shows the first player’s character big, by name: its sprite (and animation) take the character’s.
FirstStatus
Section titled “FirstStatus”public string FirstStatus { get; }“Ready!” once the first player has picked, “Choose” until then: a label.
MoveSound
Section titled “MoveSound”public string? MoveSound { get; set; }A sound played as a cursor moves.
PickActions
Section titled “PickActions”public string? PickActions { get; set; }The input actions that pick, separated by commas.
PickSound
Section titled “PickSound”public string? PickSound { get; set; }A sound played as a character is picked.
Players
Section titled “Players”public int Players { get; set; }How many people pick: 2 for versus, 1 against the computer or to train.
SaveAs
Section titled “SaveAs”public string? SaveAs { get; set; }A name to keep the picks under in the save data, e.g. “Pick”: “Pick.1” and “Pick.2” (the characters), “Pick.Computer” (whether the computer plays the second), and “Pick.Scene” (this scene, for a “Character Select” button to come back to).
public string? Scene { get; set; }The scene to load once everyone has picked, e.g. “Stage”.
SecondControls
Section titled “SecondControls”public string SecondControls { get; }What the second player plays with. Set by the game.
SecondCursor
Section titled “SecondCursor”public string? SecondCursor { get; set; }The second player’s cursor, by name.
SecondIndex
Section titled “SecondIndex”public int SecondIndex { get; set; }The card the second player is on, from 0. Set by the game.
SecondName
Section titled “SecondName”public string SecondName { get; }The character the second player (or the computer) is on.
SecondPicked
Section titled “SecondPicked”public bool SecondPicked { get; set; }True once the second player (or the computer) has picked. Set by the game.
SecondPreview
Section titled “SecondPreview”public string? SecondPreview { get; set; }What shows the second player’s character big, by name.
SecondStatus
Section titled “SecondStatus”public string SecondStatus { get; }“Ready!” once the second player has picked; “Computer” for the computer’s.
public float Timer { get; set; }Seconds until the scene loads, once everyone has picked. Set by the game.
Methods
Section titled “Methods”CharacterName
Section titled “CharacterName”public static string CharacterName(string? prefab)The character’s name a prefab’s name or path gives: “Prefabs/Kenta.prefab” (and “Kenta”) is Kenta.
public void Pick(string character)Picks the character called character for the first player still choosing, as a click on its card does.
SwapControls
Section titled “SwapControls”public void SwapControls()Swaps the first two players’ controls: the one at the keyboard and the one on the controller change places (kept with the player’s settings).
public override bool Uses(string property)Events
Section titled “Events”Picked
Section titled “Picked”public event Action<CharacterSelect>? PickedRaised as everyone has picked.