private static void ToggleConnectToServer(string buttonName) { if (Client.Instance.isConnected) { DisconnectFromServer(); _connectButton.UpdateText("Connect"); } else { ConnectToServer(); _connectButton.UpdateText("Disconnect"); } }
private static void ConnectToServer() { if (!Client.Instance.isConnected) { Log("Connecting to Server..."); ConnectionInfo.UpdateText("Connecting to server..."); if (_ipInput.GetText() != "") { MultiplayerClient.settings.host = _ipInput.GetText(); } if (_portInput.GetText() != "") { MultiplayerClient.settings.port = int.Parse(_portInput.GetText()); } if (_usernameInput.GetText() != "") { MultiplayerClient.settings.username = _usernameInput.GetText(); } PlayerManager.activeScene = UnityEngine.SceneManagement.SceneManager.GetActiveScene().name; _connectRoutine = Client.Instance.StartCoroutine(Connect()); Log("Connected to Server!"); ConnectionInfo.UpdateText("Connected to server."); ConnectButton.UpdateText("Disconnect"); } else { Log("Already connected to the server!"); } }
private static void ToggleTeam(string buttonName) { if (SessionManager.Instance.TeamsEnabled) { Client.Instance.team++; if (Client.Instance.team != 1 && Client.Instance.team != 2 && Client.Instance.team != 3 && Client.Instance.team != 4) { Log("Team Was not an known amount"); Client.Instance.team = 1; } Log("Button pressed"); switch (Client.Instance.team) { case 1: HeroController.instance.gameObject.GetComponent <tk2dSpriteAnimator>().Sprite.color = Color.red; TeamButton.UpdateText("Red"); Log("Red"); break; case 2: HeroController.instance.gameObject.GetComponent <tk2dSpriteAnimator>().Sprite.color = Color.blue; TeamButton.UpdateText("Blue"); Log("blue"); break; case 3: HeroController.instance.gameObject.GetComponent <tk2dSpriteAnimator>().Sprite.color = Color.yellow; TeamButton.UpdateText("Yellow"); Log("yellow"); break; case 4: HeroController.instance.gameObject.GetComponent <tk2dSpriteAnimator>().Sprite.color = Color.green; TeamButton.UpdateText("Green"); Log("green"); break; } } if (Client.Instance.isConnected) { ClientSend.Team(Client.Instance.myId, Client.Instance.team); } }