W tym ostatnim kroku znajdziesz kompletny kod wykorzystany do utworzenia projektu. Każdy z poniższych nagłówków odpowiada nazwie pliku w projekcie, w którym znajduje się dany fragment kodu.
Spróbuj zmodyfikować kod i znaleźć inne sposoby na dodanie nowych funkcji do minigry. Oto kilka pomysłów, od których możesz zacząć:
Dodaj więcej poziomów, które postać będzie musiała przejść.
Monitoruj, jak długo zajęło graczowi rozwiązanie łamigłówki i ile ruchów wykonała postać na każdym poziomie.
Dodaj więcej poleceń dla postaci, aby stworzyć bardziej złożone łamigłówki, na przykład podnoszenie przedmiotów i umieszczanie ich na planszy.
submodules.verse
Plik projektu submodules.verse określa poziom dostępu dla podmodułów i zasobów w projekcie, aby można je było wykorzystać w kodzie Verse. Więcej szczegółów zawierają krok 5. Sterowanie postacią niezależną za pomocą UI i temat Uwidacznianie zasobów w UEFN dla Verse.
# This file sets the access levels for submodules in the project.
# Specifically, this file is making art assets accessible to the Verse files in the project
# so textures, meshes, and materials can be used in the UI and in the game.
# The submodule Textures.MiniGameUI below is the same as the folder
# Textures/MinigameUI that you can see in the project's Content Browser.
Textures := module:
MiniGameUI<public> := module{}
# The submodule VerseCommander below is the same as the folder
verse_starter_tags.verse
Plik projektu verse_starter_tags.verse zawiera definicję tagu rozgrywki verse_commander_minigame_tag, za pomocą którego skrypt postaci niezależnej w minigrze Komandor Verse może wyszukać urządzenie minigry Komandor Verse i nasłuchiwać jego zdarzeń. Więcej szczegółów zawiera krok 1. Tworzenie zachowania postaci niezależnej (NPC).
# This file contains the Gameplay Tags for the project.
# You can use Gameplay Tags to tag an object in the island
# and be able to query all objects that have the tag during the game using Verse.
using { /Verse.org/Simulation/Tags }
# The verse_commander_minigame_tag is for the Verse Commander Character NPC script
# to be able to find the Verse Commander Minigame device and listen to its events.
verse_commander_minigame_tag := class(tag){}
commands.verse
Plik projektu commands.verse w podmodule VerseCommander zawiera reprezentację danych wszystkich poleceń, jakie może otrzymać postać niezależna. Więcej szczegółów zawiera krok 4. Tworzenie reprezentacji danych poleceń.
# This file contains the data representation of all the commands that the NPC can receive
# and utilities for the data to help with debugging and troubleshooting issues.
# Each type of command that the NPC can perform will be an instance of this class.
# The class has the unique specifier to make instances of the class comparable.
# The class has the computes specifier to be able to instantiate it at module-scope.
# The class has the abstract specifier so it cannot be instantiated directly, and
# requires subclasses to implement any non-initialized functions, like DebugString().
command := class<computes><unique><abstract>:
DebugString():string
gameboard.verse
Plik projektu gameboard.verse w podmodule VerseCommander zawiera dane oraz zachowanie planszy. Więcej szczegółów zawiera krok 2. Definiowanie plansz do gry.
# This file contains the gameboard structure and how it works.
# The gameboard knows where the NPC is supposed to start on the board
# how many obstacles / barriers there are to getting to the end goal,
# and what the end goal is and when it has been reached.
using { /Fortnite.com/Devices }
using { /UnrealEngine.com/Temporary/SpatialMath }
using { /Verse.org/Simulation }
using { /Verse.org/Simulation/Tags }
# An obstacle on the gameboard, with an associated set of
ui_manager.verse
Plik projektu ui_manager.verse w podmodule VerseCommander zawiera kod tworzenia i modyfikowania wyglądu UI. Więcej szczegółów zawierają krok 5. Sterowanie postacią niezależną za pomocą UI.
# This file contains all the code to create and modify the UI
# in the Verse Commander minigame.
# The UI for the game contains:
# - Buttons that map to commands for the NPC: forward, turn left, turn right.
# - An execute button that tells the NPC to perform the queue of commands.
# - A remove button that removes the last command added.
# - A reset button that resets the current board and clears out the command queue.
# - A dynamic list of commands that grows wider when a player adds commands and shrinks when a player removes commands.
using { /Fortnite.com/Devices }
verse_commander_minigame.verse
Plik projektu verse_commander_minigame.verse w podmodule VerseCommander zawiera urządzenie Verse, które zarządza minigrą. Więcej szczegółów zawiera krok 6. Zarządzanie pętlą gry.
# This device is in charge of managing the minigame.
# In its Details panel in the editor, you can:
# - Define how many gameboards there are
# - The order you play the gameboards
# - All the details of the gameboard such as their obstacles.
using { /Fortnite.com/Devices }
using { /Fortnite.com/UI }
using { /UnrealEngine.com/Temporary }
using { /UnrealEngine.com/Temporary/Diagnostics }
verse_commander_character.verse
Plik projektu verse_commander_character.verse w podmodule VerseCommander zawiera logikę postaci niezależnej minigry. Więcej szczegółów zawiera krok 1. Tworzenie zachowania postaci niezależnej (NPC).
# This file handles the logic for the gameboard NPC. The NPC waits for commands from
# verse_commander_minigame, then executes movement based on those commands using navigation targets.
# It also tracks the NPC's position using a visual arrow that updates after each command.
using { /Fortnite.com/AI }
using { /Fortnite.com/Characters }
using { /Fortnite.com/Devices }
using { /UnrealEngine.com/Temporary/Diagnostics }
using { /UnrealEngine.com/Temporary/SpatialMath }
using { /Verse.org/Assets }