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
|
else
|
||||||
{
|
{
|
||||||
Debug.Log(gameObject.name+" doesn't want that");
|
Debug.Log(gameObject.name+" doesn't want that "+object_used.name);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Debug.Log(gameObject.name+" doesn't want that");
|
Debug.Log(gameObject.name+" doesn't want that "+object_used.name);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -146,7 +146,7 @@ public class Client_controller : MonoBehaviour, IUsable
|
||||||
{
|
{
|
||||||
//Leave tavern
|
//Leave tavern
|
||||||
status = "leaving";
|
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
|
else if(UIWaitingTimer != null) //Update UI Waiting timer
|
||||||
UIWaitingTimer.SetValue(waitTimer/waitingTime);
|
UIWaitingTimer.SetValue(waitTimer/waitingTime);
|
||||||
|
@ -173,7 +173,7 @@ public class Client_controller : MonoBehaviour, IUsable
|
||||||
|
|
||||||
//Leave tavern
|
//Leave tavern
|
||||||
status = "leaving";
|
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.
|
//Return a random available target. Or the Exit if Exit=True.
|
||||||
public Vector2 assignTarget(Vector2? prevTarget=null)
|
//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)
|
if(prevTarget != null)
|
||||||
{
|
{
|
||||||
targets_dict[(Vector2)prevTarget]=false; //Free prevTarget
|
targets_dict[(Vector2)prevTarget]=false; //Free prevTarget
|
||||||
return spawnPoint;
|
|
||||||
}
|
}
|
||||||
List<Vector2> avail_tgt = new List<Vector2>();
|
if(exit) //Assign Exit target
|
||||||
foreach(KeyValuePair<Vector2, bool> tgt in targets_dict)
|
return spawnPoint;
|
||||||
if(tgt.Value is false)
|
else
|
||||||
avail_tgt.Add(tgt.Key);
|
{
|
||||||
|
List<Vector2> avail_tgt = new List<Vector2>();
|
||||||
Vector2 target = avail_tgt[Random.Range(0, avail_tgt.Count)];
|
foreach(KeyValuePair<Vector2, bool> tgt in targets_dict)
|
||||||
targets_dict[target]=true;
|
if(tgt.Value is false)
|
||||||
return target;
|
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
|
// Start is called before the first frame update
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue