コード例 #1
0
ファイル: boss.cs プロジェクト: LanLou123/SpaceInvaders
    public void  firestage1()
    {
        stage1timer += Time.deltaTime;
        if (stage1timer > stage1shootinterval)
        {
            stage1timer = 0;
            Vector3 spanwpos = new Vector3(-1, gameObject.transform.position.y, 10f);
            for (stage1rot = 0; stage1rot < 2 * Mathf.PI; stage1rot += rotdegree)
            {
                spanwpos.x += 1.70f * Mathf.Cos(stage1rot);
                spanwpos.z -= 1.70f * Mathf.Sin(stage1rot);
                GameObject obj = Instantiate(stag1bullet, spanwpos, Quaternion.identity) as GameObject;
                ene2bullet bb  = obj.GetComponent <ene2bullet>();
                bb.thrust = new Vector3(0, 0, 300);
                Quaternion rot = Quaternion.Euler(new Vector3(0, stage1rot * 180 / Mathf.PI, 0));

                bb.GetComponent <Rigidbody>().MoveRotation(rot);
            }
        }
    }
コード例 #2
0
ファイル: boss.cs プロジェクト: LanLou123/SpaceInvaders
    public void firestage2()
    {
        stg2timer += Time.deltaTime;
        if (stg2timer > stage2shootinterval)
        {
            stg2timer = 0;
            Vector3 spanwpos = new Vector3(-1, gameObject.transform.position.y, gameObject.transform.position.z);

            if (stg2cnt >= 20)
            {
                stg2cnt = 0;
            }
            stg2rot     = stg2cnt * rotdegree;
            spanwpos.x += 4f * Mathf.Cos(stg2cnt);
            spanwpos.z -= 4f * Mathf.Sin(stg2cnt);
            GameObject obj = Instantiate(stag2bullet, spanwpos, Quaternion.identity) as GameObject;
            ene2bullet bb  = obj.GetComponent <ene2bullet>();
            bb.thrust = new Vector3(0, 0, 300);
            Quaternion rot = Quaternion.Euler(new Vector3(0, stg2cnt * 180 / Mathf.PI, 0));

            bb.GetComponent <Rigidbody>().MoveRotation(rot);
            stg2cnt++;
        }
    }