# This is our main script file. # It manages the egg collection game. using { /Fortnite.com/Devices } using { /Fortnite.com/Characters } using { /Fortnite.com/Game } using { /Verse.org/Simulation } using { /UnrealEngine.com/Temporary/Diagnostics } # We create a new "Game" device. # This device holds all our game logic. egg_collector_game := class(creative_device): # A reference to the trigger device placed at the finish line. # Wire this up in the UEFN editor by selecting the trigger_device here. @editable FinishTrigger : trigger_device = trigger_device{} # A reference to the item spawner that provides the Heal Egg. # Wire this up in the UEFN editor. @editable HealEggSpawner : item_spawner_device = item_spawner_device{} # A reference to the item spawner that provides the Hop Egg. # Wire this up in the UEFN editor. @editable HopEggSpawner : item_spawner_device = item_spawner_device{} # We track how many eggs each player has collected using a counter. # Both spawners will signal this when a player picks up an egg. @editable EggCounter : player_counter_device = player_counter_device{} # This function runs when the game starts. OnBegin() : void = Print("Welcome to the Egg Hunt! Find the eggs to win!") # Listen for players stepping on the finish trigger. FinishTrigger.TriggeredEvent.Subscribe(OnPlayerEnteredTrigger) # This function runs when a player enters the trigger. # It checks if the player has collected enough eggs. # note: Verse cannot inspect a player's inventory directly at runtime; # we use a counter_device wired to both item spawners' PickedUpEvent # to track how many eggs (out of 2) the player has collected. OnPlayerEnteredTrigger(TriggeringAgent : ?agent) : void = if (Agent := TriggeringAgent?): # Get the current count from the counter device. # A value of 2 means the player picked up both eggs. CurrentCount := EggCounter.GetCount() if (CurrentCount >= 2): Print("You found all the eggs! You win!") else: Print("Keep looking! You need more eggs.")