// Start is called before the first frame update void Start() { rigidbody = GetComponent <Rigidbody>(); animator = GetComponent <Animator>(); meshRenderer = GetComponent <MeshRenderer>(); graph = GameObject.FindGameObjectWithTag("Graph").GetComponent <Graph>(); destination = new Vector3(); destination = transform.position; currentNode = home; path = new Queue <GraphNode>(); List <GraphNode> work = new List <GraphNode>(); if (graph.Nodes.Any()) { foreach (var node in graph.Nodes.Where(node => node.attribute == GraphNode.Attribute.Office)) { work.Add(node); } if (work.Count > 0) { System.Random randomWork = new System.Random(); this.work = work[randomWork.Next(0, work.Count)]; this.work.GetComponent <OfficeNode>().AddCitizen(gameObject); } else { destination = new Vector3(); destination = transform.position; currentNode = home; ObjectPool pool = GameObject.FindGameObjectWithTag("Manager").GetComponent <ObjectPool>(); pool.AddObjcetToPool("Simple Citizen", gameObject); gameObject.SetActive(false); } } SecureRandom rng = new SecureRandom(); randomAStarUpdate = rng.NextFloat(1, 20); }