Recap: Round Manager
Part of the Building Real Games section of Coddy's Unity journey. Lesson 16 of 56.
Challenge
EasyA coin grab in 3 rounds of 4 seconds. The arrows walk the Player (ready). Write the RoundManager and the Coin scripts; the Inspector has filled the RoundManager's fields with the panels, the texts, rounds (3) and roundTime (4).
- The RoundManager is a singleton, so each coin reaches it with no Inspector field.
- It has three states. Ready shows only
readyPanel, withroundTextnaming the round (Round 1, thenRound 2...), and Space starts the round. Playing shows onlyplayPaneland lastsroundTimeseconds; then the next round is Ready, or after the last round the game is Finished. Finished shows onlyfinishedPanel, withfinalTextgiving the coins, asCoins: 3, and nothing starts it again. - A coin the player touches during a round counts, shows the total in
coinsText(Coins: 2) and is removed. A coin touched between rounds does not count and stays where it is.
Press Play and play all three rounds, then Check.
Try it yourself
using UnityEngine;
using TMPro;
public class RoundManager : MonoBehaviour
{
public GameObject readyPanel;
public GameObject playPanel;
public GameObject finishedPanel;
public TMP_Text roundText;
public TMP_Text coinsText;
public TMP_Text finalText;
public int rounds = 3;
public float roundTime = 4f;
// A singleton with three states: Ready, Playing and Finished
}
All lessons in Building Real Games
2Buttons and Screens
Buttons and onClickLambdasWiring in the InspectorPanels On and OffHealth BarsRecap: Upgrade Shop5Saving with PlayerPrefs
Save a NumberLoad with a DefaultHigh ScoreSave SettingsRecap: Coins in the Bank3The Game Manager
One Script Runs the GameThe SingletonGame StatesSwitching on the StateRecap: Round Manager6Project: Endless Runner
Three LanesObstacles Ahead9The New Input System
Two Input SystemsKeyboard and MousePressed This FrameInput ActionsRecap: Input Swap