Skip to content

VersusMatch

namespace Griff.Modules.Fighting;
public sealed class VersusMatch : Component, IPlaytestReport

A 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.

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.

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.

public ComputerBehavior ComputerBehavior { get; set; }

What the computer’s fighter does: fight, or stand, crouch or jump as a training dummy.

public ComputerDifficulty ComputerDifficulty { get; set; }

How well the computer fights.

public string? FightSound { get; set; }

A sound played as “Fight!” is.

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.

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.

public Vector2 FirstStart { get; set; }

Where the first fighter starts each round, as it was placed. Set by the game as the match starts.

public int FirstWins { get; set; }

Rounds the first fighter has won. Set by the game.

public string HitboxesShown { get; }

“On” while the hitboxes are drawn over the game (its Toggle Hitboxes action), “Off” otherwise: a training menu’s label.

public float IntroTime { get; set; }

Seconds “Round 1” is shown before the fighters can move.

public float KoFreeze { get; set; }

Seconds the game freezes on a K.O., for it to land hard.

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.

public string? RoundMessage { get; set; }

A message sent as each round starts, with its number as its data.

public string? RoundOverMessage { get; set; }

A message sent as a round is won, with the winner’s name as its data (“Draw” for neither).

public float RoundOverTime { get; set; }

Seconds after a K.O. (or the time running out) before the next round, or the winner.

public string? RoundSound { get; set; }

A sound played as each round is announced.

public float RoundTime { get; set; }

Seconds a round lasts before the time’s up (and more health left wins it). 0 for no clock.

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.

public string? Second { get; set; }

The second player’s fighter, by name: on the right as a round starts.

public string? SecondName { get; set; }

The second fighter’s name as shown. Set by the game.

public Vector2 SecondStart { get; set; }

Where the second fighter starts each round. Set by the game as the match starts.

public Color SecondTint { get; set; }

A tint for the second fighter when both picked the same one, so they can be told apart.

public int SecondWins { get; set; }

Rounds the second fighter has won. Set by the game.

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.

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.

public string? WinSound { get; set; }

A sound played as the match is won.

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.

public void Rematch()

Starts the match over from round 1: no rounds won, the fighters back in their places at full health.

public void ResetPositions()

Puts the fighters back in their places at full health, the round going on (training’s Reset).

public void ToggleHitboxes()

Shows the hitboxes over the game, or stops (training).

public override bool Uses(string property)
public event Action<Entity>? RoundWon

Raised as a round is won, with the winner’s fighter (null for a draw).

public event Action<Entity>? Won

Raised as the match is won, with the winner’s fighter (null for a draw).