Unity3D经验(3)——飞机弹幕设计

圆形弹幕:

    override protected IEnumerator Shoots()
    {
        Vector3 firdir = transform.up;
        Quaternion offset = Quaternion.AngleAxis(30, Vector3.forward);
        for (int j = 1; j <= 5; j++)
        {
            for (int i = 1; i <= 12; i++)
            {
                GameObject tmp = Instantiate(bullet);
                tmp.transform.position = transform.position;
                tmp.transform.rotation = Quaternion.Euler(firdir);
                firdir = offset * firdir;
            }
            yield return new WaitForSeconds(1f);
        }
        yield return null;
    }

三点弹幕:

override protected IEnumerator Shoots()
    {
        Vector3 firdir;
        Quaternion offsetL = Quaternion.AngleAxis(30, Vector3.forward);
        Quaternion offsetR = Quaternion.AngleAxis(-30, Vector3.forward);
        for (int j = 1; j <= 5; j++)
        {
            firdir = -transform.up;
            firdir = offsetL * firdir;
            GameObject tmp = Instantiate(bullet);
            tmp.transform.position = transform.position;
            tmp.transform.rotation = Quaternion.Euler(firdir);
            firdir = offsetR * firdir;
            tmp = Instantiate(bullet);
            tmp.transform.position = transform.position;
            tmp.transform.rotation = Quaternion.Euler(firdir);
            firdir = offsetR * firdir;
            tmp = Instantiate(bullet);
            tmp.transform.position = transform.position;
            tmp.transform.rotation = Quaternion.Euler(firdir);
            yield return new WaitForSeconds(1f);
        }
        yield return null;
    }

圆形延迟弹幕:

override protected IEnumerator Shoots()
    {
        Vector3 firdir = transform.up;
        Quaternion offset = Quaternion.AngleAxis(30, Vector3.forward);
        for (int j = 1; j <= 5; j++)
        {
            for (int i = 1; i <= 12; i++)
            {
                GameObject tmp = Instantiate(bullet);
                tmp.transform.position = transform.position;
                tmp.transform.rotation = Quaternion.Euler(firdir);
                firdir = offset * firdir;
                yield return new WaitForSeconds(0.05f);
            }
        }
        yield return null;
    }

星状散射弹幕:

override protected IEnumerator Shoots()
    {
        Vector3 firdir = transform.up;
        Quaternion offset = Quaternion.AngleAxis(60, Vector3.forward);
        for (int k = 1; k <= 3; k++)
        {
            for (int j = 1; j <= 5; j++)
            {
                for (int i = 1; i <= 6; i++)
                {
                    GameObject tmp = Instantiate(bullet);
                    tmp.transform.position = transform.position;
                    tmp.transform.rotation = Quaternion.Euler(firdir);
                    firdir = offset * firdir;
                }
                yield return new WaitForSeconds(0.05f);
            }
            yield return new WaitForSeconds(0.3f);
        }
        yield return null;
    }

散射追踪弹幕:

override protected IEnumerator Shoots()
    {
        Vector3 firdir = transform.up;
        Quaternion offset = Quaternion.AngleAxis(60, Vector3.forward);
        Quaternion kick = Quaternion.AngleAxis(3, Vector3.forward);
        for (int j = 1; j <= 120; j++)
        {
            firdir = kick * firdir;
            for (int i = 1; i <= 6; i++)
            {
                GameObject tmp = Instantiate(bullet);
                tmp.transform.position = transform.position;
                tmp.transform.rotation = Quaternion.Euler(firdir);
                firdir = offset * firdir;
            }
            yield return new WaitForSeconds(0.05f);
        }
        yield return null;
    }

猜你喜欢

转载自blog.csdn.net/weixin_42921101/article/details/107469610