Client Timeout

This commit is contained in:
brausjonas
2023-01-29 01:54:53 +01:00
parent da8ce4b425
commit 6754d710b2
21 changed files with 1057 additions and 187 deletions
+8 -3
View File
@@ -19,6 +19,7 @@ public class Client : MonoBehaviour
[SerializeField] private Field nextField;
[SerializeField] private GameObject cam;
[SerializeField] private UIHandler uiHandler;
private void Start()
{
@@ -29,9 +30,9 @@ public class Client : MonoBehaviour
string roomCode = PlayerPrefs.GetString("roomcode");
stream.Write(Encoding.ASCII.GetBytes(roomCode));
stream.Write(Encoding.ASCII.GetBytes(roomCode), 0, 10);
string name = PlayerPrefs.GetString("name");
stream.Write(Encoding.ASCII.GetBytes(name));
stream.Write(Encoding.ASCII.GetBytes(name), 0, 10);
new Thread(Read).Start();
}
@@ -97,7 +98,11 @@ public class Client : MonoBehaviour
players[job.data[1]].name = Encoding.ASCII.GetString(name).Replace(" ", "");
players[job.data[1]].Init();
Debug.Log("test");
uiHandler.DeactivateLayout0();
break;
case 126:
stream.Write(new byte[]{126, 0, 0, 0, 0, 0, 0, 0, 0, 0}, 0, 10);
break;
case 127:
client.Close();
@@ -1,5 +1,6 @@
using System.Collections;
using System.Collections.Generic;
using TMPro;
using UnityEngine;
public class NoPlayablePlayer : Player
@@ -23,6 +24,8 @@ public class NoPlayablePlayer : Player
public override void Init()
{
GetComponentInChildren<TMP_Text>().text = name;
activated = false;
diceScript = dice.GetComponent<Dice>();
}
@@ -1,5 +1,6 @@
using System.Collections;
using System.Collections.Generic;
using TMPro;
using UnityEngine;
public class PlayablePlayer : Player
@@ -26,6 +27,8 @@ public class PlayablePlayer : Player
public override void Init()
{
GetComponentInChildren<TMP_Text>().text = name;
activated = false;
QualitySettings.vSyncCount = 0;
Application.targetFrameRate = 59;
@@ -17,20 +17,21 @@ public class StartHandler : MonoBehaviour
[SerializeField] private TMP_Text nameEnter;
[SerializeField] private GameObject buttonJoin;
[SerializeField] private GameObject buttonSubmitName;
[SerializeField] private TMP_Text playerName;
private string roomcode;
private void Start()
{
PlayerPrefs.DeleteAll();
if (PlayerPrefs.HasKey("name"))
{
playerName.text = "Name: " + PlayerPrefs.GetString("name");
layout0.SetActive(false);
layout1.SetActive(true);
}
else
{
playerName.text = "";
layout0.SetActive(true);
layout1.SetActive(false);
}
@@ -127,7 +128,15 @@ public class StartHandler : MonoBehaviour
PlayerPrefs.SetString("name", name);
PlayerPrefs.Save();
playerName.text = "Name: " + PlayerPrefs.GetString("name");
layout0.SetActive(false);
layout1.SetActive(true);
}
public void ButtonEditName()
{
layout0.SetActive(true);
layout1.SetActive(false);
}
}
+18
View File
@@ -0,0 +1,18 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class UIHandler : MonoBehaviour
{
[SerializeField] private GameObject layout0;
private void Start()
{
layout0.SetActive(true);
}
public void DeactivateLayout0()
{
layout0.SetActive(false);
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 56798c9c6d93720458be25d44a5729f7
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant: