Hi everyone, it has been a few weeks since my last update and I am keen to share the latest additions to Rift of the Realms!
Enhanced User Authentication:
We've revamped the login user scene to integrate with our Laravel API and database. The option to enter a name is removed, as it now pulls directly from the username you enter on the login screen. Let's dive into the code behind this in the web.cs
class:
The "
apiUrl
" is a variable that holds the base URL for an API hosted on the Render platform.GetUser(string username, string password)
: This method sends a POST request to the APIs "/player" endpoint to create a new user. The request body is formatted as JSON containing the username and password. Upon successful completion, the response data is logged.Login(string username, string password)
This method sends a POST request to the APIs /playerLogin
endpoint to authenticate the user. It takes the username and password as parameters. Similar to"GetUser"
it sends a JSON request body. If the login is successful (HTTP status code 200) the response data is logged and the player info is stored in the game manager. If the login fails due to the wrong credentials (HTTP status code 401), an error message is logged. In the future we need to work at adding on screen error messages and encrypting the passwords too.RegisterUser(string username, string password)
This method sends a PUT request to the APIs /player endpoint to register a new user. This is in the Create Account login.
Win Conditions Implementation
The win conditions to the game have been implemented. Now at the end of each round the winning team is displayed as "Light" if all the machines have been fixed in the time limit. In order to do this we set the Photon custom room property "Winner" to "Light" when the condition for fixing all the machines is met.
// Method to set the winner as a room property private void SetWinner(string winner) { PhotonNetwork.CurrentRoom.SetCustomProperties(new ExitGames.Client.Photon.Hashtable { { "Winner", winner } }); }
Conversely, if the machines aren't fixed by the Light Realm players in the time limit then the round concludes showing the Dark Realm players have won.
At the end of each round a video playing Round Over appears briefly first before displaying which team won the round.
Coins
We have now integrated the gold and silver coins, designed by Shashank Kumar Sukumar Singh into the game. They can be seen in the top left.
That's all the updates for now. I would like to give a big shoutout to my fellow programmer Shashank Kumar Sukumar Singh who did a great job designing the UI displays for the round over and the login screens. Thanks for tuning into our progress update!
Molly