bool SpawnNPC(Color color) { List <Spawn> viableSpawns = new List <Spawn>(); foreach (Spawn s in spawns) { if (s.IsValid(reqDistance)) { viableSpawns.Add(s); } } if (viableSpawns.Count == 0) { return(false); } Spawn choice = viableSpawns[Random.Range(0, viableSpawns.Count)]; choice.Use(); NpcController newNPC = Instantiate(NpcPrefab, choice.transform.position, Quaternion.identity, NpcHolder.transform).GetComponent <NpcController>(); newNPC.color = color; newNPC.direction = choice.validDirections[Random.Range(0, choice.validDirections.Length)]; newNPC.UpdateAnim(); return(true); }