Added map
This commit is contained in:
@@ -5,6 +5,7 @@ using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System;
|
||||
using TMPro;
|
||||
/*
|
||||
GameManager - hlavní tøida pro správu hry
|
||||
@@ -13,43 +14,63 @@ using TMPro;
|
||||
GameManager_Map - subsystém pro správu mapy a prostøedí
|
||||
GameManager_Input - subsystém pro správu vstupu od hráèe
|
||||
GameManager_UI - subsystém pro správu uživatelského rozhraní
|
||||
GamaManager_Stats - subsystém pro správu statistik pro server
|
||||
GamaManager_Stats - subsystém pro správu statistik pro server
|
||||
*/
|
||||
public class GameManager : MonoBehaviour
|
||||
{
|
||||
[Header("Subsystems")]
|
||||
protected GameManager_Network networkSubsystem;
|
||||
protected GameManager_UI uiSubsystem;
|
||||
|
||||
protected GameManager_Map mapSubsystem;
|
||||
|
||||
protected GameClient gameClient;
|
||||
|
||||
[Header("Player Info")]
|
||||
public string displayName;
|
||||
|
||||
[Header("UI Elements")]
|
||||
public Canvas JoinCreateLobby;
|
||||
public Canvas InLobby;
|
||||
public Canvas LoadingScreen;
|
||||
public Canvas GameScreen;
|
||||
|
||||
|
||||
[Header("Map")]
|
||||
public GameObject MapCenterPoint;
|
||||
public BuildingSettings buildingSettings;
|
||||
public PathwaySettings pathwaySettings;
|
||||
public AreaSettings areaSettings;
|
||||
|
||||
|
||||
void Start()
|
||||
{
|
||||
DontDestroyOnLoad(this);
|
||||
if (displayName == null || displayName == "")
|
||||
{
|
||||
displayName = "Player_" + Random.Range(1000, 9999).ToString();
|
||||
displayName = "Player_" + UnityEngine.Random.Range(1000, 9999).ToString();
|
||||
}
|
||||
gameClient = new GameClient(GenerateUUID(), /*displayName*/ GenerateUsername());
|
||||
uiSubsystem = new GameManager_UI(gameClient, JoinCreateLobby, InLobby);
|
||||
uiSubsystem = new GameManager_UI(gameClient, JoinCreateLobby, InLobby, LoadingScreen, GameScreen);
|
||||
networkSubsystem = new GameManager_Network(gameClient);
|
||||
mapSubsystem = new GameManager_Map(gameClient, MapCenterPoint, buildingSettings, pathwaySettings, areaSettings);
|
||||
networkSubsystem.OpenConection();
|
||||
InvokeRepeating(nameof(uiSubsystem.UpdateLobbyUI), 1f, 1f);
|
||||
}
|
||||
private void Update()
|
||||
{
|
||||
if (gameClient.CurrentLobbyState != null)
|
||||
{
|
||||
uiSubsystem.UpdateLobbyUI();
|
||||
|
||||
}
|
||||
try
|
||||
{
|
||||
if (gameClient.CurrentLobbyState.MapDataReady)
|
||||
{
|
||||
mapSubsystem.BuildMap();
|
||||
gameClient.CurrentLobbyState.MapDataReady = false;
|
||||
}
|
||||
}
|
||||
catch (NullReferenceException ex) { }
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -61,13 +82,13 @@ public class GameManager : MonoBehaviour
|
||||
}
|
||||
protected string GenerateUsername()
|
||||
{
|
||||
string Username = Random.Range(0,10).ToString() + Random.Range(0, 10).ToString() + Random.Range(0, 10).ToString() + Random.Range(0, 10).ToString();
|
||||
string Username = UnityEngine.Random.Range(0,10).ToString() + UnityEngine.Random.Range(0, 10).ToString() + UnityEngine.Random.Range(0, 10).ToString() + UnityEngine.Random.Range(0, 10).ToString();
|
||||
Debug.Log(Username);
|
||||
return Username;
|
||||
}
|
||||
public void CreateLobbyButton()
|
||||
{
|
||||
networkSubsystem.CrateLobby(50.0755, 14.4378);
|
||||
networkSubsystem.CrateLobby(50.7727264, 15.0719876);
|
||||
}
|
||||
public void JoinLobbyButton()
|
||||
{
|
||||
@@ -85,6 +106,10 @@ public class GameManager : MonoBehaviour
|
||||
{
|
||||
networkSubsystem.LeaveLobby();
|
||||
}
|
||||
public void StartGameButton()
|
||||
{
|
||||
networkSubsystem.StartGame();
|
||||
}
|
||||
void OnApplicationQuit()
|
||||
{
|
||||
gameClient.Disconnect();
|
||||
|
||||
Reference in New Issue
Block a user