미니게임의 핵심 비헤이비어는 verse_commander_minigame Verse 장치에서 정의됩니다. 이 장치는 미니게임을 시작하고, UI와 캐릭터 간의 통신을 처리하고, 게임에서 사용되는 보드를 실행합니다.
이 장치에는 에디터에서 수정 가능한 다음과 같은 필드가 있습니다.
HUDController: 모든 기본 포트나이트 HUD 구성요소를 제거하기 위한 HUD 컨트롤러 장치입니다.
PlayVerseCommanderButton: 미니게임을 시작하는 버튼 장치입니다.
NPCSpawner: 미니게임용 캐릭터를 생성할 수 있는 NPC 생성 장치입니다.
Gameboards: 게임의 보드 목록입니다. 보드는 목록에 나타나는 순서대로 플레이됩니다.
UICommandLimit: 화면에서 목록 하단에 있는 큐에 등록할 수 있는 명령의 최대 한도입니다.
장치에는 캐릭터와 통신하고, 캐릭터에게 정보(캐릭터가 실행할 명령 목록, 보드 리셋 시 캐릭터가 순간이동할 트랜스폼)를 전달하기 위한 커스텀 이벤트도 포함되어 있습니다.
# A Verse-authored creative device that can be placed in a level
verse_commander_minigame := class(creative_device):
# The HUD Controller device for the minigame.
@editable
HUDController<private>:hud_controller_device = hud_controller_device{}
# The button that starts the minigame.
@editable
PlayVerseCommanderButton:button_device = button_device{}
미니게임 시작하기
Verse 커맨더 미니게임 장치는 모든 플레이어가 미니게임을 시작하기 전에 컴퓨터에서 플레이어가 버튼 장치와 상호작용할 때까지 대기합니다. 이러한 대기는 루프입니다. 모든 레벨을 마치면 원하는 횟수만큼 미니게임을 리플레이할 수 있습니다.
# Runs when the device is started in a running game.
OnBegin<override>()<suspends>:void=
spawn{Cinematic.EnterCinematicModeForAll(GetPlayspace().GetPlayers())}
loop:
PlayVerseCommanderButton.InteractedWithEvent.Await()
Setup()
# Wait for all Gameboards to be set up.
Sleep(2.0)
게임 루프
게임 루프는 현재 보드를 얻으면 시작됩니다. 플레이어가 이 보드에서 처음 플레이하는 경우, 캐릭터가 보드의 시작 위치로 순간이동하고 보드는 해당 보드의 카메라로 전환하여 오프닝 시네마틱을 재생합니다.
그런 다음 레벨 루프와 UI의 리셋 이벤트 대기 간에 경합이 벌어집니다. 둘 중 하나를 먼저 마치는 경우 다른 하나는 취소됩니다. 그런 다음 루프의 표현식이 반복되어 현재 보드를 얻고 경합을 다시 시작하는 것으로 돌아갑니다.
# Loops over the current gameboard and resets them.
GameLoop<private>()<suspends>:void=
# For the current board, swap to that gameboard's camera and reset the character to the gameboard's starting position.
loop:
if:
Gameboard := Gameboards[CurrentBoard]
then:
# If first time on this board, set up the board
# and move character to starting position.
if:
레벨 루프
LevelLoop() 함수는 게임보드의 로직을 관리합니다. 이 함수는 캐릭터에 대한 명령 루프와 보드의 최종 목표에 도달할 때까지 대기하는 것 사이에서 경합합니다. 최종 목표에 도달하면 명령 루프가 취소되고 목록의 다음 보드가 호출됩니다.
명령 루프는 플레이어가 Execute 버튼을 눌러 수행할 명령 목록을 수신할 때까지 대기합니다. 리셋 버튼을 제외한 버튼이 비활성화됩니다. 캐릭터는 명령을 수행하라는 신호를 받고, Verse 장치는 루프를 재시작하여 추가 명령을 대기하기 전에 완료 신호 수신을 대기합니다.
이 루프에는 defer가 사용되어 명령 루프 또는 LevelLoop() 함수가 취소되는 경우 UI를 지웁니다. defer 표현식은 해당 범위에서 나가기 직전에 ResetUIForAllPlayers()를 호출하여 버튼 상호작용성을 리셋하므로, 버튼이 다시 활성화되고 하단의 명령 목록이 지워집니다.
# Handles command logic for the current gameboard.
LevelLoop<private>(Gameboard:gameboard)<suspends>:void=
# On the current board, race between completing the board and looping player commands.
# The race expression will cancel whichever action doesn't finish first.
race:
loop:
defer:
# If the loop is canceled because the character reached the end goal of the level,
# Or the character finished performing their commands,
# reset the UI for all the players so they can interact with it and have no commands in the queue.
게임 리셋하기
AwaitReset() 함수는 플레이어가 리셋 버튼을 선택할 때까지 대기합니다. 플레이어가 리셋하면, 보드가 자체적으로 리셋되고 캐릭터에게 보드의 시작 위치로 순간이동하라고 지시합니다.
# Waits for the Reset button to be selected, then resets the current gameboard
# and NPC.
AwaitReset<private>(Gameboard:gameboard)<suspends>:void=
ResetButtonSelected.Await()
# Reset the current gameboard, returning the game character to the starting position and
# resetting any barriers or triggers on the board.
BoardResetEvent.Signal(Gameboard.GetStartingCharacterPosition())
# Reset Gameboard
다음 단계
여기서는 미니게임용 Verse 장치의 주요 기능을 다룹니다. 다음 단계와 마지막 단계에서 Verse 커맨더 미니게임 장치를 만들기 위한 전체 코드 목록을 찾을 수 있습니다.