コード例 #1
0
    IEnumerator OneShotfleam()
    {
        while (shot_time < 500)
        {
            yield return(null);

            if (shot_time > 200)
            {
                //回転弾幕
                if (shot_time % 4 == 0)
                {
                    GameObject      shot = Instantiate(BossEnemyBullet1, transform.position, transform.rotation) as GameObject; //敵弾生成
                    BossEnemyBullet s    = shot.GetComponent <BossEnemyBullet>();                                               //bulletスクリプトを取得
                    s.Add(rad, 0.01f);                                                                                          //関数に弾の初期情報を渡す
                    rad += 0.2f;                                                                                                //発射角度プラス
                }
                if (shot_time % 4 == 0)
                {
                    GameObject      shot = Instantiate(BossEnemyBullet2, transform.position, transform.rotation) as GameObject; //敵弾生成
                    BossEnemyBullet s    = shot.GetComponent <BossEnemyBullet>();                                               //bulletスクリプトを取得
                    s.Add(rad2, 0.01f);                                                                                         //関数に弾の初期情報を渡す
                    rad2 -= 0.2f;                                                                                               //発射角度マイナス
                }
            }
            //shot_timeの数値でBossの動作管理を行う
            shot_time++;
        }
    }
コード例 #2
0
    IEnumerator trackingshot()
    {
        while (shot_time < 800)
        {
            yield return(null);

            if (shot_time > 500)
            {
                //追尾
                if (shot_time % 45 == 0)
                {
                    Vector2 e0  = transform.position;                                                                               //自機と敵の角度計算
                    float   etx = Player.transform.position.x - e0.x;                                                               //自機と敵の角度計算
                    float   ety = Player.transform.position.y - e0.y;                                                               //自機と敵の角度計算
                    rad = Mathf.Atan2(ety, etx);                                                                                    //自機と敵の角度計算

                    for (float ang = -7.8f; ang <= -5.4f; ang += 0.4f)                                                              //自機狙い6方向弾幕(1フレームに6発発射)
                    {
                        GameObject      shot = Instantiate(BossEnemyBullet1, transform.position, transform.rotation) as GameObject; //敵弾生成
                        BossEnemyBullet s    = shot.GetComponent <BossEnemyBullet>();                                               //bulletスクリプトを取得
                        s.Add(rad + ang + 0.1f, 0.03f);                                                                             //関数に弾の初期情報を渡す
                    }
                }
            }
            //shot_timeの数値でBossの動作管理を行う
            shot_time++;
        }
    }
コード例 #3
0
    IEnumerator Shot8()
    {
        while (shot_time < 160)
        {
            yield return(null);

            if (shot_time > 100)
            {
                //弾幕1
                if (shot_time % 16 == 0)
                {
                    //弾発射角度が6.28になるまでループ【6.28で一回転(3.14の2倍)】
                    for (rad = 0f; rad < 6.28f; rad += 0.8f)
                    {
                        //敵弾1の生成
                        GameObject shot = Instantiate(BossEnemyBullet1, transform.position, transform.rotation) as GameObject;
                        //BossEnemyBulletからスクリプトを取得する
                        BossEnemyBullet s = shot.GetComponent <BossEnemyBullet>();
                        //関数を通じて弾の初期情報を渡す(発射角度、スピード)
                        s.Add(rad + rad2, 0.01f);
                    }
                    //1フレームごとに発射角度プラス
                    rad2 += 0.1f;
                    //弾発射角度が6.28になるまでループ【6.28で一回転(3.14の2倍)】
                    for (rad = 0f; rad < 6.28f; rad += 0.8f)
                    {
                        //敵弾2の生成
                        GameObject shot = Instantiate(BossEnemyBullet2, transform.position, transform.rotation) as GameObject;
                        //BossEnemyBulletからスクリプトを取得する
                        BossEnemyBullet s = shot.GetComponent <BossEnemyBullet>();
                        //関数を通じて弾の初期情報を渡す(発射角度、スピード)
                        s.Add(rad + rad3, 0.01f);
                    }
                    //1フレームごとに発射角度マイナス
                    rad3 -= 0.1f;
                }
            }
            //shot_timeの数値でBossの動作管理を行う
            shot_time++;
        }
    }
コード例 #4
0
    void Shot(float angle, float speed)
    {
        BossEnemyBullet bullet = Instantiate(bulletPrefab, transform.position, transform.rotation);

        bullet.Setting(angle, speed); // Mathf.PI/4fは45°
    }