mirror of
https://github.com/Steffo99/better-tee.git
synced 2024-11-24 00:04:19 +00:00
Add some new code?
This commit is contained in:
parent
23b5280cd6
commit
85f321e506
8 changed files with 461 additions and 78 deletions
|
@ -11,11 +11,13 @@ namespace BetterTee.NetMsg
|
||||||
public class MaxPlayersCapReached : MessageBase {}
|
public class MaxPlayersCapReached : MessageBase {}
|
||||||
public class NotEnoughPlayers : MessageBase {}
|
public class NotEnoughPlayers : MessageBase {}
|
||||||
public class NoSettings : MessageBase {}
|
public class NoSettings : MessageBase {}
|
||||||
|
public class MissingGameSettings : MessageBase {}
|
||||||
}
|
}
|
||||||
|
|
||||||
public class LobbyStatusChange : MessageBase {
|
public class LobbyStatusChange : MessageBase {
|
||||||
public ConnectedPlayerData[] players;
|
public ConnectedPlayerData[] players;
|
||||||
public ConnectedViewerData[] viewers;
|
public ConnectedViewerData[] viewers;
|
||||||
|
public bool canStart;
|
||||||
}
|
}
|
||||||
|
|
||||||
public class LobbyEnd : MessageBase
|
public class LobbyEnd : MessageBase
|
||||||
|
|
|
@ -9,14 +9,23 @@ namespace BetterTee.Server
|
||||||
|
|
||||||
public class ServerMainController : MonoBehaviour
|
public class ServerMainController : MonoBehaviour
|
||||||
{
|
{
|
||||||
|
|
||||||
[Header("Status")]
|
[Header("Status")]
|
||||||
public string lobbyPassword = null;
|
|
||||||
public Dictionary<NetworkConnection, ConnectedPlayer> players;
|
public Dictionary<NetworkConnection, ConnectedPlayer> players;
|
||||||
public Dictionary<NetworkConnection, ConnectedViewer> viewers;
|
public Dictionary<NetworkConnection, ConnectedViewer> viewers;
|
||||||
public GamePhase phase = GamePhase.UNINTIALIZED;
|
public GamePhase gamePhase = GamePhase.UNINTIALIZED;
|
||||||
public GameSettings gameSettings = null;
|
public GameSettings gameSettings = null;
|
||||||
public int? currentActNumber = null;
|
public int? currentActNumber = null;
|
||||||
|
public string lobbyPassword = null;
|
||||||
|
|
||||||
|
public bool CanStartGame {
|
||||||
|
get {
|
||||||
|
return (
|
||||||
|
gamePhase == GamePhase.LOBBY &&
|
||||||
|
gameSettings != null &&
|
||||||
|
players.Count >= gameSettings.minimumPlayers
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public ActSettings CurrentActSettings {
|
public ActSettings CurrentActSettings {
|
||||||
get {
|
get {
|
||||||
|
@ -28,6 +37,7 @@ namespace BetterTee.Server
|
||||||
|
|
||||||
[Header("Constants")]
|
[Header("Constants")]
|
||||||
public const int MAX_CONNECTIONS = 32;
|
public const int MAX_CONNECTIONS = 32;
|
||||||
|
public const int PASSWORD_LENGTH = 4;
|
||||||
|
|
||||||
#region Unity Methods
|
#region Unity Methods
|
||||||
|
|
||||||
|
@ -42,23 +52,29 @@ namespace BetterTee.Server
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
public void ServerStart() {
|
public void ServerStart() {
|
||||||
LogFilter.Debug = true;
|
gamePhase = GamePhase.LOBBY;
|
||||||
phase = GamePhase.LOBBY;
|
|
||||||
players = new Dictionary<NetworkConnection, ConnectedPlayer>();
|
players = new Dictionary<NetworkConnection, ConnectedPlayer>();
|
||||||
viewers = new Dictionary<NetworkConnection, ConnectedViewer>();
|
viewers = new Dictionary<NetworkConnection, ConnectedViewer>();
|
||||||
Transport.activeTransport = GetComponent<TelepathyTransport>();
|
Transport.activeTransport = GetComponent<TelepathyTransport>();
|
||||||
|
|
||||||
|
#region Password Creation
|
||||||
|
char[] charList = "ABCDEFGHIJKLMNOPQRSTUVWXYZ".ToCharArray();
|
||||||
|
lobbyPassword = "";
|
||||||
|
for(int i = 0; i < PASSWORD_LENGTH; i++) {
|
||||||
|
lobbyPassword += charList[UnityEngine.Random.Range(0, charList.Length)];
|
||||||
|
}
|
||||||
|
Debug.Log("The server password is: {}");
|
||||||
|
#endregion
|
||||||
|
|
||||||
#region Client Messages
|
#region Client Messages
|
||||||
NetworkServer.RegisterHandler<NetMsg.Client.PlayerJoin>(OnPlayerJoin);
|
NetworkServer.RegisterHandler<NetMsg.Client.PlayerJoin>(OnPlayerJoin);
|
||||||
NetworkServer.RegisterHandler<NetMsg.Client.ActResultsMsg>(OnActResults);
|
NetworkServer.RegisterHandler<NetMsg.Client.ActResultsMsg>(OnActResults);
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region Viewer Messages
|
#region Viewer Messages
|
||||||
NetworkServer.RegisterHandler<NetMsg.Viewer.Settings>(OnGameSettings);
|
NetworkServer.RegisterHandler<NetMsg.Viewer.Settings>(OnGameSettings);
|
||||||
NetworkServer.RegisterHandler<NetMsg.Viewer.ViewerLink>(OnViewerLink);
|
NetworkServer.RegisterHandler<NetMsg.Viewer.ViewerLink>(OnViewerLink);
|
||||||
NetworkServer.RegisterHandler<NetMsg.Viewer.GameStart>(OnGameStart);
|
NetworkServer.RegisterHandler<NetMsg.Viewer.GameStart>(OnGameStart);
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region Other Messages
|
#region Other Messages
|
||||||
NetworkServer.RegisterHandler<ConnectMessage>(OnConnect);
|
NetworkServer.RegisterHandler<ConnectMessage>(OnConnect);
|
||||||
NetworkServer.RegisterHandler<DisconnectMessage>(OnDisconnect);
|
NetworkServer.RegisterHandler<DisconnectMessage>(OnDisconnect);
|
||||||
|
@ -70,13 +86,15 @@ namespace BetterTee.Server
|
||||||
public void SendLobbyUpdate() {
|
public void SendLobbyUpdate() {
|
||||||
SendToAllRegistered<NetMsg.Server.LobbyStatusChange>(new NetMsg.Server.LobbyStatusChange {
|
SendToAllRegistered<NetMsg.Server.LobbyStatusChange>(new NetMsg.Server.LobbyStatusChange {
|
||||||
players = players.Values.ToList().ConvertAll<ConnectedPlayerData>(player => player.Data).ToArray(),
|
players = players.Values.ToList().ConvertAll<ConnectedPlayerData>(player => player.Data).ToArray(),
|
||||||
viewers = viewers.Values.ToList().ConvertAll<ConnectedViewerData>(viewer => viewer.Data).ToArray()
|
viewers = viewers.Values.ToList().ConvertAll<ConnectedViewerData>(viewer => viewer.Data).ToArray(),
|
||||||
|
canStart = (gameSettings != null && players.Count >= gameSettings.minimumPlayers)
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public void GameStart() {
|
public void GameStart() {
|
||||||
phase = GamePhase.ACTS;
|
gamePhase = GamePhase.ACTS;
|
||||||
currentActNumber = 1;
|
currentActNumber = 1;
|
||||||
|
//TODO?
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ActInit() {
|
public void ActInit() {
|
||||||
|
@ -111,12 +129,11 @@ namespace BetterTee.Server
|
||||||
|
|
||||||
#region Network Events
|
#region Network Events
|
||||||
|
|
||||||
protected void OnConnect(NetworkConnection connection, ConnectMessage message) {
|
protected void OnConnect(NetworkConnection connection, ConnectMessage message) {}
|
||||||
//Kick out clients that don't identify in 5 seconds?
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void OnDisconnect(NetworkConnection connection, DisconnectMessage message) {
|
protected void OnDisconnect(NetworkConnection connection, DisconnectMessage message) {
|
||||||
//How to handle disconnections?
|
//How to handle disconnections?
|
||||||
|
if(gamePhase == GamePhase.LOBBY) {
|
||||||
try {
|
try {
|
||||||
players.Remove(connection);
|
players.Remove(connection);
|
||||||
}
|
}
|
||||||
|
@ -129,15 +146,23 @@ namespace BetterTee.Server
|
||||||
|
|
||||||
SendLobbyUpdate();
|
SendLobbyUpdate();
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
Debug.LogWarning("Disconnections after the lobby phase aren't handled");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
protected void OnPlayerJoin(NetworkConnection connection, NetMsg.Client.PlayerJoin message)
|
protected void OnPlayerJoin(NetworkConnection connection, NetMsg.Client.PlayerJoin message) {
|
||||||
{
|
if(gameSettings == null) {
|
||||||
|
connection.Send<NetMsg.Server.Error.MissingGameSettings>(new NetMsg.Server.Error.MissingGameSettings());
|
||||||
|
connection.Disconnect();
|
||||||
|
return;
|
||||||
|
}
|
||||||
if(message.gamePassword != lobbyPassword) {
|
if(message.gamePassword != lobbyPassword) {
|
||||||
connection.Send<NetMsg.Server.Error.InvalidPassword>(new NetMsg.Server.Error.InvalidPassword());
|
connection.Send<NetMsg.Server.Error.InvalidPassword>(new NetMsg.Server.Error.InvalidPassword());
|
||||||
connection.Disconnect();
|
connection.Disconnect();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if(phase != GamePhase.LOBBY) {
|
if(gamePhase != GamePhase.LOBBY) {
|
||||||
connection.Send<NetMsg.Server.Error.GameAlreadyStarted>(new NetMsg.Server.Error.GameAlreadyStarted());
|
connection.Send<NetMsg.Server.Error.GameAlreadyStarted>(new NetMsg.Server.Error.GameAlreadyStarted());
|
||||||
connection.Disconnect();
|
connection.Disconnect();
|
||||||
return;
|
return;
|
||||||
|
@ -154,22 +179,10 @@ namespace BetterTee.Server
|
||||||
};
|
};
|
||||||
players.Add(connection, newPlayer);
|
players.Add(connection, newPlayer);
|
||||||
|
|
||||||
Debug.LogFormat("Player {0} joined the game", message.playerName);
|
|
||||||
|
|
||||||
SendLobbyUpdate();
|
SendLobbyUpdate();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void OnActResults(NetworkConnection connection, NetMsg.Client.ActResultsMsg message) {
|
protected void OnViewerLink(NetworkConnection connection, NetMsg.Viewer.ViewerLink message) {
|
||||||
//Where should we put act results?
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void OnGameSettings(NetworkConnection connection, NetMsg.Viewer.Settings message) {
|
|
||||||
Debug.LogFormat("Received GameSettings from {0}", viewers[connection].name);
|
|
||||||
gameSettings = message.settings;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void OnViewerLink(NetworkConnection connection, NetMsg.Viewer.ViewerLink message)
|
|
||||||
{
|
|
||||||
if(message.gamePassword != lobbyPassword) {
|
if(message.gamePassword != lobbyPassword) {
|
||||||
connection.Send<NetMsg.Server.Error.InvalidPassword>(new NetMsg.Server.Error.InvalidPassword());
|
connection.Send<NetMsg.Server.Error.InvalidPassword>(new NetMsg.Server.Error.InvalidPassword());
|
||||||
connection.Disconnect();
|
connection.Disconnect();
|
||||||
|
@ -182,20 +195,25 @@ namespace BetterTee.Server
|
||||||
};
|
};
|
||||||
viewers.Add(connection, newViewer);
|
viewers.Add(connection, newViewer);
|
||||||
|
|
||||||
Debug.LogFormat("Viewer {0} is now linked to the game", message.viewerName);
|
SendLobbyUpdate();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void OnGameSettings(NetworkConnection connection, NetMsg.Viewer.Settings message) {
|
||||||
|
if(gameSettings != null) {
|
||||||
|
Debug.LogWarning("gameSettings were overwritten.");
|
||||||
|
}
|
||||||
|
|
||||||
|
gameSettings = message.settings;
|
||||||
|
|
||||||
SendLobbyUpdate();
|
SendLobbyUpdate();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void OnGameStart(NetworkConnection connection, NetMsg.Viewer.GameStart message) {
|
protected void OnGameStart(NetworkConnection connection, NetMsg.Viewer.GameStart message) {
|
||||||
|
|
||||||
if(gameSettings == null) {
|
if(gameSettings == null) {
|
||||||
connection.Send<NetMsg.Server.Error.NoSettings>(new NetMsg.Server.Error.NoSettings());
|
connection.Send<NetMsg.Server.Error.NoSettings>(new NetMsg.Server.Error.NoSettings());
|
||||||
connection.Disconnect();
|
connection.Disconnect();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(players.Count < gameSettings.minimumPlayers) {
|
if(players.Count < gameSettings.minimumPlayers) {
|
||||||
connection.Send<NetMsg.Server.Error.NotEnoughPlayers>(new NetMsg.Server.Error.NotEnoughPlayers());
|
connection.Send<NetMsg.Server.Error.NotEnoughPlayers>(new NetMsg.Server.Error.NotEnoughPlayers());
|
||||||
connection.Disconnect();
|
connection.Disconnect();
|
||||||
|
@ -205,6 +223,8 @@ namespace BetterTee.Server
|
||||||
GameStart();
|
GameStart();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected void OnActResults(NetworkConnection connection, NetMsg.Client.ActResultsMsg message) {}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
using System;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using UnityEngine.EventSystems;
|
using UnityEngine.EventSystems;
|
||||||
|
|
||||||
|
@ -5,7 +6,7 @@ using UnityEngine.EventSystems;
|
||||||
namespace BetterTee.Viewer
|
namespace BetterTee.Viewer
|
||||||
{
|
{
|
||||||
|
|
||||||
public class ActViewer
|
public abstract class ActViewer
|
||||||
{
|
{
|
||||||
[Header("Settings")]
|
[Header("Settings")]
|
||||||
public ActSettings settings = null;
|
public ActSettings settings = null;
|
||||||
|
@ -14,6 +15,73 @@ namespace BetterTee.Viewer
|
||||||
[Header("Objects")]
|
[Header("Objects")]
|
||||||
public Canvas canvas = null;
|
public Canvas canvas = null;
|
||||||
public EventSystem eventSystem = null;
|
public EventSystem eventSystem = null;
|
||||||
|
|
||||||
|
public ActPhase Phase {
|
||||||
|
get {
|
||||||
|
return phase;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[Serializable]
|
||||||
|
public class InvalidPhaseException : Exception {
|
||||||
|
public readonly ActPhase currentPhase;
|
||||||
|
|
||||||
|
public InvalidPhaseException(ActPhase currentPhase) {
|
||||||
|
this.currentPhase = currentPhase;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Call this to initialize the Act (GameObjects, ActSettings, etc). All interactable components should be disabled in this phase.
|
||||||
|
/// </summary>
|
||||||
|
public virtual void ActInit() {
|
||||||
|
phase = ActPhase.INIT;
|
||||||
|
|
||||||
|
canvas = GameObject.FindGameObjectWithTag("Canvas")?.GetComponent<Canvas>();
|
||||||
|
eventSystem = GameObject.FindGameObjectWithTag("EventSystem")?.GetComponent<EventSystem>();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Call this to enable all interactable components in the Act. It should be called when the player is ready to play.
|
||||||
|
/// </summary>
|
||||||
|
public virtual void ActStart() {
|
||||||
|
if(Phase != ActPhase.INIT) throw new InvalidPhaseException(phase);
|
||||||
|
phase = ActPhase.START;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Call this to disable once again all interactable components in the Act. It should be called when the Act is finished (time ran out, player reached submission limit, etc).
|
||||||
|
/// </summary>
|
||||||
|
public virtual void ActEnd() {
|
||||||
|
if(Phase != ActPhase.START) throw new InvalidPhaseException(phase);
|
||||||
|
phase = ActPhase.END;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Call this to cleanup all GameObjects created during the Init phase.
|
||||||
|
/// </summary>
|
||||||
|
public virtual void ActCleanup() {
|
||||||
|
if(Phase != ActPhase.END) {
|
||||||
|
Debug.LogWarningFormat("ActCleanup() was called during {0}", Phase);
|
||||||
|
}
|
||||||
|
phase = ActPhase.CLEANUP;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected virtual void Awake() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
protected virtual void Start() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
protected virtual void Update() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
protected virtual void OnDestroy() {
|
||||||
|
ActCleanup();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -15,18 +15,12 @@ namespace BetterTee.Viewer
|
||||||
public EventSystem eventSystem = null;
|
public EventSystem eventSystem = null;
|
||||||
public Action startGameAction = null;
|
public Action startGameAction = null;
|
||||||
public Text lobbyText = null;
|
public Text lobbyText = null;
|
||||||
public Text playersText = null;
|
public InputField gameSettingsField = null;
|
||||||
public Text viewersText = null;
|
|
||||||
public Text playersList = null;
|
|
||||||
public Text viewersList = null;
|
|
||||||
public StartGameBtn startGameBtn = null;
|
public StartGameBtn startGameBtn = null;
|
||||||
|
|
||||||
[Header("Prefabs")]
|
[Header("Prefabs")]
|
||||||
public GameObject lobbyTextPrefab;
|
public GameObject lobbyTextPrefab;
|
||||||
public GameObject playersTextPrefab;
|
public GameObject gameSettingsFieldPrefab;
|
||||||
public GameObject viewersTextPrefab;
|
|
||||||
public GameObject playersListPrefab;
|
|
||||||
public GameObject viewersListPrefab;
|
|
||||||
public GameObject startGameBtnPrefab;
|
public GameObject startGameBtnPrefab;
|
||||||
|
|
||||||
protected void Start() {
|
protected void Start() {
|
||||||
|
@ -34,25 +28,14 @@ namespace BetterTee.Viewer
|
||||||
eventSystem = GameObject.FindGameObjectWithTag("EventSystem")?.GetComponent<EventSystem>();
|
eventSystem = GameObject.FindGameObjectWithTag("EventSystem")?.GetComponent<EventSystem>();
|
||||||
|
|
||||||
lobbyText = Instantiate(lobbyTextPrefab, canvas.transform).GetComponent<Text>();
|
lobbyText = Instantiate(lobbyTextPrefab, canvas.transform).GetComponent<Text>();
|
||||||
playersText = Instantiate(playersTextPrefab, canvas.transform).GetComponent<Text>();
|
gameSettingsField = Instantiate(gameSettingsFieldPrefab, canvas.transform).GetComponent<InputField>();
|
||||||
viewersText = Instantiate(viewersTextPrefab, canvas.transform).GetComponent<Text>();
|
|
||||||
playersList = Instantiate(playersListPrefab, canvas.transform).GetComponent<Text>();
|
|
||||||
viewersList = Instantiate(viewersListPrefab, canvas.transform).GetComponent<Text>();
|
|
||||||
startGameBtn = Instantiate(startGameBtnPrefab, canvas.transform).GetComponent<StartGameBtn>();
|
startGameBtn = Instantiate(startGameBtnPrefab, canvas.transform).GetComponent<StartGameBtn>();
|
||||||
startGameBtn.lobbyController = this;
|
startGameBtn.lobbyController = this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void OnLobbyStatusChange(ConnectedPlayerData[] players, ConnectedViewerData[] viewers) {
|
public void OnLobbyStatusChange(ConnectedPlayerData[] players, ConnectedViewerData[] viewers, bool canStart) {
|
||||||
playersList.text = "";
|
gameSettingsField.interactable = true;
|
||||||
viewersList.text = "";
|
startGameBtn.GetComponent<Button>().interactable = canStart;
|
||||||
|
|
||||||
foreach(ConnectedPlayerData player in players) {
|
|
||||||
playersList.text += String.Format("[{0}] {1}\n", player.id, player.name);
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach(ConnectedViewerData viewer in viewers) {
|
|
||||||
viewersList.text += String.Format("[{0}] {1}\n", viewer.id, viewer.name);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void OnStartGameBtnPress() {
|
public void OnStartGameBtnPress() {
|
||||||
|
@ -61,10 +44,8 @@ namespace BetterTee.Viewer
|
||||||
|
|
||||||
protected void OnDestroy() {
|
protected void OnDestroy() {
|
||||||
Destroy(lobbyText.gameObject);
|
Destroy(lobbyText.gameObject);
|
||||||
Destroy(playersText.gameObject);
|
Destroy(gameSettingsField.gameObject);
|
||||||
Destroy(viewersText.gameObject);
|
Destroy(startGameBtn.gameObject);
|
||||||
Destroy(playersList.gameObject);
|
|
||||||
Destroy(viewersList.gameObject);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,6 +37,16 @@ namespace BetterTee.Viewer
|
||||||
};
|
};
|
||||||
|
|
||||||
public void LoadAct(ActSettings settings) {
|
public void LoadAct(ActSettings settings) {
|
||||||
|
if(settings.type == "Drawing") {
|
||||||
|
currentAct = Instantiate(drawingViewerPrefab).GetComponent<ActViewer>();
|
||||||
|
currentAct.settings = settings;
|
||||||
|
currentAct.ActInit();
|
||||||
|
}
|
||||||
|
else if(settings.type == "Typing") {
|
||||||
|
currentAct = Instantiate(typingViewerPrefab).GetComponent<ActViewer>();
|
||||||
|
currentAct.settings = settings;
|
||||||
|
currentAct.ActInit();
|
||||||
|
}
|
||||||
throw new InvalidActTypeException(settings.type);
|
throw new InvalidActTypeException(settings.type);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -61,7 +71,6 @@ namespace BetterTee.Viewer
|
||||||
#region Network Events
|
#region Network Events
|
||||||
|
|
||||||
protected void OnConnect(NetworkConnection connection, ConnectMessage message) {
|
protected void OnConnect(NetworkConnection connection, ConnectMessage message) {
|
||||||
Debug.Log("Sending ViewerLink message");
|
|
||||||
connection.Send<NetMsg.Viewer.ViewerLink>(new NetMsg.Viewer.ViewerLink {
|
connection.Send<NetMsg.Viewer.ViewerLink>(new NetMsg.Viewer.ViewerLink {
|
||||||
viewerName = viewerName,
|
viewerName = viewerName,
|
||||||
gamePassword = gamePassword
|
gamePassword = gamePassword
|
||||||
|
@ -76,25 +85,26 @@ namespace BetterTee.Viewer
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void OnLobbyStatusChange(NetworkConnection connection, NetMsg.Server.LobbyStatusChange message) {
|
protected void OnLobbyStatusChange(NetworkConnection connection, NetMsg.Server.LobbyStatusChange message) {
|
||||||
lobbyController.OnLobbyStatusChange(message.players, message.viewers);
|
lobbyController.OnLobbyStatusChange(message.players, message.viewers, message.canStart);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void OnLobbyEnd(NetworkConnection connection, NetMsg.Server.LobbyEnd message) {}
|
protected void OnLobbyEnd(NetworkConnection connection, NetMsg.Server.LobbyEnd message) {
|
||||||
|
Destroy(lobbyController.gameObject);
|
||||||
|
}
|
||||||
|
|
||||||
protected void OnGameEnd(NetworkConnection connection, NetMsg.Server.GameEnd message) {}
|
protected void OnGameEnd(NetworkConnection connection, NetMsg.Server.GameEnd message) {}
|
||||||
|
|
||||||
protected void OnActInit(NetworkConnection connection, NetMsg.Server.ActInit message) {
|
protected void OnActInit(NetworkConnection connection, NetMsg.Server.ActInit message) {
|
||||||
LoadAct(message.settings);
|
LoadAct(message.settings);
|
||||||
//currentAct.ActInit();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void OnActStart(NetworkConnection connection, NetMsg.Server.ActStart message) {
|
protected void OnActStart(NetworkConnection connection, NetMsg.Server.ActStart message) {
|
||||||
//currentAct.ActStart();
|
currentAct.ActStart();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void OnActEnd(NetworkConnection connection, NetMsg.Server.ActEnd message) {
|
protected void OnActEnd(NetworkConnection connection, NetMsg.Server.ActEnd message) {
|
||||||
//currentAct.ActEnd();
|
currentAct.ActEnd();
|
||||||
//Destroy(currentAct);
|
Destroy(currentAct.gameObject);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
295
Assets/Prefabs/Misc/Game Settings Field.prefab
Normal file
295
Assets/Prefabs/Misc/Game Settings Field.prefab
Normal file
|
@ -0,0 +1,295 @@
|
||||||
|
%YAML 1.1
|
||||||
|
%TAG !u! tag:unity3d.com,2011:
|
||||||
|
--- !u!1 &3870861457645760480
|
||||||
|
GameObject:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
serializedVersion: 6
|
||||||
|
m_Component:
|
||||||
|
- component: {fileID: 3870861457645760483}
|
||||||
|
- component: {fileID: 3870861457645760485}
|
||||||
|
- component: {fileID: 3870861457645760482}
|
||||||
|
m_Layer: 5
|
||||||
|
m_Name: Placeholder
|
||||||
|
m_TagString: Untagged
|
||||||
|
m_Icon: {fileID: 0}
|
||||||
|
m_NavMeshLayer: 0
|
||||||
|
m_StaticEditorFlags: 0
|
||||||
|
m_IsActive: 1
|
||||||
|
--- !u!224 &3870861457645760483
|
||||||
|
RectTransform:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 3870861457645760480}
|
||||||
|
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
|
||||||
|
m_LocalPosition: {x: 0, y: 0, z: 0}
|
||||||
|
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||||
|
m_Children: []
|
||||||
|
m_Father: {fileID: 3870861458944526235}
|
||||||
|
m_RootOrder: 0
|
||||||
|
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||||
|
m_AnchorMin: {x: 0, y: 0}
|
||||||
|
m_AnchorMax: {x: 1, y: 1}
|
||||||
|
m_AnchoredPosition: {x: 0, y: -0.5}
|
||||||
|
m_SizeDelta: {x: -20, y: -13}
|
||||||
|
m_Pivot: {x: 0.5, y: 0.5}
|
||||||
|
--- !u!222 &3870861457645760485
|
||||||
|
CanvasRenderer:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 3870861457645760480}
|
||||||
|
m_CullTransparentMesh: 0
|
||||||
|
--- !u!114 &3870861457645760482
|
||||||
|
MonoBehaviour:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 3870861457645760480}
|
||||||
|
m_Enabled: 1
|
||||||
|
m_EditorHideFlags: 0
|
||||||
|
m_Script: {fileID: 11500000, guid: 5f7201a12d95ffc409449d95f23cf332, type: 3}
|
||||||
|
m_Name:
|
||||||
|
m_EditorClassIdentifier:
|
||||||
|
m_Material: {fileID: 0}
|
||||||
|
m_Color: {r: 0.19607843, g: 0.19607843, b: 0.19607843, a: 0.5}
|
||||||
|
m_RaycastTarget: 1
|
||||||
|
m_OnCullStateChanged:
|
||||||
|
m_PersistentCalls:
|
||||||
|
m_Calls: []
|
||||||
|
m_FontData:
|
||||||
|
m_Font: {fileID: 10102, guid: 0000000000000000e000000000000000, type: 0}
|
||||||
|
m_FontSize: 64
|
||||||
|
m_FontStyle: 2
|
||||||
|
m_BestFit: 0
|
||||||
|
m_MinSize: 6
|
||||||
|
m_MaxSize: 177
|
||||||
|
m_Alignment: 4
|
||||||
|
m_AlignByGeometry: 0
|
||||||
|
m_RichText: 1
|
||||||
|
m_HorizontalOverflow: 0
|
||||||
|
m_VerticalOverflow: 0
|
||||||
|
m_LineSpacing: 1
|
||||||
|
m_Text: Paste the Game JSON here!
|
||||||
|
--- !u!1 &3870861457914105388
|
||||||
|
GameObject:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
serializedVersion: 6
|
||||||
|
m_Component:
|
||||||
|
- component: {fileID: 3870861457914105391}
|
||||||
|
- component: {fileID: 3870861457914105393}
|
||||||
|
- component: {fileID: 3870861457914105390}
|
||||||
|
m_Layer: 5
|
||||||
|
m_Name: Text
|
||||||
|
m_TagString: Untagged
|
||||||
|
m_Icon: {fileID: 0}
|
||||||
|
m_NavMeshLayer: 0
|
||||||
|
m_StaticEditorFlags: 0
|
||||||
|
m_IsActive: 1
|
||||||
|
--- !u!224 &3870861457914105391
|
||||||
|
RectTransform:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 3870861457914105388}
|
||||||
|
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
|
||||||
|
m_LocalPosition: {x: 0, y: 0, z: 0}
|
||||||
|
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||||
|
m_Children: []
|
||||||
|
m_Father: {fileID: 3870861458944526235}
|
||||||
|
m_RootOrder: 1
|
||||||
|
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||||
|
m_AnchorMin: {x: 0, y: 0}
|
||||||
|
m_AnchorMax: {x: 1, y: 1}
|
||||||
|
m_AnchoredPosition: {x: 0, y: -0.5}
|
||||||
|
m_SizeDelta: {x: -20, y: -13}
|
||||||
|
m_Pivot: {x: 0.5, y: 0.5}
|
||||||
|
--- !u!222 &3870861457914105393
|
||||||
|
CanvasRenderer:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 3870861457914105388}
|
||||||
|
m_CullTransparentMesh: 0
|
||||||
|
--- !u!114 &3870861457914105390
|
||||||
|
MonoBehaviour:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 3870861457914105388}
|
||||||
|
m_Enabled: 1
|
||||||
|
m_EditorHideFlags: 0
|
||||||
|
m_Script: {fileID: 11500000, guid: 5f7201a12d95ffc409449d95f23cf332, type: 3}
|
||||||
|
m_Name:
|
||||||
|
m_EditorClassIdentifier:
|
||||||
|
m_Material: {fileID: 0}
|
||||||
|
m_Color: {r: 0.19607843, g: 0.19607843, b: 0.19607843, a: 1}
|
||||||
|
m_RaycastTarget: 1
|
||||||
|
m_OnCullStateChanged:
|
||||||
|
m_PersistentCalls:
|
||||||
|
m_Calls: []
|
||||||
|
m_FontData:
|
||||||
|
m_Font: {fileID: 10102, guid: 0000000000000000e000000000000000, type: 0}
|
||||||
|
m_FontSize: 64
|
||||||
|
m_FontStyle: 0
|
||||||
|
m_BestFit: 0
|
||||||
|
m_MinSize: 6
|
||||||
|
m_MaxSize: 64
|
||||||
|
m_Alignment: 4
|
||||||
|
m_AlignByGeometry: 0
|
||||||
|
m_RichText: 0
|
||||||
|
m_HorizontalOverflow: 0
|
||||||
|
m_VerticalOverflow: 0
|
||||||
|
m_LineSpacing: 1
|
||||||
|
m_Text:
|
||||||
|
--- !u!1 &3870861458944526232
|
||||||
|
GameObject:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
serializedVersion: 6
|
||||||
|
m_Component:
|
||||||
|
- component: {fileID: 3870861458944526235}
|
||||||
|
- component: {fileID: 3870861458944526236}
|
||||||
|
- component: {fileID: 3870861458944526237}
|
||||||
|
- component: {fileID: 6553367698705692023}
|
||||||
|
m_Layer: 5
|
||||||
|
m_Name: Submission Field 1
|
||||||
|
m_TagString: Untagged
|
||||||
|
m_Icon: {fileID: 0}
|
||||||
|
m_NavMeshLayer: 0
|
||||||
|
m_StaticEditorFlags: 0
|
||||||
|
m_IsActive: 1
|
||||||
|
--- !u!224 &3870861458944526235
|
||||||
|
RectTransform:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 3870861458944526232}
|
||||||
|
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
|
||||||
|
m_LocalPosition: {x: 0, y: 0, z: 0}
|
||||||
|
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||||
|
m_Children:
|
||||||
|
- {fileID: 3870861457645760483}
|
||||||
|
- {fileID: 3870861457914105391}
|
||||||
|
m_Father: {fileID: 0}
|
||||||
|
m_RootOrder: 0
|
||||||
|
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||||
|
m_AnchorMin: {x: 0, y: 0}
|
||||||
|
m_AnchorMax: {x: 1, y: 1}
|
||||||
|
m_AnchoredPosition: {x: 0, y: 50}
|
||||||
|
m_SizeDelta: {x: -24, y: -124}
|
||||||
|
m_Pivot: {x: 0.5, y: 0.5}
|
||||||
|
--- !u!222 &3870861458944526236
|
||||||
|
CanvasRenderer:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 3870861458944526232}
|
||||||
|
m_CullTransparentMesh: 0
|
||||||
|
--- !u!114 &3870861458944526237
|
||||||
|
MonoBehaviour:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 3870861458944526232}
|
||||||
|
m_Enabled: 1
|
||||||
|
m_EditorHideFlags: 0
|
||||||
|
m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3}
|
||||||
|
m_Name:
|
||||||
|
m_EditorClassIdentifier:
|
||||||
|
m_Material: {fileID: 0}
|
||||||
|
m_Color: {r: 1, g: 1, b: 1, a: 1}
|
||||||
|
m_RaycastTarget: 1
|
||||||
|
m_OnCullStateChanged:
|
||||||
|
m_PersistentCalls:
|
||||||
|
m_Calls: []
|
||||||
|
m_Sprite: {fileID: 10911, guid: 0000000000000000f000000000000000, type: 0}
|
||||||
|
m_Type: 1
|
||||||
|
m_PreserveAspect: 0
|
||||||
|
m_FillCenter: 1
|
||||||
|
m_FillMethod: 4
|
||||||
|
m_FillAmount: 1
|
||||||
|
m_FillClockwise: 1
|
||||||
|
m_FillOrigin: 0
|
||||||
|
m_UseSpriteMesh: 0
|
||||||
|
m_PixelsPerUnitMultiplier: 1
|
||||||
|
--- !u!114 &6553367698705692023
|
||||||
|
MonoBehaviour:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 3870861458944526232}
|
||||||
|
m_Enabled: 1
|
||||||
|
m_EditorHideFlags: 0
|
||||||
|
m_Script: {fileID: 11500000, guid: d199490a83bb2b844b9695cbf13b01ef, type: 3}
|
||||||
|
m_Name:
|
||||||
|
m_EditorClassIdentifier:
|
||||||
|
m_Navigation:
|
||||||
|
m_Mode: 3
|
||||||
|
m_SelectOnUp: {fileID: 0}
|
||||||
|
m_SelectOnDown: {fileID: 0}
|
||||||
|
m_SelectOnLeft: {fileID: 0}
|
||||||
|
m_SelectOnRight: {fileID: 0}
|
||||||
|
m_Transition: 1
|
||||||
|
m_Colors:
|
||||||
|
m_NormalColor: {r: 1, g: 1, b: 1, a: 1}
|
||||||
|
m_HighlightedColor: {r: 0.9607843, g: 0.9607843, b: 0.9607843, a: 1}
|
||||||
|
m_PressedColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 1}
|
||||||
|
m_SelectedColor: {r: 0.9607843, g: 0.9607843, b: 0.9607843, a: 1}
|
||||||
|
m_DisabledColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 0.5019608}
|
||||||
|
m_ColorMultiplier: 1
|
||||||
|
m_FadeDuration: 0.1
|
||||||
|
m_SpriteState:
|
||||||
|
m_HighlightedSprite: {fileID: 0}
|
||||||
|
m_PressedSprite: {fileID: 0}
|
||||||
|
m_SelectedSprite: {fileID: 0}
|
||||||
|
m_DisabledSprite: {fileID: 0}
|
||||||
|
m_AnimationTriggers:
|
||||||
|
m_NormalTrigger: Normal
|
||||||
|
m_HighlightedTrigger: Highlighted
|
||||||
|
m_PressedTrigger: Pressed
|
||||||
|
m_SelectedTrigger: Selected
|
||||||
|
m_DisabledTrigger: Disabled
|
||||||
|
m_Interactable: 0
|
||||||
|
m_TargetGraphic: {fileID: 3870861458944526237}
|
||||||
|
m_TextComponent: {fileID: 3870861457914105390}
|
||||||
|
m_Placeholder: {fileID: 3870861457645760482}
|
||||||
|
m_ContentType: 0
|
||||||
|
m_InputType: 0
|
||||||
|
m_AsteriskChar: 42
|
||||||
|
m_KeyboardType: 0
|
||||||
|
m_LineType: 2
|
||||||
|
m_HideMobileInput: 1
|
||||||
|
m_CharacterValidation: 0
|
||||||
|
m_CharacterLimit: 0
|
||||||
|
m_OnEndEdit:
|
||||||
|
m_PersistentCalls:
|
||||||
|
m_Calls: []
|
||||||
|
m_OnValueChanged:
|
||||||
|
m_PersistentCalls:
|
||||||
|
m_Calls: []
|
||||||
|
m_CaretColor: {r: 0.19607843, g: 0.19607843, b: 0.19607843, a: 1}
|
||||||
|
m_CustomCaretColor: 0
|
||||||
|
m_SelectionColor: {r: 0.65882355, g: 0.80784315, b: 1, a: 0.7529412}
|
||||||
|
m_Text:
|
||||||
|
m_CaretBlinkRate: 0.85
|
||||||
|
m_CaretWidth: 5
|
||||||
|
m_ReadOnly: 0
|
7
Assets/Prefabs/Misc/Game Settings Field.prefab.meta
Normal file
7
Assets/Prefabs/Misc/Game Settings Field.prefab.meta
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: b04ddc9d1f92e9e4ea65801e5557ad5d
|
||||||
|
PrefabImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
|
@ -191,7 +191,7 @@ MonoBehaviour:
|
||||||
m_PressedTrigger: Pressed
|
m_PressedTrigger: Pressed
|
||||||
m_SelectedTrigger: Selected
|
m_SelectedTrigger: Selected
|
||||||
m_DisabledTrigger: Disabled
|
m_DisabledTrigger: Disabled
|
||||||
m_Interactable: 1
|
m_Interactable: 0
|
||||||
m_TargetGraphic: {fileID: 3724447121527780808}
|
m_TargetGraphic: {fileID: 3724447121527780808}
|
||||||
m_OnClick:
|
m_OnClick:
|
||||||
m_PersistentCalls:
|
m_PersistentCalls:
|
||||||
|
|
Loading…
Reference in a new issue