mirror of
				https://github.com/DerTyp7/defrain-shooter-unity.git
				synced 2025-10-30 04:57:10 +01:00 
			
		
		
		
	| @@ -1,137 +0,0 @@ | ||||
| using System.Collections; | ||||
| using System.Collections.Generic; | ||||
| using System; | ||||
| using UnityEngine; | ||||
| using UnityEngine.UI; | ||||
| using TMPro; | ||||
| using System.Text.RegularExpressions; | ||||
|  | ||||
|  | ||||
| public class InputValidator : MonoBehaviour | ||||
| { | ||||
|     public enum TypeOfInput | ||||
|     { | ||||
|         IP, | ||||
|         Username, | ||||
|         Port | ||||
|     } | ||||
|  | ||||
|     public TypeOfInput InputType; | ||||
|     private TMP_InputField inputField; | ||||
|  | ||||
|     private void Start() | ||||
|     { | ||||
|         inputField = GetComponent<TMP_InputField>(); | ||||
|          | ||||
|  | ||||
|         if(InputType == TypeOfInput.Port) | ||||
|         { | ||||
|             inputField.text = "7777"; | ||||
|         } | ||||
|  | ||||
|         inputField.onValueChanged.AddListener(delegate { ValueChangeCheck(); }); | ||||
|     } | ||||
|  | ||||
|     private void ValueChangeCheck() | ||||
|     { | ||||
|         //IP | ||||
|         if(InputType == TypeOfInput.IP) | ||||
|         { | ||||
|             int counter = 0; | ||||
|             foreach (char c in inputField.text) | ||||
|             { | ||||
|                 //is not 0-9 or dot | ||||
|                 if (!Char.IsDigit(c)) | ||||
|                 { | ||||
|                     if (c != '.') | ||||
|                     { | ||||
|                         inputField.text = inputField.text.Remove(counter); | ||||
|                         counter--; | ||||
|                     } | ||||
|                 } | ||||
|                 else | ||||
|                 { | ||||
|                     //Max 3 nummern nacheinander | ||||
|                     if(counter > 2) | ||||
|                     { | ||||
|                         if(Char.IsDigit(inputField.text[counter-1]) && Char.IsDigit(inputField.text[counter - 2]) && Char.IsDigit(inputField.text[counter - 3])) | ||||
|                         { | ||||
|                             inputField.text = inputField.text.Remove(counter); | ||||
|                             counter--; | ||||
|                         } | ||||
|                     } | ||||
|                 } | ||||
|  | ||||
|                 //no double dot | ||||
|                 if(c == '.' && counter > 0) | ||||
|                 { | ||||
|                     if(inputField.text[counter-1] == '.') | ||||
|                     { | ||||
|                         inputField.text = inputField.text.Remove(counter); | ||||
|                         counter--; | ||||
|                     } | ||||
|                 } | ||||
|  | ||||
|                 counter++; | ||||
|             } | ||||
|             //max dots = 3 | ||||
|             if (inputField.text.Split(".").Length-1 > 3) | ||||
|             { | ||||
|                 inputField.text = inputField.text.Remove(inputField.text.LastIndexOf(".")); | ||||
|             } | ||||
|  | ||||
|         } | ||||
|          | ||||
|         if(InputType == TypeOfInput.Port) | ||||
|         {//0  - 65535 | ||||
|             foreach (char c in inputField.text) | ||||
|             { | ||||
|                 if (!Char.IsDigit(c)) | ||||
|                 { | ||||
|                     inputField.text = inputField.text.Remove(inputField.text.LastIndexOf(c)); | ||||
|                 } | ||||
|                 else if (int.Parse(inputField.text) > 65535) | ||||
|                 { | ||||
|                     inputField.text = "65535"; | ||||
|                 } | ||||
|             } | ||||
|  | ||||
|             | ||||
|         } | ||||
|  | ||||
|         // USERNAME | ||||
|         if (InputType == TypeOfInput.Username) | ||||
|         { | ||||
|              | ||||
|             foreach (char c in inputField.text) | ||||
|             { | ||||
|                 if (!Char.IsLetter(c)) | ||||
|                 { | ||||
|                     if (!Char.IsDigit(c)) | ||||
|                     { | ||||
|                         inputField.text = inputField.text.Remove(inputField.text.LastIndexOf(c)); | ||||
|                     } | ||||
|                 } | ||||
|             } | ||||
|              | ||||
|  | ||||
|             if(inputField.text.Length > 25) | ||||
|             { | ||||
|                 string tempText = ""; | ||||
|  | ||||
|                  | ||||
|                 for(int c = 0; c < inputField.text.Length; c++) | ||||
|                 { | ||||
|                     if(c < 25) | ||||
|                     { | ||||
|                         tempText += inputField.text[c]; | ||||
|                     } | ||||
|                 } | ||||
|  | ||||
|                 inputField.text = tempText; | ||||
|  | ||||
|  | ||||
|             } | ||||
|         } | ||||
|     } | ||||
| } | ||||
| @@ -1,11 +0,0 @@ | ||||
| fileFormatVersion: 2 | ||||
| guid: 63e8a56290440f546ab703ec69045442 | ||||
| MonoImporter: | ||||
|   externalObjects: {} | ||||
|   serializedVersion: 2 | ||||
|   defaultReferences: [] | ||||
|   executionOrder: 0 | ||||
|   icon: {instanceID: 0} | ||||
|   userData:  | ||||
|   assetBundleName:  | ||||
|   assetBundleVariant:  | ||||
| @@ -1,39 +0,0 @@ | ||||
| using System.Collections; | ||||
| using System.Collections.Generic; | ||||
| using UnityEngine; | ||||
| using UnityEngine.UI; | ||||
| using UnityEngine.EventSystems; | ||||
|  | ||||
| public class MenuBtn : MonoBehaviour, IPointerEnterHandler, IPointerExitHandler  | ||||
| { | ||||
|     [Header("Background Image")] | ||||
|     [SerializeField] private GameObject BtnBgImage; | ||||
|     [SerializeField] private Color BgColor; | ||||
|     [SerializeField] private Color OnHoverBgColor; | ||||
|      | ||||
|     private bool mouse_over = false; | ||||
|  | ||||
|  | ||||
|     public void Update() | ||||
|     { | ||||
|         if (mouse_over) | ||||
|         { | ||||
|             BtnBgImage.GetComponent<Image>().color = OnHoverBgColor; | ||||
|         } | ||||
|         else | ||||
|         { | ||||
|             BtnBgImage.GetComponent<Image>().color = BgColor; | ||||
|         } | ||||
|     } | ||||
|  | ||||
|  | ||||
|     public void OnPointerEnter(PointerEventData e) | ||||
|     { | ||||
|         mouse_over = true; | ||||
|     } | ||||
|  | ||||
|     public void OnPointerExit(PointerEventData e) | ||||
|     { | ||||
|         mouse_over = false; | ||||
|     } | ||||
| } | ||||
| @@ -1,11 +0,0 @@ | ||||
| fileFormatVersion: 2 | ||||
| guid: fd4b898ade2dd5d41b2181efb5309551 | ||||
| MonoImporter: | ||||
|   externalObjects: {} | ||||
|   serializedVersion: 2 | ||||
|   defaultReferences: [] | ||||
|   executionOrder: 0 | ||||
|   icon: {instanceID: 0} | ||||
|   userData:  | ||||
|   assetBundleName:  | ||||
|   assetBundleVariant:  | ||||
| @@ -1,7 +0,0 @@ | ||||
| using Mirror; | ||||
| using UnityEngine; | ||||
|  | ||||
| public class MenuManager : NetworkManager | ||||
| { | ||||
|  | ||||
| } | ||||
| @@ -1,11 +0,0 @@ | ||||
| fileFormatVersion: 2 | ||||
| guid: 145706024aa7ca34b9312d85f68fc209 | ||||
| MonoImporter: | ||||
|   externalObjects: {} | ||||
|   serializedVersion: 2 | ||||
|   defaultReferences: [] | ||||
|   executionOrder: 0 | ||||
|   icon: {instanceID: 0} | ||||
|   userData:  | ||||
|   assetBundleName:  | ||||
|   assetBundleVariant:  | ||||
| @@ -1,55 +0,0 @@ | ||||
| using System.Collections; | ||||
| using System.Collections.Generic; | ||||
| using UnityEngine; | ||||
| using UnityEngine.UI; | ||||
|  | ||||
| public class MenuPanelSwitch : MonoBehaviour | ||||
| { | ||||
|     [SerializeField] private GameObject MainPanel, JoinPanel, HostPanel, OptionsPanel; | ||||
|  | ||||
|     [SerializeField] private Button JoinBtn, HostBtn, OptionsBtn; | ||||
|     private Button BackBtn; | ||||
|  | ||||
|     private void Start() | ||||
|     { | ||||
|         ResetToMain(); | ||||
|         JoinBtn.onClick.AddListener(SwitchJoinPanel); | ||||
|         HostBtn.onClick.AddListener(SwitchHostPanel); | ||||
|         OptionsBtn.onClick.AddListener(SwitchOptionsPanel);         | ||||
|     } | ||||
|     public void ResetToMain() | ||||
|     { | ||||
|         JoinPanel.SetActive(false); | ||||
|         HostPanel.SetActive(false); | ||||
|         OptionsPanel.SetActive(false); | ||||
|  | ||||
|         MainPanel.SetActive(true); | ||||
|     } | ||||
|  | ||||
|     public void TurnAllOff() | ||||
|     { | ||||
|         JoinPanel.SetActive(false); | ||||
|         HostPanel.SetActive(false); | ||||
|         OptionsPanel.SetActive(false); | ||||
|         MainPanel.SetActive(false); | ||||
|     } | ||||
|  | ||||
|     public void SwitchJoinPanel() | ||||
|     { | ||||
|         TurnAllOff(); | ||||
|         JoinPanel.SetActive(true); | ||||
|     } | ||||
|  | ||||
|     public void SwitchHostPanel() | ||||
|     { | ||||
|         TurnAllOff(); | ||||
|         HostPanel.SetActive(true); | ||||
|     } | ||||
|  | ||||
|     public void SwitchOptionsPanel() | ||||
|     { | ||||
|         TurnAllOff(); | ||||
|         OptionsPanel.SetActive(true); | ||||
|     } | ||||
|  | ||||
| } | ||||
| @@ -1,11 +0,0 @@ | ||||
| fileFormatVersion: 2 | ||||
| guid: 62a9b64eb5d37bb43a7f4ff101582b6f | ||||
| MonoImporter: | ||||
|   externalObjects: {} | ||||
|   serializedVersion: 2 | ||||
|   defaultReferences: [] | ||||
|   executionOrder: 0 | ||||
|   icon: {instanceID: 0} | ||||
|   userData:  | ||||
|   assetBundleName:  | ||||
|   assetBundleVariant:  | ||||
| @@ -1,24 +0,0 @@ | ||||
| using Mirror; | ||||
| using UnityEngine; | ||||
| using TMPro; | ||||
|  | ||||
| public class MenuStartClient : MonoBehaviour | ||||
| { | ||||
|     [SerializeField] private TMP_InputField IpInput; | ||||
|     [SerializeField] private TMP_InputField UsernameInput; | ||||
|     public void StartClient() | ||||
|     { | ||||
|         if(UsernameInput.text != "") | ||||
|         { | ||||
|             Debug.Log("[MENU] Starting client..."); | ||||
|  | ||||
|             GameObject.FindGameObjectWithTag("VariableSaver").GetComponent<VariableSaver>().username = UsernameInput.text; | ||||
|  | ||||
|             NetworkManager.singleton.networkAddress = IpInput.text; | ||||
|             if(IpInput.text != "") | ||||
|             { | ||||
|                 NetworkManager.singleton.StartClient(); | ||||
|             } | ||||
|         } | ||||
|     } | ||||
| } | ||||
| @@ -1,11 +0,0 @@ | ||||
| fileFormatVersion: 2 | ||||
| guid: 4e1b622a4122f984e8ecc6b6c9556411 | ||||
| MonoImporter: | ||||
|   externalObjects: {} | ||||
|   serializedVersion: 2 | ||||
|   defaultReferences: [] | ||||
|   executionOrder: 0 | ||||
|   icon: {instanceID: 0} | ||||
|   userData:  | ||||
|   assetBundleName:  | ||||
|   assetBundleVariant:  | ||||
| @@ -1,17 +0,0 @@ | ||||
| using Mirror; | ||||
| using UnityEngine; | ||||
| using TMPro; | ||||
|  | ||||
| public class MenuStartHost : MonoBehaviour | ||||
| { | ||||
|     [SerializeField] private TMP_InputField UsernameInput; | ||||
|     public void StartHost() | ||||
|     { | ||||
|         if (UsernameInput.text != "") | ||||
|         { | ||||
|             Debug.Log("[MENU] Starting host..."); | ||||
|             GameObject.FindGameObjectWithTag("VariableSaver").GetComponent<VariableSaver>().username = UsernameInput.text; | ||||
|             NetworkManager.singleton.StartHost(); | ||||
|         } | ||||
|     } | ||||
| } | ||||
| @@ -1,11 +0,0 @@ | ||||
| fileFormatVersion: 2 | ||||
| guid: ba11870b778d63f44b93c88ab9ee53e2 | ||||
| MonoImporter: | ||||
|   externalObjects: {} | ||||
|   serializedVersion: 2 | ||||
|   defaultReferences: [] | ||||
|   executionOrder: 0 | ||||
|   icon: {instanceID: 0} | ||||
|   userData:  | ||||
|   assetBundleName:  | ||||
|   assetBundleVariant:  | ||||
		Reference in New Issue
	
	Block a user
	 DerTyp187
					DerTyp187