コード例 #1
0
    ///
    void OnTriggerEnter2D(Collider2D other)
    {
        if (other != null && other.gameObject != null)
        {
            ShipMBullet Mbullet = other.gameObject.GetComponent <ShipMBullet>();
            ShipSBullet Sbullet = other.gameObject.GetComponent <ShipSBullet>();
            ShipLBullet Lbullet = other.gameObject.GetComponent <ShipLBullet>();


            if (Mbullet != null)
            {
                HP -= Mbullet.GetPower();
                //
                Hurt();
                //
                Destroy(Mbullet.gameObject);
            }
            else if (Sbullet != null)
            {
                HP -= Sbullet.GetPower();
                //
                Hurt();
                //
                Destroy(Sbullet.gameObject);
            }
            else if (Lbullet != null)
            {
                HP -= Lbullet.GetPower();
                //
                Hurt();
                //
                Destroy(Lbullet.gameObject);
            }
        }
    }
コード例 #2
0
    //
    void OnTriggerEnter2D(Collider2D collision)
    {
        if (HP < 0)
        {
            return;
        }

        if (collision.gameObject != null)
        {
            TriangleShip pPCtrl = collision.gameObject.GetComponent <TriangleShip>();
            if (pPCtrl != null)
            {
                pPCtrl.HurtByEnemy(1000);
            }
        }
        //
        if (collision.gameObject != null)
        {
            ShipMBullet Mbullet = collision.gameObject.GetComponent <ShipMBullet>();
            ShipSBullet Sbullet = collision.gameObject.GetComponent <ShipSBullet>();
            ShipLBullet Lbullet = collision.gameObject.GetComponent <ShipLBullet>();


            if (Mbullet != null)
            {
                HP -= Mbullet.GetPower();
                //
                Hurt();
                //
                Destroy(Mbullet.gameObject);
            }
            else if (Sbullet != null)
            {
                HP -= Sbullet.GetPower();
                //
                Hurt();
                //
                Destroy(Sbullet.gameObject);
            }
            else if (Lbullet != null)
            {
                HP -= Lbullet.GetPower();
                //
                Hurt();
                //
                Destroy(Lbullet.gameObject);
            }
        }
    }
コード例 #3
0
ファイル: Boss_1_Logic.cs プロジェクト: woym2008/Oberon
    //
    ///
    void OnTriggerEnter2D(Collider2D other)
    {
        if (other.gameObject != null)
        {
            TriangleShip pPCtrl = other.gameObject.GetComponent <TriangleShip>();
            if (pPCtrl != null)
            {
                pPCtrl.HurtByEnemy();
            }
        }
        //
        if (other != null && other.gameObject != null)
        {
            if (Invincible)
            {
                return;
            }

            ShipMBullet Mbullet = other.gameObject.GetComponent <ShipMBullet>();
            ShipSBullet Sbullet = other.gameObject.GetComponent <ShipSBullet>();
            ShipLBullet Lbullet = other.gameObject.GetComponent <ShipLBullet>();


            if (Mbullet != null)
            {
                HP -= Mbullet.GetPower();
                //
                Hurt();
                //
                Destroy(Mbullet.gameObject);
            }
            else if (Sbullet != null)
            {
                HP -= Sbullet.GetPower();
                //
                Hurt();
                //
                Destroy(Sbullet.gameObject);
            }
            else if (Lbullet != null)
            {
                HP -= Lbullet.GetPower();
                //
                Hurt();
                //
                Destroy(Lbullet.gameObject);
            }
        }
    }