Advanced Integration
For ADVANCED INTEGRATION features, please make a formal request to ENERTIME using the following email address: info@enertime.io
Upon requesting for Advanced Integration, you will receive the following files from Enertime.
BeginOrEnd.cs
CmdTypes.cs
SerInstance.cs
Utils.cs
Among these files, the main file that you will be working with is SerInstance.cs
The other files are part of its dependencies, but its code need not be modified.
DEVELOPER NOTE: "The export format must be in Windows/MAC/Linux"
Now, please follow the below steps to integrate our solution with your product.
Step 1: Adding files into your game repository
Add the above 4 files that you will receive from us at Enertime, into a new folder within your working project file.
Step 2: Create a new script to extend the original SerInstance Class
Extend your class accordingly, using the sample provided below:
Step 3: Begin the Override process with the SetAddresses() method
DESCRIPTION:
void SetAddresses(int[][] IPA){}
Contains a 2D array of integers
In a single dimension, 1D, it represents an IP address.
Its main use is to generate the QR code used to establish a connection between the client and the server (executed every 5 seconds for stable connection).
Format of data (add an example):
When only 1 IP Address :
Eg: “ENERTIME: 192.168.1.1]”
When more than 1:
Eg: “ENERTIME: 192.168.1.1|192.168.1.213|......192.168.1.254]”
In addition, there is a padding feature, where every byte must have a length of 3, else it will append 0s to it’s left.
The sample code for the override may be found below:
The result
variable is used to make the QR code for connection purposes. The format is as follows:
result = “ENERTIME: 192.168.1.1|192.168.1.213|......192.168.1.254]”
Step 4: Begin the Override for the SetMode method
Description:
void SetMode(byte clientID, byte mode){}
Stores information about the client’s playing mode.
For the successful override of this function, please follow these procedures
Create a byte array as a member of the newly created extended class
Set minimum size to 8, but max limit is upto your choosing.
Set the default value for every element of this array to 254.
Store the modes as an array within the parameter clientID as follows:
array[clientID] = mode
Here, 254 is used as a placeholder within the array. It is also used as an indicator for the connection status of the users (as 254 implies that the user is disconnected from the server).
The latter is mainly used for the below function.
Step 5: Override for the Disconnected() method
DESCRIPTION:
public override void Disconnected(byte clientID){}
Used to detect if the player (phone/client) is connected to the server.
Cases where the client is disconnected from the server:
Internet connection resets during gameplay. (maybe wifi network changed, or connected hotspot turned off)
Client finishes playing the game
Steps:
If this instruction is passed, please execute the following code segment:
array[clientID] = 254
Step 6: Override the HandleCommand() method
DEFINE:
public override void HandleCommand(byte clientID,CmdType type, byte[] paras){}
DESCRIPTION:
Please refer to the sample code for the function below:
Apart from Saber mode and Jump mode, if you would like to try some of the other modes, please utilize the protocol codes within the instruction sheet in the next section.
A quick summary of the code used is provided below.
Overridable Function: A function that is re-used/inherited from a pre-existing class, but is modified to perform different tasks during execution
By making use of these functions, you can have your ideas make effective use of our solution.
Last updated