added scene

This commit is contained in:
DerTyp187
2021-11-26 08:56:05 +01:00
parent 62e35c6b7d
commit f238d16f8e
17 changed files with 4849 additions and 0 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 68e95db5b9c629148994409c6c7f814a
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

1257
Assets/Scenes/Lobby.unity Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 33f487c6a0f179a4cb0f9cd2f080aca8
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 8e20cf4fb20172a40b1905995d0cdd7e
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,135 @@
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()
{
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";
}
}
}
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;
}
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 63e8a56290440f546ab703ec69045442
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,39 @@
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;
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: fd4b898ade2dd5d41b2181efb5309551
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,7 @@
using Mirror;
using UnityEngine;
public class MenuManager : NetworkManager
{
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 145706024aa7ca34b9312d85f68fc209
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,55 @@
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);
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 62a9b64eb5d37bb43a7f4ff101582b6f
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,16 @@
using Mirror;
using UnityEngine;
using UnityEngine.UI;
using TMPro;
public class MenuStartClient : MonoBehaviour
{
[SerializeField] private TMP_InputField IpInput;
public void StartClient()
{
Debug.Log("[MENU] Starting client...");
NetworkManager.singleton.networkAddress = IpInput.text;
NetworkManager.singleton.StartClient();
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 4e1b622a4122f984e8ecc6b6c9556411
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,11 @@
using Mirror;
using UnityEngine;
public class MenuStartHost : MonoBehaviour
{
public void StartHost()
{
Debug.Log("[MENU] Starting host...");
NetworkManager.singleton.StartHost();
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: ba11870b778d63f44b93c88ab9ee53e2
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant: