Functionnal navigation / service
This commit is contained in:
parent
7a7fcb6ac1
commit
81dfbfaa57
5 changed files with 170 additions and 155 deletions
|
@ -145,7 +145,7 @@ MonoBehaviour:
|
|||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
consumeTime: 3
|
||||
waitingTime: 10
|
||||
waitingTime: 1
|
||||
--- !u!195 &8842024822361446808
|
||||
NavMeshAgent:
|
||||
m_ObjectHideFlags: 0
|
||||
|
|
|
@ -124,80 +124,49 @@ NavMeshSettings:
|
|||
debug:
|
||||
m_Flags: 0
|
||||
m_NavMeshData: {fileID: 0}
|
||||
--- !u!1001 &47257443
|
||||
PrefabInstance:
|
||||
--- !u!1 &128722682
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
serializedVersion: 2
|
||||
m_Modification:
|
||||
m_TransformParent: {fileID: 0}
|
||||
m_Modifications:
|
||||
- target: {fileID: 5304524770463492230, guid: 2dde00c8c5857d2438fd92435d8c3abb,
|
||||
type: 3}
|
||||
propertyPath: m_Name
|
||||
value: Oldman
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 5304524770463492230, guid: 2dde00c8c5857d2438fd92435d8c3abb,
|
||||
type: 3}
|
||||
propertyPath: m_IsActive
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 5304524770463492235, guid: 2dde00c8c5857d2438fd92435d8c3abb,
|
||||
type: 3}
|
||||
propertyPath: m_RootOrder
|
||||
value: 1
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 5304524770463492235, guid: 2dde00c8c5857d2438fd92435d8c3abb,
|
||||
type: 3}
|
||||
propertyPath: m_LocalPosition.x
|
||||
value: 2.64
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 5304524770463492235, guid: 2dde00c8c5857d2438fd92435d8c3abb,
|
||||
type: 3}
|
||||
propertyPath: m_LocalPosition.y
|
||||
value: 0.39
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 5304524770463492235, guid: 2dde00c8c5857d2438fd92435d8c3abb,
|
||||
type: 3}
|
||||
propertyPath: m_LocalPosition.z
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 5304524770463492235, guid: 2dde00c8c5857d2438fd92435d8c3abb,
|
||||
type: 3}
|
||||
propertyPath: m_LocalRotation.w
|
||||
value: 1
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 5304524770463492235, guid: 2dde00c8c5857d2438fd92435d8c3abb,
|
||||
type: 3}
|
||||
propertyPath: m_LocalRotation.x
|
||||
value: -0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 5304524770463492235, guid: 2dde00c8c5857d2438fd92435d8c3abb,
|
||||
type: 3}
|
||||
propertyPath: m_LocalRotation.y
|
||||
value: -0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 5304524770463492235, guid: 2dde00c8c5857d2438fd92435d8c3abb,
|
||||
type: 3}
|
||||
propertyPath: m_LocalRotation.z
|
||||
value: -0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 5304524770463492235, guid: 2dde00c8c5857d2438fd92435d8c3abb,
|
||||
type: 3}
|
||||
propertyPath: m_LocalEulerAnglesHint.x
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 5304524770463492235, guid: 2dde00c8c5857d2438fd92435d8c3abb,
|
||||
type: 3}
|
||||
propertyPath: m_LocalEulerAnglesHint.y
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 5304524770463492235, guid: 2dde00c8c5857d2438fd92435d8c3abb,
|
||||
type: 3}
|
||||
propertyPath: m_LocalEulerAnglesHint.z
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
m_RemovedComponents: []
|
||||
m_SourcePrefab: {fileID: 100100000, guid: 2dde00c8c5857d2438fd92435d8c3abb, type: 3}
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
serializedVersion: 6
|
||||
m_Component:
|
||||
- component: {fileID: 128722683}
|
||||
- component: {fileID: 128722684}
|
||||
m_Layer: 0
|
||||
m_Name: ClientManager
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
--- !u!4 &128722683
|
||||
Transform:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 128722682}
|
||||
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: 1160225022}
|
||||
m_RootOrder: 1
|
||||
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:
|
||||
--- !u!1 &268005788
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
|
@ -2972,12 +2941,12 @@ Transform:
|
|||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 322056902}
|
||||
m_LocalRotation: {x: -0.7071068, y: 0, z: 0, w: 0.7071068}
|
||||
m_LocalPosition: {x: 6.17, y: -0.66, z: -2.4934947}
|
||||
m_LocalRotation: {x: -0.7071068, y: -0, z: 0, w: 0.7071068}
|
||||
m_LocalPosition: {x: 6.383482, y: -4.752509, z: -0.3424089}
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_Children: []
|
||||
m_Father: {fileID: 0}
|
||||
m_RootOrder: 9
|
||||
m_Father: {fileID: 1160225022}
|
||||
m_RootOrder: 0
|
||||
m_LocalEulerAnglesHint: {x: -90, y: 0, z: 0}
|
||||
--- !u!1 &519420028
|
||||
GameObject:
|
||||
|
@ -3060,7 +3029,7 @@ Transform:
|
|||
m_LocalScale: {x: 0.5, y: 0.5, z: 1}
|
||||
m_Children: []
|
||||
m_Father: {fileID: 0}
|
||||
m_RootOrder: 3
|
||||
m_RootOrder: 1
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
--- !u!1 &698542424
|
||||
GameObject:
|
||||
|
@ -3170,7 +3139,7 @@ Transform:
|
|||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_Children: []
|
||||
m_Father: {fileID: 0}
|
||||
m_RootOrder: 4
|
||||
m_RootOrder: 3
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
--- !u!1 &706948613
|
||||
GameObject:
|
||||
|
@ -3293,7 +3262,67 @@ Transform:
|
|||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_Children: []
|
||||
m_Father: {fileID: 0}
|
||||
m_RootOrder: 6
|
||||
m_RootOrder: 5
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
--- !u!1 &827096820
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
serializedVersion: 6
|
||||
m_Component:
|
||||
- component: {fileID: 827096821}
|
||||
m_Layer: 0
|
||||
m_Name: Chair 3
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 6519382022992737161, guid: 0000000000000000d000000000000000, type: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
--- !u!4 &827096821
|
||||
Transform:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 827096820}
|
||||
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
|
||||
m_LocalPosition: {x: -5.6, y: -2.07, z: 2.5482712}
|
||||
m_LocalScale: {x: 0.099999994, y: 0.099999994, z: 0.099999994}
|
||||
m_Children: []
|
||||
m_Father: {fileID: 1863361785}
|
||||
m_RootOrder: 2
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
--- !u!1 &863760954
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
serializedVersion: 6
|
||||
m_Component:
|
||||
- component: {fileID: 863760955}
|
||||
m_Layer: 0
|
||||
m_Name: Chair 2
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 6519382022992737161, guid: 0000000000000000d000000000000000, type: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
--- !u!4 &863760955
|
||||
Transform:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 863760954}
|
||||
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
|
||||
m_LocalPosition: {x: -2.89, y: -0.784, z: 2.5482712}
|
||||
m_LocalScale: {x: 0.099999994, y: 0.099999994, z: 0.099999994}
|
||||
m_Children: []
|
||||
m_Father: {fileID: 1863361785}
|
||||
m_RootOrder: 1
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
--- !u!1 &966209153
|
||||
GameObject:
|
||||
|
@ -3340,7 +3369,7 @@ Transform:
|
|||
- {fileID: 268005789}
|
||||
- {fileID: 2115704629}
|
||||
m_Father: {fileID: 0}
|
||||
m_RootOrder: 8
|
||||
m_RootOrder: 7
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
--- !u!1 &1145481934
|
||||
GameObject:
|
||||
|
@ -7029,6 +7058,8 @@ Transform:
|
|||
m_LocalPosition: {x: -0.21348187, y: 4.0925093, z: -2.1510859}
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_Children:
|
||||
- {fileID: 322056904}
|
||||
- {fileID: 128722683}
|
||||
- {fileID: 1863361785}
|
||||
- {fileID: 1486551544}
|
||||
m_Father: {fileID: 0}
|
||||
|
@ -7129,7 +7160,7 @@ Transform:
|
|||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_Children: []
|
||||
m_Father: {fileID: 0}
|
||||
m_RootOrder: 5
|
||||
m_RootOrder: 4
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
--- !u!61 &1163880825
|
||||
BoxCollider2D:
|
||||
|
@ -7283,7 +7314,7 @@ Transform:
|
|||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_Children: []
|
||||
m_Father: {fileID: 0}
|
||||
m_RootOrder: 7
|
||||
m_RootOrder: 6
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
--- !u!1 &1486551543
|
||||
GameObject:
|
||||
|
@ -7313,7 +7344,7 @@ Transform:
|
|||
m_LocalScale: {x: 0.1, y: 0.1, z: 0.1}
|
||||
m_Children: []
|
||||
m_Father: {fileID: 1160225022}
|
||||
m_RootOrder: 1
|
||||
m_RootOrder: 3
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
--- !u!1 &1520733216
|
||||
GameObject:
|
||||
|
@ -32093,7 +32124,6 @@ GameObject:
|
|||
serializedVersion: 6
|
||||
m_Component:
|
||||
- component: {fileID: 1678986453}
|
||||
- component: {fileID: 1678986452}
|
||||
m_Layer: 0
|
||||
m_Name: Chair 1
|
||||
m_TagString: Untagged
|
||||
|
@ -32101,58 +32131,6 @@ GameObject:
|
|||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
--- !u!212 &1678986452
|
||||
SpriteRenderer:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1678986451}
|
||||
m_Enabled: 0
|
||||
m_CastShadows: 0
|
||||
m_ReceiveShadows: 0
|
||||
m_DynamicOccludee: 1
|
||||
m_MotionVectors: 1
|
||||
m_LightProbeUsage: 1
|
||||
m_ReflectionProbeUsage: 1
|
||||
m_RayTracingMode: 0
|
||||
m_RayTraceProcedural: 0
|
||||
m_RenderingLayerMask: 1
|
||||
m_RendererPriority: 0
|
||||
m_Materials:
|
||||
- {fileID: 10754, guid: 0000000000000000f000000000000000, type: 0}
|
||||
m_StaticBatchInfo:
|
||||
firstSubMesh: 0
|
||||
subMeshCount: 0
|
||||
m_StaticBatchRoot: {fileID: 0}
|
||||
m_ProbeAnchor: {fileID: 0}
|
||||
m_LightProbeVolumeOverride: {fileID: 0}
|
||||
m_ScaleInLightmap: 1
|
||||
m_ReceiveGI: 1
|
||||
m_PreserveUVs: 0
|
||||
m_IgnoreNormalsForChartDetection: 0
|
||||
m_ImportantGI: 0
|
||||
m_StitchLightmapSeams: 1
|
||||
m_SelectedEditorRenderState: 0
|
||||
m_MinimumChartSize: 4
|
||||
m_AutoUVMaxDistance: 0.5
|
||||
m_AutoUVMaxAngle: 89
|
||||
m_LightmapParameters: {fileID: 0}
|
||||
m_SortingLayerID: 0
|
||||
m_SortingLayer: 0
|
||||
m_SortingOrder: 0
|
||||
m_Sprite: {fileID: -1209127185579228243, guid: bfabe3920bf35724b9a95bf95f5431a9,
|
||||
type: 3}
|
||||
m_Color: {r: 1, g: 1, b: 1, a: 1}
|
||||
m_FlipX: 0
|
||||
m_FlipY: 0
|
||||
m_DrawMode: 0
|
||||
m_Size: {x: 0.175, y: 0.2}
|
||||
m_AdaptiveModeThreshold: 0.5
|
||||
m_SpriteTileMode: 0
|
||||
m_WasSpriteAssigned: 1
|
||||
m_MaskInteraction: 0
|
||||
m_SpriteSortPoint: 0
|
||||
--- !u!4 &1678986453
|
||||
Transform:
|
||||
m_ObjectHideFlags: 0
|
||||
|
@ -32195,8 +32173,10 @@ Transform:
|
|||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_Children:
|
||||
- {fileID: 1678986453}
|
||||
- {fileID: 863760955}
|
||||
- {fileID: 827096821}
|
||||
m_Father: {fileID: 1160225022}
|
||||
m_RootOrder: 0
|
||||
m_RootOrder: 2
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
--- !u!1 &2115704628
|
||||
GameObject:
|
||||
|
|
|
@ -9,7 +9,7 @@ using UnityEngine.AI;
|
|||
public class Client_controller : MonoBehaviour, IUsable
|
||||
{
|
||||
public float consumeTime = 3.0f; //Time to consume currentMug
|
||||
public float waitingTime = 10.0f; //Patience after ordering
|
||||
public float waitingTime = 10.0f; //Patience after reaching seat
|
||||
|
||||
string _status;
|
||||
HashSet<string> _availStatus = new HashSet<string>(){"entering", "waiting", "consuming", "leaving"};
|
||||
|
@ -85,6 +85,8 @@ public class Client_controller : MonoBehaviour, IUsable
|
|||
agent.updateUpAxis = false;
|
||||
//Get target
|
||||
agent.destination = ClientManager.Instance.assignTarget();
|
||||
//Assign Random priority to prevent two agent blocking each other
|
||||
agent.avoidancePriority=Random.Range(0, 99);
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
|
@ -93,8 +95,7 @@ public class Client_controller : MonoBehaviour, IUsable
|
|||
//Navigation
|
||||
// Debug.Log(gameObject.name + " navigation : "+ agent.isStopped + " " + agent.remainingDistance);
|
||||
|
||||
//Reached seat
|
||||
if(status=="entering" && agent.remainingDistance==0)
|
||||
if(status=="entering" && !agent.pathPending && agent.remainingDistance==0) //Reached seat ?
|
||||
{
|
||||
status="waiting";
|
||||
waitTimer=waitingTime;
|
||||
|
@ -112,7 +113,8 @@ public class Client_controller : MonoBehaviour, IUsable
|
|||
}
|
||||
|
||||
//Consume Timer
|
||||
if (status=="consuming" && agent.remainingDistance==0) //Consuming mug if there's one and reached destination
|
||||
//TODO : Make Client Obstacle when consumming
|
||||
if(status=="consuming" && !agent.pathPending && agent.remainingDistance==0) //Consuming mug if there's one and reached destination
|
||||
{
|
||||
consumeTimer -= Time.deltaTime;
|
||||
if (consumeTimer < 0) //Finished consuming mug ?
|
||||
|
@ -131,5 +133,10 @@ public class Client_controller : MonoBehaviour, IUsable
|
|||
agent.destination = ClientManager.Instance.assignTarget(agent.destination); //Request next target
|
||||
}
|
||||
}
|
||||
|
||||
if(status=="leaving" && !agent.pathPending && agent.remainingDistance==0)
|
||||
{
|
||||
ClientManager.Instance.clientLeave(gameObject);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,14 +6,15 @@ using UnityEditor;
|
|||
//Define the system managing the clients. (Singleton)
|
||||
public sealed class ClientManager : MonoBehaviour
|
||||
{
|
||||
int currentNbClient = 0;
|
||||
int nbMaxClients = 1;
|
||||
int nbMaxClients = 3;
|
||||
bool clientSpawnReady = false;
|
||||
float clientSpawnTimer = 0.5f; //Intial time before first spawn (pseudo-random after that)
|
||||
float maxTimeNewClients = 10.0f;
|
||||
|
||||
string ClientRessourceFolder = "Clients";
|
||||
private Object[] clients;
|
||||
GameObject ClientContainer = null;
|
||||
List<int> clientIDs = new List<int>();
|
||||
|
||||
Vector2 spawnPoint;
|
||||
Dictionary<Vector2, bool> targets_dict; //Dict with target and wether they're taken by a client
|
||||
|
@ -22,20 +23,32 @@ public sealed class ClientManager : MonoBehaviour
|
|||
//Return wether a new client was created
|
||||
public bool clientRequest()
|
||||
{
|
||||
if(clientSpawnReady && currentNbClient<nbMaxClients && targets_dict.ContainsValue(false))
|
||||
if(clientSpawnReady && clientIDs.Count<nbMaxClients && targets_dict.ContainsValue(false))
|
||||
{
|
||||
GameObject newClient = (GameObject)clients[Random.Range(0, clients.Length)];
|
||||
// Debug.Log("Spawning "+clientPrefab.name+" at "+spawnPosition);
|
||||
Instantiate(newClient, spawnPoint, Quaternion.identity);
|
||||
currentNbClient+=1;
|
||||
int prefabChoice = Random.Range(0, clients.Length);
|
||||
GameObject newClient = Instantiate((GameObject)clients[prefabChoice], spawnPoint, Quaternion.identity, ClientContainer.transform); //Instantiate new client inside ClientManager
|
||||
clientIDs.Add(newClient.GetInstanceID()); //Save ID
|
||||
// Debug.Log(newClient.GetInstanceID());
|
||||
newClient.name = newClient.name.Split('(')[0]+clientIDs[clientIDs.Count-1]; //Rename new client
|
||||
|
||||
clientSpawnTimer=Random.Range(1.0f, maxTimeNewClients); //Need more random ?
|
||||
clientSpawnReady=false;
|
||||
|
||||
// Debug.Log("Spawning "+clientPrefab.name+" at "+spawnPosition);
|
||||
return true; //New client instantiated
|
||||
}
|
||||
return false; //No new client
|
||||
}
|
||||
|
||||
//Destroy a client
|
||||
public void clientLeave(GameObject client)
|
||||
{
|
||||
clientIDs.Remove(-int.Parse(client.name.Split('-')[1]));
|
||||
Destroy(client);
|
||||
// Debug.Log(client.name+" destroyed"+clientIDs.Count);
|
||||
|
||||
}
|
||||
|
||||
//Assign a random available target.
|
||||
public Vector2 assignTarget(Vector2? prevTarget=null)
|
||||
{
|
||||
|
@ -57,6 +70,10 @@ public sealed class ClientManager : MonoBehaviour
|
|||
// Start is called before the first frame update
|
||||
void Start()
|
||||
{
|
||||
ClientContainer = GameObject.Find("/GameSystem/ClientManager");
|
||||
if (ClientContainer is null)
|
||||
throw new System.Exception("No ClientManager found under GameSystem");
|
||||
|
||||
// Load clients prefabs //
|
||||
|
||||
// Find all assets labelled with 'usable' :
|
||||
|
@ -70,9 +87,13 @@ public sealed class ClientManager : MonoBehaviour
|
|||
|
||||
clients = Resources.LoadAll(ClientRessourceFolder);
|
||||
|
||||
foreach (var c in clients)
|
||||
// foreach (var c in clients)
|
||||
// {
|
||||
// Debug.Log(gameObject.name+" : "+c.name + " loaded");
|
||||
// }
|
||||
if (clients.Length<nbMaxClients)
|
||||
{
|
||||
Debug.Log(gameObject.name+" : "+c.name + " loaded");
|
||||
Debug.LogWarning("ClientManager doesn't have enough client prefab to manage unique MaxClients : "+clients.Length+"/"+nbMaxClients);
|
||||
}
|
||||
|
||||
// Load Client spawn point //
|
||||
|
@ -95,10 +116,14 @@ public sealed class ClientManager : MonoBehaviour
|
|||
if(target.gameObject.name != "Targets")
|
||||
{
|
||||
targets_dict.Add(target.position, false);
|
||||
Debug.Log("Client target : "+ target.gameObject.name + target.position);
|
||||
// Debug.Log("Client target : "+ target.gameObject.name + target.position);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (targets_dict.Count<nbMaxClients)
|
||||
{
|
||||
Debug.LogWarning("ClientManager doesn't have enough target to manage MaxClients : "+targets_dict.Count+"/"+nbMaxClients);
|
||||
}
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
|
@ -110,6 +135,7 @@ public sealed class ClientManager : MonoBehaviour
|
|||
if(clientSpawnTimer<=0)
|
||||
clientSpawnReady=true;
|
||||
}
|
||||
// Debug.Log("Client Spawn : "+clientSpawnTimer+" / Seat available: "+targets_dict.ContainsValue(false));
|
||||
}
|
||||
|
||||
//// Singleton Implementation (https://jlambert.developpez.com/tutoriels/dotnet/implementation-pattern-singleton-csharp/#LIII) ////
|
||||
|
|
|
@ -8,7 +8,7 @@ public sealed class GameSystem : MonoBehaviour
|
|||
{
|
||||
//Time
|
||||
bool serviceOpen = false;
|
||||
float serviceTime = 10.0f;
|
||||
float serviceTime = 30.0f;
|
||||
float serviceTimer = 0.0f;
|
||||
float slowScale = 0.5f; //Default scale for slow mode
|
||||
private float fixedDeltaTime;
|
||||
|
@ -69,8 +69,10 @@ public sealed class GameSystem : MonoBehaviour
|
|||
{
|
||||
serviceTimer-= Time.deltaTime;
|
||||
if (serviceTimer < 0)
|
||||
{
|
||||
serviceOpen = false;
|
||||
|
||||
Debug.Log("Service closed");
|
||||
}
|
||||
ClientManager.Instance.clientRequest();
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue