Example #1
0
    void OnTriggerEnter2D(Collider2D c)
    {
        // *It is compared with name in order to separate as Asset from project settings.
        //  However, it is recommended to use Layer or Tag.
        if (c.name.Contains(NAME_PLAYER_BULLET))
        {
            UbhSimpleBullet bullet = c.transform.parent.GetComponent <UbhSimpleBullet>();

            UbhObjectPool.Instance.ReleaseGameObject(c.transform.parent.gameObject);

            _Hp = _Hp - bullet._Power;

            if (_Hp <= 0)
            {
                FindObjectOfType <UbhScore>().AddPoint(_Point);

                _Spaceship.Explosion();

                Destroy(gameObject);
            }
            else
            {
                _Spaceship.GetAnimator().SetTrigger(ANIM_DAMAGE_TRIGGER);
            }
        }
    }
    private void OnTriggerEnter2D(Collider2D c)
    {
        // *It is compared with name in order to separate as Asset from project settings.
        //  However, it is recommended to use Layer or Tag.
        if (c.name.Contains(NAME_PLAYER_BULLET))
        {
            UbhPlayerBullet playerBullet = c.transform.parent.GetComponent <UbhPlayerBullet>();
            if (playerBullet != null && playerBullet.isActive)
            {
                UbhObjectPool.instance.ReleaseBullet(playerBullet);

                m_hp = m_hp - playerBullet.m_power;

                if (m_hp <= 0)
                {
                    FindObjectOfType <UbhScore>().AddPoint(m_point);

                    m_spaceship.Explosion();

                    Destroy(gameObject);
                }
                else
                {
                    m_spaceship.GetAnimator().SetTrigger(ANIM_DAMAGE_TRIGGER);
                }
            }
        }
    }
    private void Damage()
    {
        if (m_manager != null)
        {
            m_manager.GameOver();
        }

        m_spaceship.Explosion();

        Destroy(gameObject);
    }
Example #4
0
    void HitCheck(Transform colTrans)
    {
        // *It is compared with name in order to separate as Asset from project settings.
        //  However, it is recommended to use Layer or Tag.
        string goName = colTrans.name;

        if (goName.Contains(NAME_ENEMY_BULLET))
        {
            UbhObjectPool.Instance.ReleaseGameObject(colTrans.parent.gameObject);
        }

        if (goName.Contains(NAME_ENEMY))
        {
            UbhManager manager = FindObjectOfType <UbhManager>();
            if (manager != null)
            {
                manager.GameOver();
            }

            _Spaceship.Explosion();

            Destroy(gameObject);
        }
    }
Example #5
0
    private void HitCheck(Transform colTrans)
    {
        // *It is compared with name in order to separate as Asset from project settings.
        //  However, it is recommended to use Layer or Tag.
        string goName = colTrans.name;

        if (goName.Contains(NAME_ENEMY_BULLET))
        {
            UbhBullet bullet = colTrans.parent.GetComponent <UbhBullet>();
            UbhObjectPool.instance.ReleaseBullet(bullet);
        }

        if (goName.Contains(NAME_ENEMY))
        {
            if (m_manager != null)
            {
                m_manager.GameOver();
            }

            m_spaceship.Explosion();

            Destroy(gameObject);
        }
    }