From 641ce0abcbd1c0b257ad37a315477423442969a7 Mon Sep 17 00:00:00 2001 From: Antoine H Date: Fri, 18 Dec 2020 12:12:45 +0100 Subject: [PATCH] Add ClientManager --- Assets/Scripts/GameSystems.meta | 8 ++ Assets/Scripts/GameSystems/ClientManager.cs | 86 +++++++++++++++++++ .../Scripts/GameSystems/ClientManager.cs.meta | 13 +++ .../Scripts/{ => GameSystems}/GameSystem.cs | 7 +- .../{ => GameSystems}/GameSystem.cs.meta | 0 5 files changed, 109 insertions(+), 5 deletions(-) create mode 100644 Assets/Scripts/GameSystems.meta create mode 100644 Assets/Scripts/GameSystems/ClientManager.cs create mode 100644 Assets/Scripts/GameSystems/ClientManager.cs.meta rename Assets/Scripts/{ => GameSystems}/GameSystem.cs (96%) rename Assets/Scripts/{ => GameSystems}/GameSystem.cs.meta (100%) diff --git a/Assets/Scripts/GameSystems.meta b/Assets/Scripts/GameSystems.meta new file mode 100644 index 0000000..91dfe8a --- /dev/null +++ b/Assets/Scripts/GameSystems.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: f936e977ecaeacc44818a09cfebd7de1 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/GameSystems/ClientManager.cs b/Assets/Scripts/GameSystems/ClientManager.cs new file mode 100644 index 0000000..b237a8d --- /dev/null +++ b/Assets/Scripts/GameSystems/ClientManager.cs @@ -0,0 +1,86 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; +using UnityEditor; + +//Define the system managing the clients. (Singleton) +public sealed class ClientManager : MonoBehaviour +{ + int currentNbClient = 0; + int nbMaxClients = 1; + bool clientSpawnReady = false; + float clientSpawnTimer = 2.0f; //Intial time before first spawn (pseudo-random after that) + float maxTimeNewClients = 10.0f; + + string ClientRessourceFolder = "Clients"; + Vector3 spawnPosition = new Vector3(0, 0, 0); + private Object[] clients; + + //Request new client + //Return wether a new client was created + public bool clientRequest() + { + if(clientSpawnReady && currentNbClient(); + } + //// +} diff --git a/Assets/Scripts/GameSystems/ClientManager.cs.meta b/Assets/Scripts/GameSystems/ClientManager.cs.meta new file mode 100644 index 0000000..ebfa94a --- /dev/null +++ b/Assets/Scripts/GameSystems/ClientManager.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: 2bc1593400bcb054db0179d45fa332e9 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: + - clientPrefab: {fileID: 5304524770463492230, guid: 2dde00c8c5857d2438fd92435d8c3abb, + type: 3} + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/GameSystem.cs b/Assets/Scripts/GameSystems/GameSystem.cs similarity index 96% rename from Assets/Scripts/GameSystem.cs rename to Assets/Scripts/GameSystems/GameSystem.cs index a3fe004..5449da8 100644 --- a/Assets/Scripts/GameSystem.cs +++ b/Assets/Scripts/GameSystems/GameSystem.cs @@ -4,7 +4,6 @@ using UnityEngine; using System; //Exceptions //Define the global game system of the service. (Singleton) -//TODO : Split gamesystem into subsystem ? public sealed class GameSystem : MonoBehaviour { //Time @@ -14,10 +13,6 @@ public sealed class GameSystem : MonoBehaviour float slowScale = 0.5f; //Default scale for slow mode private float fixedDeltaTime; - //Clients - // int nbMaxClients = 2; - // float freqNewClients = 3.0f; - public void startService() { serviceTimer=serviceTime; @@ -75,6 +70,8 @@ public sealed class GameSystem : MonoBehaviour serviceTimer-= Time.deltaTime; if (serviceTimer < 0) serviceOpen = false; + + ClientManager.Instance.clientRequest(); } //Temporary manual slowmode toggle diff --git a/Assets/Scripts/GameSystem.cs.meta b/Assets/Scripts/GameSystems/GameSystem.cs.meta similarity index 100% rename from Assets/Scripts/GameSystem.cs.meta rename to Assets/Scripts/GameSystems/GameSystem.cs.meta