Update to assignTarget
This commit is contained in:
parent
2dbb5e4dfe
commit
1696694db5
2 changed files with 26 additions and 15 deletions
|
@ -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
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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<Vector2> avail_tgt = new List<Vector2>();
|
||||
foreach(KeyValuePair<Vector2, bool> 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<Vector2> avail_tgt = new List<Vector2>();
|
||||
foreach(KeyValuePair<Vector2, bool> 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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue