//Setup for dinsoaur adds a first batch of dinosaurs to the list and spawns them all at once public void Setup() { Dinosaurs = Resources.LoadAll("Prefabs/Dinosaurs"); for (int i = 0; i < (maxDinos - 1); i++) { DinosaurScript dinosaur = NewCustomer(i * 2).GetComponent <DinosaurScript>(); Dinos.Add(dinosaur); dinosaur.startSequence(); } }
//Checks if either the player or the dino have left the collision circle and nulls dino private void OnTriggerExit(Collider other) { if (other.gameObject.layer == 13) { dino = null; dinoPresent = false; } if (other.gameObject.layer == 8) { playerPresent = false; } }
//Checks if either the player or the dino have entered the collision circle and assigns dino to the colliding dino private void OnTriggerEnter(Collider other) { if (other.gameObject.layer == 13) { dino = other.gameObject.GetComponent <DinosaurScript>(); dinoPresent = true; } if (other.gameObject.layer == 8) { playerPresent = true; } }
//Destroys the Dino that requests so, also deletes it from the list and spawns a new customer public void DestroyDino(DinosaurScript dino) { Debug.Log("22"); Dinos.Remove(dino); Destroy(dino.gameObject); GameObject Dinosaur = NewCustomer(Dinos.Count); if (Dinosaur != null) { DinosaurScript dinoScript = Dinosaur.GetComponent <DinosaurScript>(); Dinos.Add(dinoScript); dinoScript.startSequence(); } }
// ============================================== public funtion ============================================ // 새로운 공룡을 추가 public void AddDino(DinosaurScript dino) { dinosaurs.Add(dino); }