private void TakeKeyboardInput() { Caret.scale = new Vector2(0.5f); if (InputTeam1Name) { string str = Team1.text; GUIInput.AppendString(ref str, 15); Team1.text = str; Caret.position = Team1.position + new Vector2(Team1.size.x, CaretOffsetBig); Caret.scale = new Vector2(1); } else if (InputTeam2Name) { string str = Team2.text; GUIInput.AppendString(ref str, 15); Team2.text = str; Caret.position = Team2.position + new Vector2(Team2.size.x, CaretOffsetBig); Caret.scale = new Vector2(1); } else if (InputServerName) { string str = ServerNameString.text; GUIInput.AppendString(ref str, 15); ServerNameString.text = str; Caret.position = ServerNameString.position + new Vector2(ServerNameString.size.x, CaretOffsetSmall); } else if (InputPortName) { string str = PortNameString.text; GUIInput.AppendString(ref str, 4); PortNameString.text = str; Caret.position = PortNameString.position + new Vector2(PortNameString.size.x, CaretOffsetSmall); } else if (InputMaxPlayers) { string str = MaxPlayersString.text; GUIInput.AppendString(ref str, 3); MaxPlayersString.text = str; Caret.position = MaxPlayersString.position + new Vector2(MaxPlayersString.size.x, -MaxPlayersString.size.y * CaretOffsetSmall); } else if (InputTimeRound) { string str = TimeRoundString.text; GUIInput.AppendString(ref str, 2); TimeRoundString.text = str; Caret.position = TimeRoundString.position + new Vector2(TimeRoundString.size.x, -TimeRoundString.size.y * CaretOffsetSmall); } /* else if (InputScoreLimit) * { * string str = ScoreLimitString.text; * GUIInput.AppendString(ref str, 3); * ScoreLimitString.text = str; * Caret.position = ScoreLimitString.position + new Vector2(ScoreLimitString.size.x, CaretOffsetSmall); * }*/ }
public override void Update() { if (Canvas.isRendering) { Play.color = Unselected; HostGame.color = Unselected; Options.color = Unselected; Credits.color = Unselected; Exit.color = Unselected; RandomHat.color = Unselected; if (Play.Hovered()) { Play.color = Selected; } else if (HostGame.Hovered()) { HostGame.color = Selected; } else if (Options.Hovered()) { Options.color = Selected; } else if (Credits.Hovered()) { Credits.color = Selected; } else if (Exit.Hovered()) { Exit.color = Selected; } else if (RandomHat.Hovered()) { RandomHat.color = Selected; } if (Input.GetMouseButtonDown(Input.MouseButtons.LEFT)) { if (ChadArea.Hovered()) { Input.SetMouseMode(Input.MouseMode.POSITION_RELATIVE); _RotateChad = true; } } if (MyNameSticker.Clicked()) { TakeName = true; if (Blink == null) { Blink = CaretBlink(); StartCoroutine(Blink); } if (ClearName) { PlayerName.text = ""; ClearName = false; } } else if (Input.GetMouseButtonUp(Input.MouseButtons.LEFT)) { Input.SetMouseMode(Input.MouseMode.POSITION_ABSOLUTE); _RotateChad = false; TakeName = false; if (Blink != null) { StopCoroutine(Blink); Blink = null; } Caret.text = ""; } #region Clicked if (Play.Clicked() && PlayerName.text != "") { CameraMaster.instance.SetState(CAM_STATE.JOIN_HOST); TakeName = false; UserSettings.AddOrUpdateAppSetting("Hat", CameraMaster.instance.SelectedHat.ToString()); UserSettings.AddOrUpdateAppSetting("PlayerName", PlayerName.text); } else if (HostGame.Clicked()) { CameraMaster.instance.SetState(CAM_STATE.HOST_MENU); TakeName = false; UserSettings.AddOrUpdateAppSetting("Hat", CameraMaster.instance.SelectedHat.ToString()); UserSettings.AddOrUpdateAppSetting("PlayerName", PlayerName.text); } else if (Exit.Clicked()) { ThomasWrapper.IssueShutdown(); } else if (SelectHatRight.Clicked()) { CameraMaster.instance.SelectedHat += 1; AnnouncerSoundManager.Instance.Announce(ANNOUNCEMENT_TYPE.HAT); } else if (SelectHatLeft.Clicked()) { CameraMaster.instance.SelectedHat -= 1; AnnouncerSoundManager.Instance.Announce(ANNOUNCEMENT_TYPE.HAT); } else if (RandomHat.Clicked()) { CameraMaster.instance.SelectedHat = (int)(Random.Range(0.0f, 1.0f) * (HatManager.Instance.Hats.Count - 2)) + 1; AnnouncerSoundManager.Instance.Announce(ANNOUNCEMENT_TYPE.HAT); } else if (Options.Clicked()) { CameraMaster.instance.SetState(CAM_STATE.OPTIONS_MENU); } #endregion if (TakeName) { string playerString = PlayerName.text; GUIInput.AppendString(ref playerString, 9); PlayerName.text = playerString; } RotateChad(); Caret.position = PlayerName.position + new Vector2(PlayerName.size.x / 2 - 0.005f, CaretOffset + PlayerName.size.x * NameRotation); } }
public override void Update() { Join.color = Color.FloralWhite; Back.color = Color.FloralWhite; if (TakeIP) { string str = IPText.text; GUIInput.AppendString(ref str, 15); IPText.text = str; Caret.position = IPText.position + new Vector2(IPText.size.x / 2 - 0.005f, CaretOffset); } if (TakePort) { string str = PortText.text; GUIInput.AppendString(ref str, 5); PortText.text = str; Caret.position = PortText.position + new Vector2(PortText.size.x / 2 - 0.005f, CaretOffset); } if (Input.GetMouseButtonUp(Input.MouseButtons.LEFT)) { TakePort = false; TakeIP = false; TextBoxIP.color = Color.Black; TextBoxPort.color = Color.Black; if (Blink == null) { Blink = CaretBlink(); StartCoroutine(Blink); } } if (Join.Clicked()) { TakeIP = false; TakePort = false; ConnectingText.text = ""; System.Net.IPAddress ipaddress; UserSettings.AddOrUpdateAppSetting("LastUsedIP", IPText.text); try { ipaddress = NetUtils.ResolveAddress(IPText.text); } catch (Exception e) { ConnectingText.text = e.Message; return; } if (PortText.text != "") { try { if (IPText.text == "127.0.0.1") { MatchSystem.instance.LocalPort = 0; } else { MatchSystem.instance.LocalPort = Convert.ToInt32(PortText.text); } MatchSystem.instance.TargetPort = Convert.ToInt32(PortText.text); MatchSystem.instance.TargetIP = IPText.text; MatchSystem.instance.Listener.AllPeersConnectedEvent += Listener_AllPeersConnectedEvent; MatchSystem.instance.Listener.PeerDisconnectedEvent += Listener_PeerDisconnectedEvent; MatchSystem.instance.Init(); MatchSystem.instance.Connect(); ConnectingText.text = "Connecting"; ConnectingText.scale = new Vector2(1); ConnectingText.position = new Vector2(0.75f, 0.9f); Connect = Connecting(); StartCoroutine(Connect); Join.interactable = false; return; } catch (Exception e) //Hopefully this catches the exception thrown in ServerInfoEventHandler { ConnectingText.text = e.Message; Join.interactable = true; StopCoroutine(Connect); } } else { if (IPText.text == "") { TextBoxIP.color = Color.Red; } if (PortText.text == "") { TextBoxPort.color = Color.Red; } } } if (Back.Clicked()) { TakeIP = false; TakePort = false; CameraMaster.instance.SetState(CAM_STATE.MAIN_MENU); ConnectingText.text = ""; UserSettings.AddOrUpdateAppSetting("LastUsedIP", IPText.text); } if (TextBoxIP.Clicked()) { ConnectingText.text = ""; TakeIP = true; if (ClearIP) { IPText.text = ""; ClearIP = false; } } else if (TextBoxPort.Clicked()) { ConnectingText.text = ""; TakePort = true; if (ClearPort) { PortText.text = ""; ClearPort = false; } } else if (Input.GetMouseButtonUp(Input.MouseButtons.LEFT)) { if (Blink != null) { StopCoroutine(Blink); Blink = null; Caret.text = ""; } } if (Join.Hovered()) { Join.color = Color.IndianRed; } else if (Back.Hovered()) { Back.color = Color.IndianRed; } }