/dark-frontier

Fully onchain, ZK space conquest MMORTS Dark Forest-inspired game, powered by World Engine.

Primary LanguageC#MIT LicenseMIT

Dark Frontier Logo

Fully onchain, ZK space conquest MMORTS Dark Forest-inspired game,
powered by Argus Labs' 「 World Engine 」

Telegram Chat Twitter Follow


Gameplay Screenshot

Table of Content


Overview

This repository contains both the Dark Frontier's Unity game client (/client) and World Engine's Cardinal game shard (/backend).

Dark Frontier provides a real-world example of what you can achieve with World Engine and have processed live production workload with 700K+ transactions.

To learn more about World Engine, visit https://world.dev.

Getting Started

We recommend reading the World Engine quickstart guide before proceeding.

The quickstart guide will guide you in installing the prerequisites for running a World Engine project that is needed to run a Dark Frontier instance on your machine.

If you have any questions, please reach out to our friendly community on Telegram!


Running Dark Frontier's World Engine backend

Prerequisites

  • Go
  • Docker
  • World CLI

To install the World CLI, run the following command:

curl https://install.world.dev/cli! | bash

Setup

  1. Download ZK circuit artifacts
make getCircuitArtifacts

  1. Run vendor to statically link the artifacts into Cardinal
cd cardinal && go mod vendor && cd ../

  1. Start Nakama and Cardinal. Ensure you're in /backend directory, then:
world cardinal start

  1. To stop both the Nakama and Cardinal
world cardinal stop

Configuring Allowlist/Game Keys

World Engine's Nakama Allowlist feature allows you to restrict access to the game using game keys.

To enable this feature, set the following environment variable:

ENABLE_ALLOWLIST=true

Enabling the allowlist feature will enable two new RPC endpoints to manage and use game keys.

You can interact with these RPC endpoints easily through the Nakama API Explorer, accessible via browser at localhost:7351. For local development, use admin:password as your login credentials.

RPC generate-beta-keys

An admin-only endpoint that generates N number of game keys.

Request Payload
{
  "amount": 5
}
Return Payload
{
  "keys": [
    "ABCD-EFGH-1234-5678",
    "ABCD-EFGH-1234-5678",
    "ABCD-EFGH-1234-5678",
    "ABCD-EFGH-1234-5678",
    "ABCD-EFGH-1234-5678"
  ]
}

RPC claim-key

A user-facing endpoint which allows a user to redeem a game key.

⚠️ NOTE: the create-persona endpoint will be 🛑 BLOCKED until a user calls claim-key with a valid key. ⚠️

Request Payload
{
  "key": "ABCD-EFGH-1234-5678"
}
Return Payload
{
  "success": true
}

Running Dark Frontier's client

Prerequisites

  • Unity Hub
  • Unity 2022 LTS

Setup

  1. Install Unity Hub. and load /client project in unity.
  2. Open the Bootstrap scene: Assets/Scenes/Bootstrap.unity
  3. Locate and select the GameObject named Bootstrap within the Bootstrap scene.
  4. Configure the communication setting
    • The default configuration connects to your local World Engine backend instance.
    • For testing, you can use Argus Labs' cloud prover to generate ZK proofs required for game moves: https://lambda.argus-dev.com/generate-proof
Bootstrap Screenshot
  1. Check Will Start In Clean Test Mode to force creation of a new player.
  2. Check Will Require Beta Key only if you enabled the allowlist feature on the World Engine backend.
  3. Check Will Respect Countdown only if you want a time-limited game.
  4. Press Play to start the game.

Development Guide

Start with Bootstrap

Bootstrap.cs is the main entry point to start looking at code. It is repsonsible for instantiating all dependencies as well as setting up the major game states and their transitions so that everything is ready to go when the initial game state is started.

Each major game state receives dependencies on a need-to-know basis. An EventManager allows for communication between game states, UI, and a CommunicationsManager.

The CommunicationsManager is responsible for communicating with the backend. Non-game-specific communications are handled by the gg.argus.world-engine-client-communications-unity UPM package.

Gameplay logic is handled in Gameplay.cs.

UPM Dependencies


Gameplay Tutorial

Input Bindings

Controls Functionality
WASD Pan space view camera.
Wheel Zoom camera in and out.
LMB Select a planet.
LMB + Drag Create an energy transfer line between planets.
F Focus the camera on the selected planet.
H Focus the camera on your home planet.
TAB Cycle through the various debug modes.