예제 #1
0
    public void OnTriggerEnter2D(Collider2D other)
    {
        bulletAngre = transform.localEulerAngles.z;//今の角度を取得
        i           = mother.firstangle(bulletAngre);

        //firstangle(bulletAngre);//判定
        if (other.gameObject.tag != "damage") //弾以外に当たった時
        {
            if (count >= maxCount)            //既定の回数だけ反射していたら
            {
                Destroy(gameObject);          //オブジェクトを消す
            }
        }
        if (other.gameObject.tag == "topwall")//上の壁
        {
            count      += 1;
            bulletAngre = mother.Reflection(1, i, bulletAngre);
        }
        else if (other.gameObject.tag == "ground")//床
        {
            count      += 1;
            bulletAngre = mother.Reflection(2, i, bulletAngre);
        }
        else if (other.gameObject.tag == "leftwall")//左の壁
        {
            count      += 1;
            bulletAngre = mother.Reflection(3, i, bulletAngre);
        }
        else if (other.gameObject.tag == "rightwall")
        {
            count      += 1;
            bulletAngre = mother.Reflection(4, i, bulletAngre);
        }
        else if (other.gameObject.tag == "damage2")
        {
            Destroy(gameObject);
        }
        transform.rotation = Quaternion.Euler(0, 0, bulletAngre);
    }
예제 #2
0
    private void Reflect(string tag)
    {
        reflect = _oBase.firstangle(angle);
        switch (tag)
        {
        case "topwall":    //上
            angle = _oBase.Reflection(1, reflect, angle);
            break;

        case "ground":    //下
            angle = _oBase.Reflection(2, reflect, angle);
            break;

        case "leftwall":    //左
            angle = _oBase.Reflection(3, reflect, angle);
            break;

        case "rightwall":    //右
            angle = _oBase.Reflection(4, reflect, angle);
            break;

        case "enemy":
            break;

        default:
            break;
        }

        try
        {
            particle.transform.rotation = Quaternion.Euler(0, 0, angle + 360);
        }
        catch (System.Exception e)
        {
        }
    }