Esempio n. 1
0
 /// <summary>
 /// Recycle bullet and put in to the object pool
 /// </summary>
 private void Recycle()
 {
     if (Owner == BulletOwner.enemy)
     {
         if (this.transform.position.y < GameManager.Instance.GetLowerScreenY() - 4f)
         {
             BulletController.RecycleBullet(this.gameObject);
         }
     }
     else
     {
         if (this.transform.position.y > GameManager.Instance.GetUpperScreenY() + 4f)
         {
             BulletController.RecycleBullet(this.gameObject);
         }
     }
 }
Esempio n. 2
0
        /// <summary>
        /// Trigger explosion
        /// </summary>
        void InvokeExplosion()
        {
            GameObject explosion = Instantiate(m_ExplosionParticle);

            explosion.transform.position = this.transform.position;
            Collider2D[] hitColliders = Physics2D.OverlapCircleAll(new Vector2(0f, 1f), 5);
            int          i            = 0;

            while (i < hitColliders.Length)
            {
                if (hitColliders[i].gameObject.tag == "Enemy")
                {
                    hitColliders[i].SendMessage("MissileDamage");
                }
                i++;
            }

            BulletController.RecycleMissile(gameObject);
        }
Esempio n. 3
0
        public virtual void OnCollisionEnter2D(Collision2D collision)
        {
            switch (Owner)
            {
            case BulletOwner.player:
                if (collision.gameObject.tag == "Enemy")
                {
                    BulletController.RecycleBullet(gameObject);
                    collision.gameObject.SendMessage("Damage", Damage);
                }
                break;

            case BulletOwner.enemy:

                if (collision.gameObject.tag == "Player")
                {
                    BulletController.RecycleBullet(gameObject);
                    collision.gameObject.SendMessage("Damage", Damage);
                }
                break;
            }
        }
Esempio n. 4
0
 void Awake()
 {
     m_Instance     = this;
     m_LaserBullets = new ObjectPool(m_Bullets, m_BulletHolder, 100, false, null, null);
     m_Missiles     = new ObjectPool(m_Missile, m_MissileHolder, 10, false, null, null);
 }