Add more interface w/ Unity Inspector and Managers
This commit is contained in:
parent
4f99687ae2
commit
901a2b6c10
4 changed files with 168 additions and 69 deletions
|
@ -297,6 +297,7 @@ GameObject:
|
||||||
serializedVersion: 6
|
serializedVersion: 6
|
||||||
m_Component:
|
m_Component:
|
||||||
- component: {fileID: 128722683}
|
- component: {fileID: 128722683}
|
||||||
|
- component: {fileID: 128722684}
|
||||||
m_Layer: 0
|
m_Layer: 0
|
||||||
m_Name: ClientManager
|
m_Name: ClientManager
|
||||||
m_TagString: Untagged
|
m_TagString: Untagged
|
||||||
|
@ -318,6 +319,22 @@ Transform:
|
||||||
m_Father: {fileID: 1160225022}
|
m_Father: {fileID: 1160225022}
|
||||||
m_RootOrder: 1
|
m_RootOrder: 1
|
||||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||||
|
--- !u!114 &128722684
|
||||||
|
MonoBehaviour:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 128722682}
|
||||||
|
m_Enabled: 1
|
||||||
|
m_EditorHideFlags: 0
|
||||||
|
m_Script: {fileID: 11500000, guid: 2bc1593400bcb054db0179d45fa332e9, type: 3}
|
||||||
|
m_Name:
|
||||||
|
m_EditorClassIdentifier:
|
||||||
|
ready: 0
|
||||||
|
nbMaxClients: 5
|
||||||
|
clientSpawnTimer: 0.5
|
||||||
|
maxTimeNewClients: 2
|
||||||
--- !u!1 &156172339
|
--- !u!1 &156172339
|
||||||
GameObject:
|
GameObject:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
|
@ -3124,7 +3141,7 @@ Transform:
|
||||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||||
m_Children: []
|
m_Children: []
|
||||||
m_Father: {fileID: 1160225022}
|
m_Father: {fileID: 1160225022}
|
||||||
m_RootOrder: 0
|
m_RootOrder: 2
|
||||||
m_LocalEulerAnglesHint: {x: -90, y: 0, z: 0}
|
m_LocalEulerAnglesHint: {x: -90, y: 0, z: 0}
|
||||||
--- !u!1 &357681231
|
--- !u!1 &357681231
|
||||||
GameObject:
|
GameObject:
|
||||||
|
@ -3574,6 +3591,50 @@ Transform:
|
||||||
m_Father: {fileID: 0}
|
m_Father: {fileID: 0}
|
||||||
m_RootOrder: 6
|
m_RootOrder: 6
|
||||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||||
|
--- !u!1 &722742920
|
||||||
|
GameObject:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
serializedVersion: 6
|
||||||
|
m_Component:
|
||||||
|
- component: {fileID: 722742921}
|
||||||
|
- component: {fileID: 722742922}
|
||||||
|
m_Layer: 0
|
||||||
|
m_Name: StockManager
|
||||||
|
m_TagString: Untagged
|
||||||
|
m_Icon: {fileID: 0}
|
||||||
|
m_NavMeshLayer: 0
|
||||||
|
m_StaticEditorFlags: 0
|
||||||
|
m_IsActive: 1
|
||||||
|
--- !u!4 &722742921
|
||||||
|
Transform:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 722742920}
|
||||||
|
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
|
||||||
|
m_LocalPosition: {x: 0.8086959, y: -2.008171, z: 1.1246597}
|
||||||
|
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||||
|
m_Children: []
|
||||||
|
m_Father: {fileID: 1160225022}
|
||||||
|
m_RootOrder: 0
|
||||||
|
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||||
|
--- !u!114 &722742922
|
||||||
|
MonoBehaviour:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 722742920}
|
||||||
|
m_Enabled: 1
|
||||||
|
m_EditorHideFlags: 0
|
||||||
|
m_Script: {fileID: 11500000, guid: f33c46360b013aa48a333f4be9bb3c09, type: 3}
|
||||||
|
m_Name:
|
||||||
|
m_EditorClassIdentifier:
|
||||||
|
ready: 0
|
||||||
--- !u!1001 &728581040
|
--- !u!1001 &728581040
|
||||||
PrefabInstance:
|
PrefabInstance:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
|
@ -7717,6 +7778,9 @@ MonoBehaviour:
|
||||||
m_Script: {fileID: 11500000, guid: 5f18e7df2f912f644a6a6949b25117b6, type: 3}
|
m_Script: {fileID: 11500000, guid: 5f18e7df2f912f644a6a6949b25117b6, type: 3}
|
||||||
m_Name:
|
m_Name:
|
||||||
m_EditorClassIdentifier:
|
m_EditorClassIdentifier:
|
||||||
|
ready: 0
|
||||||
|
serviceTime: 60
|
||||||
|
slowScale: 0.5
|
||||||
--- !u!4 &1160225022
|
--- !u!4 &1160225022
|
||||||
Transform:
|
Transform:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
|
@ -7728,8 +7792,9 @@ Transform:
|
||||||
m_LocalPosition: {x: -0.21348187, y: 4.0925093, z: -2.1510859}
|
m_LocalPosition: {x: -0.21348187, y: 4.0925093, z: -2.1510859}
|
||||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||||
m_Children:
|
m_Children:
|
||||||
- {fileID: 322056904}
|
- {fileID: 722742921}
|
||||||
- {fileID: 128722683}
|
- {fileID: 128722683}
|
||||||
|
- {fileID: 322056904}
|
||||||
- {fileID: 1863361785}
|
- {fileID: 1863361785}
|
||||||
- {fileID: 1486551544}
|
- {fileID: 1486551544}
|
||||||
m_Father: {fileID: 0}
|
m_Father: {fileID: 0}
|
||||||
|
@ -7976,7 +8041,7 @@ Transform:
|
||||||
m_LocalScale: {x: 0.1, y: 0.1, z: 0.1}
|
m_LocalScale: {x: 0.1, y: 0.1, z: 0.1}
|
||||||
m_Children: []
|
m_Children: []
|
||||||
m_Father: {fileID: 1160225022}
|
m_Father: {fileID: 1160225022}
|
||||||
m_RootOrder: 3
|
m_RootOrder: 4
|
||||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||||
--- !u!1 &1520733216
|
--- !u!1 &1520733216
|
||||||
GameObject:
|
GameObject:
|
||||||
|
@ -32996,7 +33061,7 @@ Transform:
|
||||||
- {fileID: 238532360}
|
- {fileID: 238532360}
|
||||||
- {fileID: 1653625651}
|
- {fileID: 1653625651}
|
||||||
m_Father: {fileID: 1160225022}
|
m_Father: {fileID: 1160225022}
|
||||||
m_RootOrder: 2
|
m_RootOrder: 3
|
||||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||||
--- !u!1 &1905354803
|
--- !u!1 &1905354803
|
||||||
GameObject:
|
GameObject:
|
||||||
|
|
|
@ -6,10 +6,13 @@ using UnityEditor;
|
||||||
//Define the system managing the clients. (Singleton)
|
//Define the system managing the clients. (Singleton)
|
||||||
public sealed class ClientManager : MonoBehaviour
|
public sealed class ClientManager : MonoBehaviour
|
||||||
{
|
{
|
||||||
int nbMaxClients = 3;
|
[HideInInspector]
|
||||||
|
public bool ready = false; //Wether the ClientManager is initialized
|
||||||
|
|
||||||
|
public int nbMaxClients = 3;
|
||||||
bool clientSpawnReady = false;
|
bool clientSpawnReady = false;
|
||||||
float clientSpawnTimer = 0.5f; //Intial time before first spawn (pseudo-random after that)
|
public float clientSpawnTimer = 0.5f; //Intial time before first spawn (pseudo-random after that)
|
||||||
float maxTimeNewClients = 2.0f;
|
public float maxTimeNewClients = 2.0f; //Longest waiting time for new clients
|
||||||
|
|
||||||
string ClientRessourceFolder = "Clients";
|
string ClientRessourceFolder = "Clients";
|
||||||
private Object[] clients;
|
private Object[] clients;
|
||||||
|
@ -53,6 +56,12 @@ public sealed class ClientManager : MonoBehaviour
|
||||||
Destroy(client);
|
Destroy(client);
|
||||||
// Debug.Log(client.name+" destroyed"+clientIDs.Count);
|
// Debug.Log(client.name+" destroyed"+clientIDs.Count);
|
||||||
|
|
||||||
|
//Prevent immediate spawn of a new client after one leaving
|
||||||
|
if(clientSpawnReady)
|
||||||
|
{
|
||||||
|
clientSpawnReady=false;
|
||||||
|
clientSpawnTimer+=0.5f;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//Return a random available target. Or the Exit if Exit=True.
|
//Return a random available target. Or the Exit if Exit=True.
|
||||||
|
@ -90,6 +99,8 @@ public sealed class ClientManager : MonoBehaviour
|
||||||
|
|
||||||
//Awake is called when the script instance is being loaded.
|
//Awake is called when the script instance is being loaded.
|
||||||
void Awake()
|
void Awake()
|
||||||
|
{
|
||||||
|
if(!ready)
|
||||||
{
|
{
|
||||||
ClientContainer = GameObject.Find("/GameSystem/ClientManager");
|
ClientContainer = GameObject.Find("/GameSystem/ClientManager");
|
||||||
if (ClientContainer is null)
|
if (ClientContainer is null)
|
||||||
|
@ -145,6 +156,9 @@ public sealed class ClientManager : MonoBehaviour
|
||||||
{
|
{
|
||||||
Debug.LogWarning("ClientManager doesn't have enough target to manage MaxClients : "+targets_dict.Count+"/"+nbMaxClients);
|
Debug.LogWarning("ClientManager doesn't have enough target to manage MaxClients : "+targets_dict.Count+"/"+nbMaxClients);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ready = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update is called once per frame
|
// Update is called once per frame
|
||||||
|
|
|
@ -5,12 +5,15 @@ using UnityEngine;
|
||||||
//Define the global game system of the service. (Singleton)
|
//Define the global game system of the service. (Singleton)
|
||||||
public sealed class GameSystem : MonoBehaviour
|
public sealed class GameSystem : MonoBehaviour
|
||||||
{
|
{
|
||||||
|
[HideInInspector]
|
||||||
|
public bool ready = false; //Wether the GameSystems are initialized
|
||||||
|
|
||||||
//Time
|
//Time
|
||||||
bool serviceOpen = false;
|
bool serviceOpen = false;
|
||||||
float serviceTime = 30.0f;
|
public float serviceTime = 30.0f;
|
||||||
float serviceTimer = 0.0f;
|
float serviceTimer = 0.0f;
|
||||||
UITimer UIServiceTimer;
|
UITimer UIServiceTimer;
|
||||||
float slowScale = 0.5f; //Default scale for slow mode
|
public float slowScale = 0.5f; //Default scale for slow mode
|
||||||
private float fixedDeltaTime;
|
private float fixedDeltaTime;
|
||||||
|
|
||||||
//TODO : Effect on gold change
|
//TODO : Effect on gold change
|
||||||
|
@ -63,6 +66,8 @@ public sealed class GameSystem : MonoBehaviour
|
||||||
|
|
||||||
//Awake is called when the script instance is being loaded.
|
//Awake is called when the script instance is being loaded.
|
||||||
void Awake()
|
void Awake()
|
||||||
|
{
|
||||||
|
if(!ready)
|
||||||
{
|
{
|
||||||
// Make a copy of the fixedDeltaTime, it defaults to 0.02f, but it can be changed in the editor
|
// Make a copy of the fixedDeltaTime, it defaults to 0.02f, but it can be changed in the editor
|
||||||
this.fixedDeltaTime = Time.fixedDeltaTime;
|
this.fixedDeltaTime = Time.fixedDeltaTime;
|
||||||
|
@ -76,6 +81,13 @@ public sealed class GameSystem : MonoBehaviour
|
||||||
{
|
{
|
||||||
UIServiceTimer=timerObj.GetComponent<UITimer>();
|
UIServiceTimer=timerObj.GetComponent<UITimer>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(ClientManager.Instance.ready && StockManager.Instance.ready)
|
||||||
|
{
|
||||||
|
ready=true;
|
||||||
|
Debug.Log("All GameSystems are ready");
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Start is called before the first frame update
|
// Start is called before the first frame update
|
||||||
|
|
|
@ -6,6 +6,9 @@ using UnityEngine;
|
||||||
//TODO : Update check stock of registered workshops
|
//TODO : Update check stock of registered workshops
|
||||||
public class StockManager : MonoBehaviour
|
public class StockManager : MonoBehaviour
|
||||||
{
|
{
|
||||||
|
[HideInInspector]
|
||||||
|
public bool ready = false; //Wether the StockManager is initialized
|
||||||
|
|
||||||
//Consumable
|
//Consumable
|
||||||
Dictionary<string, Sprite> consumableSprites = new Dictionary<string, Sprite>(); //Sprite associated w/ types of consumable
|
Dictionary<string, Sprite> consumableSprites = new Dictionary<string, Sprite>(); //Sprite associated w/ types of consumable
|
||||||
HashSet<string> avail_consumable = new HashSet<string>(); //Available consumable
|
HashSet<string> avail_consumable = new HashSet<string>(); //Available consumable
|
||||||
|
@ -32,7 +35,7 @@ public class StockManager : MonoBehaviour
|
||||||
consumableSprites[prod_name]=prod_sprite;
|
consumableSprites[prod_name]=prod_sprite;
|
||||||
updateStock(prod_name, stock);
|
updateStock(prod_name, stock);
|
||||||
workshop_register.Add(workshop);
|
workshop_register.Add(workshop);
|
||||||
Debug.Log(workshop.gameObject.name+" registered by StockManager");
|
// Debug.Log(workshop.gameObject.name+" registered by StockManager");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -70,6 +73,8 @@ public class StockManager : MonoBehaviour
|
||||||
|
|
||||||
//Awake is called when the script instance is being loaded.
|
//Awake is called when the script instance is being loaded.
|
||||||
void Awake()
|
void Awake()
|
||||||
|
{
|
||||||
|
if(!ready)
|
||||||
{
|
{
|
||||||
//Initialize global stock
|
//Initialize global stock
|
||||||
global_stock= new Dictionary<string, int>();
|
global_stock= new Dictionary<string, int>();
|
||||||
|
@ -77,6 +82,9 @@ public class StockManager : MonoBehaviour
|
||||||
{
|
{
|
||||||
global_stock[cons]=0;
|
global_stock[cons]=0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ready = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update is called once per frame
|
// Update is called once per frame
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue