diff --git a/Assets/Scripts/Client_controller.cs b/Assets/Scripts/Client_controller.cs index 398b4f4..e489b52 100644 --- a/Assets/Scripts/Client_controller.cs +++ b/Assets/Scripts/Client_controller.cs @@ -82,13 +82,13 @@ public class Client_controller : MonoBehaviour, IUsable } else { - Debug.Log(gameObject.name+" doesn't want that"); + Debug.Log(gameObject.name+" doesn't want that "+object_used.name); return false; } } else { - Debug.Log(gameObject.name+" doesn't want that"); + Debug.Log(gameObject.name+" doesn't want that "+object_used.name); return false; } } @@ -146,7 +146,7 @@ public class Client_controller : MonoBehaviour, IUsable { //Leave tavern status = "leaving"; - agent.SetDestination(ClientManager.Instance.assignTarget(agent.destination)); //Request next target + agent.SetDestination(ClientManager.Instance.assignTarget(agent.destination, true)); //Request next target } else if(UIWaitingTimer != null) //Update UI Waiting timer UIWaitingTimer.SetValue(waitTimer/waitingTime); @@ -173,7 +173,7 @@ public class Client_controller : MonoBehaviour, IUsable //Leave tavern status = "leaving"; - agent.SetDestination(ClientManager.Instance.assignTarget(agent.destination)); //Request next target + agent.SetDestination(ClientManager.Instance.assignTarget(agent.destination, true)); //Request next target } } diff --git a/Assets/Scripts/GameSystems/ClientManager.cs b/Assets/Scripts/GameSystems/ClientManager.cs index 92cb6ab..384df27 100644 --- a/Assets/Scripts/GameSystems/ClientManager.cs +++ b/Assets/Scripts/GameSystems/ClientManager.cs @@ -55,22 +55,33 @@ public sealed class ClientManager : MonoBehaviour } - //Assign a random available target. - public Vector2 assignTarget(Vector2? prevTarget=null) + //Return a random available target. Or the Exit if Exit=True. + //prevTarget : Previous target of the client which will be available for other clients. + public Vector2 assignTarget(Vector2? prevTarget=null, bool exit=false) { if(prevTarget != null) { targets_dict[(Vector2)prevTarget]=false; //Free prevTarget - return spawnPoint; } - List avail_tgt = new List(); - foreach(KeyValuePair tgt in targets_dict) - if(tgt.Value is false) - avail_tgt.Add(tgt.Key); - - Vector2 target = avail_tgt[Random.Range(0, avail_tgt.Count)]; - targets_dict[target]=true; - return target; + if(exit) //Assign Exit target + return spawnPoint; + else + { + List avail_tgt = new List(); + foreach(KeyValuePair tgt in targets_dict) + if(tgt.Value is false) + avail_tgt.Add(tgt.Key); + + Vector2 target = avail_tgt[Random.Range(0, avail_tgt.Count)]; + targets_dict[target]=true; + return target; + } + } + + //Return a random order from available consummable + public string assignOrder() + { + return "beer"; } // Start is called before the first frame update