7 changed files with 3751 additions and 4 deletions
File diff suppressed because it is too large
@ -0,0 +1,7 @@ |
|||
fileFormatVersion: 2 |
|||
guid: 2e7eb87aefbaeed4692a1080bf81f769 |
|||
DefaultImporter: |
|||
externalObjects: {} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|||
@ -0,0 +1,90 @@ |
|||
using System.Collections; |
|||
using System.Collections.Generic; |
|||
using UnityEngine; |
|||
using UnityEngine.UI; |
|||
|
|||
public class MainMenuController : MonoBehaviour { |
|||
public GameObject mainMenu; |
|||
public GameObject serverMenu; |
|||
public GameObject lobbyMenu; |
|||
|
|||
public InputField username; |
|||
public InputField ip; |
|||
public InputField port; |
|||
|
|||
void Start() { |
|||
// Simulate Lobbies in a Server
|
|||
for (int i = 0; i < 10; i++) { |
|||
var lobby = Instantiate(serverMenu.transform.GetChild(2).GetChild(0).GetChild(0), serverMenu.transform.GetChild(2).GetChild(0)); |
|||
lobby.GetComponentInChildren<Text>().text = "LBY" + Random.Range(0, 10) + Random.Range(0, 10) + Random.Range(0, 10); |
|||
lobby.gameObject.SetActive(true); |
|||
} |
|||
} |
|||
|
|||
void Update() {} |
|||
|
|||
public void ConnectServer() { |
|||
var conn = Client.GetConnection(); |
|||
if (conn == null) { |
|||
if (ip.text != "" && port.text != "") |
|||
Client.Connect(username.text, ip.text + ":" + port.text); |
|||
else |
|||
Client.Connect(username.text); |
|||
conn = Client.GetConnection(); |
|||
} |
|||
|
|||
if (conn != null) { |
|||
mainMenu.SetActive(false); |
|||
serverMenu.SetActive(true); |
|||
lobbyMenu.SetActive(false); |
|||
} |
|||
} |
|||
|
|||
public void LeaveServer() { |
|||
Client.CloseConnection(); |
|||
mainMenu.SetActive(true); |
|||
serverMenu.SetActive(false); |
|||
lobbyMenu.SetActive(false); |
|||
} |
|||
|
|||
public void ConnectLobby(Text codeText) { |
|||
var code = codeText.text; |
|||
Debug.Log(code); |
|||
var conn = Client.GetConnection(); |
|||
if (conn != null) { |
|||
var lobby = conn.GetLobby(); |
|||
if (lobby == null) { |
|||
conn.JoinLobby(code); |
|||
mainMenu.SetActive(false); |
|||
serverMenu.SetActive(false); |
|||
lobbyMenu.SetActive(true); |
|||
} |
|||
} |
|||
} |
|||
|
|||
public void CreateLobby() { |
|||
var conn = Client.GetConnection(); |
|||
if (conn != null) { |
|||
var lobby = conn.GetLobby(); |
|||
if (lobby == null) { |
|||
conn.CreateLobby(); |
|||
mainMenu.SetActive(false); |
|||
serverMenu.SetActive(false); |
|||
lobbyMenu.SetActive(true); |
|||
} |
|||
} |
|||
} |
|||
|
|||
public void LeaveLobby() { |
|||
var conn = Client.GetConnection(); |
|||
if (conn == null) { |
|||
var lobby = conn.GetLobby(); |
|||
if (lobby != null) { |
|||
//conn.LeaveLobby();
|
|||
mainMenu.SetActive(false); |
|||
serverMenu.SetActive(true); |
|||
lobbyMenu.SetActive(false); |
|||
} |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,11 @@ |
|||
fileFormatVersion: 2 |
|||
guid: 71f2f00df2a8c024a8b4bfc9d8412dbe |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|||
@ -0,0 +1,21 @@ |
|||
using System.Collections; |
|||
using System.Collections.Generic; |
|||
using UnityEngine; |
|||
using UnityEngine.UI; |
|||
|
|||
public class Scrollable : MonoBehaviour { |
|||
public const float size = 35f; |
|||
void Start() { |
|||
var sizeY = -(transform.childCount-1) * (transform.GetChild(0).GetComponent<RectTransform>().sizeDelta.y + GetComponent<VerticalLayoutGroup>().spacing); |
|||
Debug.Log(transform.parent.GetComponent<RectTransform>().sizeDelta.y + " -- " + (-sizeY)); |
|||
GetComponent<RectTransform>().offsetMin = new Vector2(GetComponent<RectTransform>().offsetMin.x, (transform.parent.GetComponent<RectTransform>().sizeDelta.y > -sizeY ? 0 : sizeY + transform.parent.GetComponent<RectTransform>().sizeDelta.y + GetComponent<VerticalLayoutGroup>().spacing)); |
|||
int i = 1; |
|||
foreach(Transform child in transform) { |
|||
if(i % 2 == 1) |
|||
child.GetComponent<RawImage>().color = new Color(child.GetComponent<RawImage>().color.r, child.GetComponent<RawImage>().color.g, child.GetComponent<RawImage>().color.b, child.GetComponent<RawImage>().color.a / 2); |
|||
i++; |
|||
} |
|||
} |
|||
|
|||
void Update() {} |
|||
} |
|||
@ -0,0 +1,11 @@ |
|||
fileFormatVersion: 2 |
|||
guid: dc417d59709b83f40a9f4f9541441269 |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|||
Loading…
Reference in new issue