/* * After "Create" button in "NewGameScene" * Setup bind address and port, start server, change scene */ public void SetupNewGame() { Debug.Log("SetupNewGame"); isNewGame = true; isLoadGame = false; try { this.serverBindAddress = gameApp.GetInputField("ServerAddress"); this.serverBindToIP = true; this.networkPort = int.Parse(gameApp.GetInputField("ServerPort")); // uncomment for testing //this.serverBindAddress = "127.0.0.1"; //this.networkPort = 7777; if (!this.StartServer()) { throw new Exception("Starting server error!"); } this.ServerChangeScene("GameScene"); } catch (Exception e) { Debug.Log("SetupNewGame error: " + e.Message); errorInfoPanel.Show("SetupNewGame error: " + e.Message); return; } }
/* * After "Join" button in "JoinGameScene" * Setup server address and port, start client */ public void SetupClient() { Debug.Log("SetupClient"); try { // persists config data from menu scene gameApp.PersistAllParameters("JoinGameScene"); this.networkAddress = gameApp.GetAndRemoveInputField("ServerAddress"); this.networkPort = int.Parse(gameApp.GetAndRemoveInputField("ServerPort")); // uncomment for testing //this.networkAddress = "127.0.0.1"; //this.networkPort = 7777; this.StartClient(); } catch (Exception e) { Debug.Log("SetupClient error: " + e.Message); errorInfoPanel.Show("SetupClient error: " + e.Message); return; } }