Duel
This document will guide you through integrating a Sample that involves Elympics Rooms API, Competitive smart contract (Duel), where player can compete on Ethereum Testnet for Tokens, while earning Respect.
caution
This API is subject to change in the future and is not considered code-stable.
Setup Elympics SDK
- Add Elympics SDK to your game by the Package Manager using this link: https://github.com/Elympics/Unity-SDK.git
- Create an Account, Elympics Game and matchmaking queues in Developer Console
- Choose a basic fleet
- Create two matchmaking queues:
Duel
andCasual
with the Pair matchamking kind. - Contact us on Discord in order to connect the
Duel
queue to the smart contract deployment (this has to be done manually). Please provide us with the matchmaking queue identifier. - Log in to Elympics inside Unity, using your account
- Enable HTTPS/WebRTC in your Game Config
Setup the Sample Package
Download the package here. Pleas use the newest version.
Setup Menu Scene
- Setup
Elympics SDK
- Donwload
com.unity.nuget.newtonsoft-json
from the Package Manager - Download Dotween
- Download
TMPro Essentials
and "Examples & Extras"- Import
Fonts/Roboto-Bold.ttf
andResources/Fonts & Materials/Roboto-Bold SDF.asset
- In
Project Settings/TextMesh Pro/Settings/DefaultSpriteAsset
changePath
toSprites/
- Import
- Import the latest package
RoomsMenuPackage
- Add the
Menu
Scene to build settings as the initial Scene - Find
ScriptableObject
SmartContractServiceConfig
and choose the correct reference toElympicsGameConfig
, because the current one will be missing. - In
Project Settings/Player/WebGL/Resolution and Presentation
change theWebGLTemplate
toElympics
- Change
AuthDataStorage.ENCRYPTION_KEY
andChatController.APIKey
to the values that we'll provide you with on Discord. - Chat
- In
ChatConfig
change the constantPATH_IN_RESOURCES
, to{GAME_NAME}/Chat/
. Make sure that the appropriate asset is present inShared/Resources/PATH_IN_RESOURCES
. - Elympics contains a config for game region (warsaw, tokyo, etc). They're used by, among others, chat config, which is responsible for channels that are geo-scoped.
- In
- Build and upload the server version of the game
- Test the game on the
casual
queue and see if it's working. - Test the
competitive
mode according to the testing sections below. - When the game is working correctly, you can proceed with updating the assets and artstyle to suit your game.
- Remember to use prefabs whenever possible
- Remember that the hierarchy elements below
==v==DontDestroyOnLoad_Objects==v==
should not become children of otherGameObjects
- In the final non-testing build, the
IngameDebugConsole
should be removed - In case of any doubts with assets update, please contact us on Discord.
Gameplay Scene Requirements
- Synchronize the beginning of the game (
OnGameReady
orGameReady
) and the starting state for both players, usingCustomServerHandler
It should look like this:
-
Choose
DefaultServerHandler
in theElympics
Object. -
Replace the default script with
Custom
-
Add the object from
Assets/_RoomsPackage/Gameplay/Prefabs/InitialPlayerDataHandler.prefab
to the scene.
- Handle both
competitive
andcasual
, games, where game information about the players is delivered viaCustomServerHandler
- Synchronizing and displaying nicknames via
InitialPlayerDataHandler
- Correctly handle the joining process for the gameplay. Remember that one-time actions and their effects should be synchronized via state.
- Correctly display rewards at the end of the game. They're downloaded via
WebRequest
to get Respect. Use a loading indicator as this takes a short while. Also – display the financial reward in the case of a competitive game. - A sample implementation is placed in
Assets/_RoomsPackage/Gameplay/Prefabs/EndGamePrizes/
, which is used in the sample scriptEndMatchResult
. This implementation should be adjusted to suit the game's needs, but it should prove useful to have a reference. Remember to add the remaining objects fromAssets/_RoomsPackage/Gameplay/Prefabs
to your scene -Infos
andRespectInfo
. Remember to initializeTokenAddressProviderMatchData
before callingShowPrizeReward()
; - Correctly identify the winner via calling
EndGame(ResultMatchPlayerDatas result)
with the correct parameters on the server side
Testing
For testing refer to the corresponding article.