# This is the main script for our Reusable Game Manager. # It controls the flow from Lobby -> Game -> Results. # We define a "State" variable. # Think of this like the "Storm Phase" in Battle Royale. # It can only be one thing at a time: Lobby, Playing, or Finished. CurrentState := "Lobby" # This is our "Editable Object" for the timer. # You can change this number in the UEFN editor without touching code. GameDuration := 60.0 # Seconds # This is a "Function". # Think of it like a specific move in a fighting game. # When we call this function, the code inside runs. StartGame := func(): # 1. Update the State CurrentState = "Playing" # 2. Announce to the chat (optional, but fun) Print("Game Started! Go go go!") # 3. Start the timer loop StartTimer() # This function handles the countdown. # It’s like a storm timer that shrinks the zone. StartTimer := func(): # We wait for the duration set in the Editable Object Wait(GameDuration) # When time is up, switch states CurrentState = "Finished" Print("Time's Up! Back to Hub!") # Here you would add code to teleport players back to the hub # and update the score display. EndGame() # This function is called when the game ends. EndGame := func(): # Reset the state so the manager is ready for the next round CurrentState = "Lobby" # In a real island, you’d trigger the "Hub" devices here # e.g., DisableArenaDevices() # e.g., EnableHubDevices() # This is the "Event Handler". # Think of this like a "Trigger Volume" that listens for a signal. # In a real setup, you’d bind this to a "Start Game" device. # For this demo, we’ll just call StartGame() manually to show it works. OnBegin := func(): # When the island starts, we are in the Lobby CurrentState = "Lobby" Print("Lobby Active. Waiting for players...") # SIMULATION: In your actual island, you wouldn't call this here. # You would wire a "Start Game" device to call StartGame(). # But for testing, let's start it immediately. StartGame()