void OnDestroy() { if (instance_ == this) { instance_ = null; } }
void Awake() { if (instance_ == null) { instance_ = this; } if (pool_.Count == 0 && active_pool_.Count == 0) { for (int i = 0; i < 5; ++i) { GameObject instance = GameObject.Instantiate(instance_.prefab_); instance.SetActive(false); pool_.Add(instance); } } }
void Awake() { if (instance_ == null) { instance_ = this; } if (pool_.Count == 0 && active_pool_.Count == 0) { for (int i = 0; i < 5; ++i) { GameObject instance = GameObject.Instantiate(instance_.prefab_); instance.SetActive(false); pool_.Add(instance); } } }
void Update() { if (spawn_timer_ > 0.0f) { spawn_timer_ -= Time.deltaTime; if (spawn_timer_ <= 0.0f) { spawn_timer_ = Random.Range(2.0f, 5.0f); int spawn_pos_index = Random.Range(0, spawn_locations_.Count); Transform at = spawn_locations_[spawn_pos_index]; AndroidPool.Create(at); } } }
void Update() { if (death_timer_ > 0.0f) { death_timer_ -= Time.deltaTime; if (death_timer_ <= 0.0f) { Rigidbody rigidbody = GetComponent <Rigidbody>(); if (rigidbody != null) { rigidbody.constraints = RigidbodyConstraints.FreezeRotation; } AndroidPool.Destroy(gameObject); } } else if (NextNode != null) { Vector3 pos = transform.position; Vector3 target_pos = NextNode.transform.position; target_pos.y = pos.y; Vector3 direction = (target_pos - pos).normalized; transform.Translate(direction * speed_ * Time.deltaTime, Space.World); transform.LookAt(target_pos); FixHeight(); if (Vector3.Distance(transform.position, target_pos) <= node_threshold) { if (NextNode.Next.Count > 0) { NextNode = NextNode.Next[0]; } else { NextNode = null; } } } }
void OnDestroy() { if (instance_ == this) { instance_ = null; } }