Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -290,4 +290,8 @@ $RECYCLE.BIN/
# Windows shortcuts
*.lnk


# Environment file
.env

# End of https://www.toptal.com/developers/gitignore/api/macos,windows,linux,unity,intellij+all,clion+all
5 changes: 4 additions & 1 deletion Assets/Scripts/PlayerController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using System.Text;
using UnityEngine;
using SocketIOClient;
using CandyCoded.env;

public class PlayerMovement : MonoBehaviour
{
Expand All @@ -23,11 +24,13 @@ public class PlayerMovement : MonoBehaviour

private Vector2 previousMovement = Vector2.zero;

private string socketUrl;
async void Start()
{
try
{
var uri = new Uri("http://localhost:3000");
env.TryParseEnvironmentVariable("SOCKET_URL", out string socketUrl);
var uri = new Uri(socketUrl);
clientSocket = new SocketIOUnity(uri);

await clientSocket.ConnectAsync();
Expand Down
6 changes: 5 additions & 1 deletion Assets/Scripts/Trap/TrapManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using UnityEngine;
using SocketIOClient;
using Newtonsoft.Json.Linq;
using CandyCoded.env;

public class TrapManager : MonoBehaviour
{
Expand All @@ -16,6 +17,8 @@ public class TrapManager : MonoBehaviour
private Queue<TrapPlacement> placementQueue = new Queue<TrapPlacement>();
private SocketIOUnity clientSocket; // SocketIO client

private string socketUrl;

void Start()
{
// Initialize the grid
Expand All @@ -35,7 +38,8 @@ async void SetupSocket()
{
try
{
var uri = new Uri("https://d4cc-86-245-196-157.ngrok-free.app"); // Replace with your backend URL
env.TryParseEnvironmentVariable("SOCKET_URL", out string socketUrl);
var uri = new Uri(socketUrl); // Replace with your backend URL
clientSocket = new SocketIOUnity(uri);

// Connect to the server
Expand Down
1 change: 1 addition & 0 deletions Packages/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"com.unity.2d.tilemap": "1.0.0",
"com.unity.nuget.newtonsoft-json": "3.2.1",
"com.unity.ugui": "1.0.0",
"xyz.candycoded.env": "https://github.com/CandyCoded/env.git#v1.1.0",
"com.unity.modules.ai": "1.0.0",
"com.unity.modules.androidjni": "1.0.0",
"com.unity.modules.animation": "1.0.0",
Expand Down
7 changes: 7 additions & 0 deletions Packages/packages-lock.json
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,13 @@
"com.unity.modules.imgui": "1.0.0"
}
},
"xyz.candycoded.env": {
"version": "https://github.com/CandyCoded/env.git#v1.1.0",
"depth": 0,
"source": "git",
"dependencies": {},
"hash": "c6951bc02488dbe99f48509a9e289ee73c74acda"
},
"com.unity.modules.ai": {
"version": "1.0.0",
"depth": 0,
Expand Down