VersusMatch
namespace Griff.Modules.Fighting;
public sealed class VersusMatch : Component, IPlaytestReportA fighting game’s match between two fighters, with no code: rounds (best of three to start with) against a clock, each starting with “Round 1” and “Fight!” and ended by a knockout (a fighter’s Health running out) or by the time running out (more health left wins), the fighters back in their places at full health for the next; and once a fighter has won enough rounds, “Kenta Wins” and its WinMessage, which opens a panel with a rematch. With no rounds to win it’s a training session: no clock, and a fighter knocked out gets up again.
It puts in the fighters picked on a CharacterSelect (their prefabs, kept in the save data under Picks) in place of the two in the scene as it starts, keeping their names, places and PlayedBy, and gives the second to the computer (ComputerFighter) when one player plays alone. Its outputs (the round, the time left, each side’s rounds won and name, what’s announced, the winner) are for a HUD’s texts, bars and stars; its phase, clock and wins are kept with the scene, so a rewind carries on mid-round.
This is a component: its saved properties are on its component page.
Properties
Section titled “Properties”Announcement
Section titled “Announcement”public string? Announcement { get; set; }What’s announced in the middle of the screen: “Round 1”, “Fight!”, “K.O.”, “Time”, “Kenta Wins”; empty for nothing. Set by the game.
public float Clock { get; set; }Seconds left on the round’s clock. Set by the game.
Computer
Section titled “Computer”public bool Computer { get; set; }The computer plays the second fighter (as it does when the picks say so): a ComputerFighter is given to it.
ComputerBehavior
Section titled “ComputerBehavior”public ComputerBehavior ComputerBehavior { get; set; }What the computer’s fighter does: fight, or stand, crouch or jump as a training dummy.
ComputerDifficulty
Section titled “ComputerDifficulty”public ComputerDifficulty ComputerDifficulty { get; set; }How well the computer fights.
FightSound
Section titled “FightSound”public string? FightSound { get; set; }A sound played as “Fight!” is.
Fighting
Section titled “Fighting”public bool Fighting { get; }True while the fighters can fight: the round under way.
public string? First { get; set; }The first player’s fighter, by name: on the left as a round starts.
FirstName
Section titled “FirstName”public string? FirstName { get; set; }The first fighter’s name as shown: its character’s (the prefab it was made from), or its own. Set by the game.
FirstStart
Section titled “FirstStart”public Vector2 FirstStart { get; set; }Where the first fighter starts each round, as it was placed. Set by the game as the match starts.
FirstWins
Section titled “FirstWins”public int FirstWins { get; set; }Rounds the first fighter has won. Set by the game.
HitboxesShown
Section titled “HitboxesShown”public string HitboxesShown { get; }“On” while the hitboxes are drawn over the game (its Toggle Hitboxes action), “Off” otherwise: a training menu’s label.
IntroTime
Section titled “IntroTime”public float IntroTime { get; set; }Seconds “Round 1” is shown before the fighters can move.
KoFreeze
Section titled “KoFreeze”public float KoFreeze { get; set; }Seconds the game freezes on a K.O., for it to land hard.
KoSound
Section titled “KoSound”public string? KoSound { get; set; }A sound played on a K.O.
public bool Over { get; }True once the match is won.
public VersusPhase Phase { get; set; }Where the match has got to. Set by the game.
public string? Picks { get; set; }A name in the save data the fighters picked are kept under (as a CharacterSelect’s Save As keeps them), e.g. “Pick”: “Pick.1” and “Pick.2” hold the prefabs to put in place of the first and second fighters as the match starts, and “Pick.Computer” says the computer plays the second. Empty fights the two in the scene.
public int Round { get; set; }The round being fought, from 1. Set by the game.
RoundMessage
Section titled “RoundMessage”public string? RoundMessage { get; set; }A message sent as each round starts, with its number as its data.
RoundOverMessage
Section titled “RoundOverMessage”public string? RoundOverMessage { get; set; }A message sent as a round is won, with the winner’s name as its data (“Draw” for neither).
RoundOverTime
Section titled “RoundOverTime”public float RoundOverTime { get; set; }Seconds after a K.O. (or the time running out) before the next round, or the winner.
RoundSound
Section titled “RoundSound”public string? RoundSound { get; set; }A sound played as each round is announced.
RoundTime
Section titled “RoundTime”public float RoundTime { get; set; }Seconds a round lasts before the time’s up (and more health left wins it). 0 for no clock.
RoundsToWin
Section titled “RoundsToWin”public int RoundsToWin { get; set; }Rounds a fighter must win to win the match: 2 is best of three. 0 for a training session with no rounds or clock.
Second
Section titled “Second”public string? Second { get; set; }The second player’s fighter, by name: on the right as a round starts.
SecondName
Section titled “SecondName”public string? SecondName { get; set; }The second fighter’s name as shown. Set by the game.
SecondStart
Section titled “SecondStart”public Vector2 SecondStart { get; set; }Where the second fighter starts each round. Set by the game as the match starts.
SecondTint
Section titled “SecondTint”public Color SecondTint { get; set; }A tint for the second fighter when both picked the same one, so they can be told apart.
SecondWins
Section titled “SecondWins”public int SecondWins { get; set; }Rounds the second fighter has won. Set by the game.
TimeLeft
Section titled “TimeLeft”public int TimeLeft { get; }The seconds left on the clock, as a whole number counting down (99, 98…), for a HUD.
public float Timer { get; set; }Seconds until it moves on from the intro or a round’s end, or stops showing “Fight!”. Set by the game.
WinMessage
Section titled “WinMessage”public string? WinMessage { get; set; }A message sent as the match is won, with the winner’s name as its data: a panel opens on it.
WinSound
Section titled “WinSound”public string? WinSound { get; set; }A sound played as the match is won.
Winner
Section titled “Winner”public string? Winner { get; set; }The fighter that won the match (its name, as shown), or “Draw”; empty until it’s over. Set by the game.
Methods
Section titled “Methods”Rematch
Section titled “Rematch”public void Rematch()Starts the match over from round 1: no rounds won, the fighters back in their places at full health.
ResetPositions
Section titled “ResetPositions”public void ResetPositions()Puts the fighters back in their places at full health, the round going on (training’s Reset).
ToggleHitboxes
Section titled “ToggleHitboxes”public void ToggleHitboxes()Shows the hitboxes over the game, or stops (training).
public override bool Uses(string property)Events
Section titled “Events”RoundWon
Section titled “RoundWon”public event Action<Entity>? RoundWonRaised as a round is won, with the winner’s fighter (null for a draw).
public event Action<Entity>? WonRaised as the match is won, with the winner’s fighter (null for a draw).