From 1360a3f978462b12ecf36278d95e35f07666f544 Mon Sep 17 00:00:00 2001 From: Antoine H Date: Tue, 12 Jan 2021 10:41:48 +0100 Subject: [PATCH] Start assignOrder --- Assets/Scenes/Tests/SampleScene.unity | 6 ++++++ Assets/Scripts/Client_controller.cs | 8 +++++--- Assets/Scripts/GameSystems/ClientManager.cs | 10 ++++++++-- 3 files changed, 19 insertions(+), 5 deletions(-) diff --git a/Assets/Scenes/Tests/SampleScene.unity b/Assets/Scenes/Tests/SampleScene.unity index 4a60df2..1e743bf 100644 --- a/Assets/Scenes/Tests/SampleScene.unity +++ b/Assets/Scenes/Tests/SampleScene.unity @@ -3899,6 +3899,12 @@ PrefabInstance: propertyPath: m_Name value: Vodka bottle objectReference: {fileID: 0} + - target: {fileID: 6538871060898918852, guid: 3baa223794d1dea4c986a5384a835c16, + type: 3} + propertyPath: m_Sprite + value: + objectReference: {fileID: 21300000, guid: 17d59b2d4d882c04480a40119a442279, + type: 3} m_RemovedComponents: [] m_SourcePrefab: {fileID: 100100000, guid: 3baa223794d1dea4c986a5384a835c16, type: 3} --- !u!1 &966209153 diff --git a/Assets/Scripts/Client_controller.cs b/Assets/Scripts/Client_controller.cs index e489b52..022e7ae 100644 --- a/Assets/Scripts/Client_controller.cs +++ b/Assets/Scripts/Client_controller.cs @@ -53,6 +53,7 @@ public class Client_controller : MonoBehaviour, IUsable } } + string order = "none"; //Order requested by the client float consumeTimer; float waitTimer; GameObject currentMug = null; //Mug currently held by the client @@ -72,7 +73,7 @@ public class Client_controller : MonoBehaviour, IUsable if(object_used != null && object_used.tag=="Grabable") { Mug mug = object_used.GetComponent(); - if (mug!= null && mug.content != null) + if (mug!= null && mug.content != null && mug.content.Type==order) { status = "consuming"; Debug.Log(gameObject.name+" "+status+" "+object_used.name+ " of "+mug.content.Type); @@ -82,13 +83,13 @@ public class Client_controller : MonoBehaviour, IUsable } else { - Debug.Log(gameObject.name+" doesn't want that "+object_used.name); + Debug.Log(gameObject.name+" doesn't want that "+object_used.name+" - Request : "+order); return false; } } else { - Debug.Log(gameObject.name+" doesn't want that "+object_used.name); + Debug.Log(gameObject.name+" doesn't want that "+object_used.name+" - Request : "+order); return false; } } @@ -137,6 +138,7 @@ public class Client_controller : MonoBehaviour, IUsable { status="waiting"; waitTimer=waitingTime; + order = ClientManager.Instance.assignOrder(); } if(status=="waiting") diff --git a/Assets/Scripts/GameSystems/ClientManager.cs b/Assets/Scripts/GameSystems/ClientManager.cs index 384df27..784b832 100644 --- a/Assets/Scripts/GameSystems/ClientManager.cs +++ b/Assets/Scripts/GameSystems/ClientManager.cs @@ -6,7 +6,7 @@ using UnityEditor; //Define the system managing the clients. (Singleton) public sealed class ClientManager : MonoBehaviour { - int nbMaxClients = 1; + int nbMaxClients = 3; bool clientSpawnReady = false; float clientSpawnTimer = 0.5f; //Intial time before first spawn (pseudo-random after that) float maxTimeNewClients = 2.0f; @@ -79,9 +79,15 @@ public sealed class ClientManager : MonoBehaviour } //Return a random order from available consummable + //TODO : Check stock before assignement + //TODO : Share available types w/ consummable + //TODO : Give sprite public string assignOrder() { - return "beer"; + List available_types = new List(new [] {"beer", "vodka"}); + + string order_type = available_types[Random.Range(0, available_types.Count)]; + return order_type; } // Start is called before the first frame update