public void CreateMatch() { StartCoroutine(DB_API.Match_Create(DB_API.UserAuth.SessionID, "duh herro", "Reactor", 1, 12, 10, 10, "", true, callback => { if (callback.Success) { StartCoroutine(DB_API.Match_Join(DB_API.UserAuth.SessionID, callback.MatchID, "", c => { if (c.Success) { DB_API.MatchID = callback.MatchID; DB_Object.Instance.Start_Match_Ping_API(); string ip = c.Server.IP; ushort port = (ushort)c.Server.Port; NetworkingManager.Singleton.GetComponent <EnetTransport.EnetTransport>().Address = ip; NetworkingManager.Singleton.GetComponent <EnetTransport.EnetTransport>().Port = port; //NetworkingManager.Singleton.GetComponent<RufflesTransport.RufflesTransport>().ConnectAddress = ip; //NetworkingManager.Singleton.GetComponent<RufflesTransport.RufflesTransport>().ConnectPort = port; //NetworkingManager.Singleton.GetComponent<LiteNetLibTransport.LiteNetLibTransport>().Address = ip; //NetworkingManager.Singleton.GetComponent<LiteNetLibTransport.LiteNetLibTransport>().Port = port; NetworkingManager.Singleton.NetworkConfig.ConnectionData = System.Text.Encoding.ASCII.GetBytes(DB_API.ConnectionData); NetworkingManager.Singleton.StartClient(); } })); } })); }
private void JoinMatch(Match_List.Match match) { StartCoroutine(DB_API.Match_Join(DB_API.UserAuth.SessionID, match.ID, "", callback => { if (callback.Success) { DB_API.MatchID = match.ID; DB_Object.Instance.Start_Match_Ping_API(); string ip = callback.Server.IP; ushort port = (ushort)callback.Server.Port; NetworkingManager.Singleton.GetComponent <EnetTransport.EnetTransport>().Address = ip; NetworkingManager.Singleton.GetComponent <EnetTransport.EnetTransport>().Port = port; //NetworkingManager.Singleton.GetComponent<RufflesTransport.RufflesTransport>().ConnectAddress = ip; //NetworkingManager.Singleton.GetComponent<RufflesTransport.RufflesTransport>().ConnectPort = port; //NetworkingManager.Singleton.GetComponent<LiteNetLibTransport.LiteNetLibTransport>().Address = ip; //NetworkingManager.Singleton.GetComponent<LiteNetLibTransport.LiteNetLibTransport>().Port = port; NetworkingManager.Singleton.NetworkConfig.ConnectionData = System.Text.Encoding.ASCII.GetBytes(DB_API.ConnectionData); NetworkingManager.Singleton.StartClient(); } })); }
public void QuitGame() { ConfirmDialog.Instance.Open("Quit Game", "Are you sure you want to quit the game while you are in a match?", "Quit Game", "Nevermind", () => { StartCoroutine(DB_API.Match_Leave(DB_API.UserAuth.SessionID, DB_API.MatchID, callback => { })); NetworkingManager.Singleton.StopClient(); Application.Quit(); }); }
public void LeaveMatch() { ConfirmDialog.Instance.Open("Leave Match", "Are you sure you want to leave the match?", "Leave Match", "Nevermind", () => { StartCoroutine(DB_API.Match_Leave(DB_API.UserAuth.SessionID, DB_API.MatchID, callback => { })); NetworkingManager.Singleton.StopClient(); SceneManager.LoadScene("Main Menu"); }); }
public void DoLogin(string email, string password) { if (string.IsNullOrWhiteSpace(email) || string.IsNullOrWhiteSpace(password)) { return; } // Do Loading Screen LoginButton.interactable = false; LoginButton.GetComponentInChildren <TextMeshProUGUI>().SetText("Logging In..."); //LoadingScreen.Instance.EnableScreen("Logging In", true); StartCoroutine(DB_API.User_Auth(email, password, (session) => { if (session.Success) { // Gather player data StartCoroutine(DB_API.User_Info(session.SessionID, (data) => { if (data.Success) { // Start pinging the API DB_Object.Instance.Start_User_Ping_API(); // Do Loading Screen LoginButton.interactable = false; LoginButton.GetComponentInChildren <TextMeshProUGUI>().SetText("Loggin Successful..."); //LoadingScreen.Instance.EnableScreen("Login Successful", false); // Load menu scene SceneManager.LoadScene("Main Menu"); } else { // Do Loading Screen LoginButton.interactable = true; LoginButton.GetComponentInChildren <TextMeshProUGUI>().SetText("Login Failed... Try Again"); //LoadingScreen.Instance.DisableScreenFade("Login Failed", 0.1f); return; } })); } else { // Do Loading Screen LoginButton.interactable = true; LoginButton.GetComponentInChildren <TextMeshProUGUI>().SetText("Login Failed... Try Again"); //LoadingScreen.Instance.DisableScreenFade("Login Failed", 0.1f); return; } })); // Save the username to the playerprefs PlayerPrefs.SetString("Email", email); PlayerPrefs.SetString("Password", AutoLoginToggle.isOn ? password : ""); PlayerPrefs.SetInt("AutoLogin", AutoLoginToggle.isOn ? 1 : 0); }
private void Start() { User_Info info = DB_API.UserInfo; NamePlateText.SetText(PlayerMethods.GetColoredTitleName(info.Account.Name, (byte)info.Account.GameAccess, 0)); StartCoroutine(DB_API.User_Avatar("m", callback => { Avatar.sprite = Sprite.Create(callback, new Rect(0.0f, 0.0f, callback.width, callback.height), new Vector2(0.5f, 0.5f)); })); InvokeRepeating("UpdateServerList", 0.0f, 3.0f); }
int startAttempts = 0; // How many times have we tried to start the server thus far private void Start() { if (Instance == null) { Instance = this; DontDestroyOnLoad(gameObject); } else { Destroy(gameObject); } // Set the target framerate Application.targetFrameRate = 60; // Get the server settings LoadFile(); UUID = Guid.NewGuid(); Debug.Log("UUIDv4: " + UUID); if (!Settings.IsTestServer) { StartCoroutine(DB_API.Server_Create(UUID.ToString(), Settings.PlayerLimit, 1, Settings.IP, Settings.Port, callback => { if (callback.Success) { StartServer(); } else { if (startAttempts < 5) { Start(); startAttempts++; } else { Application.Quit(); } } })); } else { StartServer(); } //string title = string.Format("Shakedown Server | Name: {0} | Port: {1} | Map: {2} | GameMode: {3} | PlayerLimit: {4} | ScoreLimit: {5} | Password: {6}", Name, Port, Map, GameMode, PlayerLimit, ScoreLimit, Password); //ChangeTitle(title); }
private void UpdateServerList() { StartCoroutine(DB_API.Match_List(DB_API.UserAuth.SessionID, callback => { if (callback.Success) { // Clear the game objects of removed rooms for (int i = 0; i < ServerListRect.childCount; i++) { Destroy(ServerListRect.GetChild(i).gameObject); } // If no matches are created if (callback.Matches.Count == 0) { ServerStatus.SetText("No Servers Found..."); return; } ServerStatus.SetText(""); // Otherwise instantiate server objects for the matches foreach (var match in callback.Matches) { GameObject obj = Instantiate(ServerEntryObject, ServerListRect); obj.GetComponent <ServerListEntry>().Initialize(match); } } else { ServerStatus.SetText("Failed to get Match List"); // Clear the game objects of removed rooms for (int i = 0; i < ServerListRect.childCount; i++) { Destroy(ServerListRect.GetChild(i).gameObject); } } })); }
private void ApprovalCheck(byte[] connectionData, ulong clientID, NetworkingManager.ConnectionApprovedDelegate callback) { Debug.Log("Checking Connection Approval"); if (Settings.IsTestServer) { Debug.Log("A connection was approved without security checks."); callback(true, 1897319656204293034, true, null, null); SpawnPlayer(clientID); return; } string cd = System.Text.Encoding.ASCII.GetString(connectionData); string[] data = cd.Split(','); int matchID = int.Parse(data[0]); int userID = int.Parse(data[1]); StartCoroutine(DB_API.Server_Match_User_Authorized(matchID, userID, c => { Debug.Log("Client Connection Approval: " + c.Success); callback(true, null, c.Success, null, null); SpawnPlayer(clientID); })); }
void match_ping_api() { StartCoroutine(DB_API.Match_Ping(DB_API.UserAuth.SessionID, DB_API.MatchID, callback => { })); }
void user_ping_api() { StartCoroutine(DB_API.User_Ping(DB_API.UserAuth.SessionID, callback => { })); }