Commit 90b2f22b authored by Tobias's avatar Tobias

Made Spawn Tracks Parallel

parent 58d7d137
......@@ -19,6 +19,7 @@ public class CustomerBehaviour : MonoBehaviour
private bool _percTwo = false;
private bool _percThree = false;
private Transform _despawnPoint;
private GameObject _cameraObject;
private NavMeshAgent _agent;
private Order _customerOrder;
......@@ -53,6 +54,12 @@ public class CustomerBehaviour : MonoBehaviour
public NavMeshAgent Agent => _agent;
public Transform DespawnPoint
{
get => _despawnPoint;
set => _despawnPoint = value;
}
// Start is called before the first frame update
void Start()
{
......@@ -98,7 +105,7 @@ public class CustomerBehaviour : MonoBehaviour
print("I waited too long!!!11!elf");
_playerActor.AudioSource.PlayOneShot(_customerSounds.GetAngryClip(), 0.2f);
_agent.SetDestination(transform.parent.position);
_agent.SetDestination(_despawnPoint.transform.position);
_customerBar.gameObject.SetActive(false);
_state = CustomerState.Leaving;
}
......
......@@ -9,6 +9,7 @@ public class CustomerSpawner : MonoBehaviour
{
[SerializeField] private List<CustomerData> possibleCustomers;
[SerializeField] private List<Transform> waitingSpots;
[SerializeField] private List<Transform> despawnSpots;
[SerializeField] private float maxTimeTillNextCustomer;
[SerializeField] private float timeTillFullDifficulty;
[SerializeField] private AnimationCurve timeCurve;
......@@ -35,11 +36,13 @@ public class CustomerSpawner : MonoBehaviour
// Spawn Customer
int randomValue = Random.Range(0, possibleCustomers.Count - 1);
GameObject customerObject =
Instantiate(possibleCustomers[randomValue].Prefab, this.transform);
Instantiate(possibleCustomers[randomValue].Prefab, despawnSpots[freeSpot]);
NavMeshAgent agent = customerObject.GetComponent<NavMeshAgent>();
if (agent != null)
{
agent.SetDestination(waitingSpots[freeSpot].position);
customerObject.GetComponent<CustomerBehaviour>().DespawnPoint = despawnSpots[freeSpot];
}
customerObject.GetComponent<CustomerBehaviour>().CustomerData = possibleCustomers[randomValue].Order;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment