void OnDestroy()
 {
     if (instance_ == this)
     {
         instance_ = null;
     }
 }
Exemplo n.º 2
0
  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);
            }
        }
    }
Exemplo n.º 4
0
    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);
            }
        }
    }
Exemplo n.º 5
0
    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;
                }
            }
        }
    }
Exemplo n.º 6
0
 void OnDestroy() {
   if (instance_ == this) {
     instance_ = null;
   }
 }