Exemplo n.º 1
0
    protected void Purge()
    {
        //isPurge = true;

        //発射口
        //Transform muzzle = null;
        List <Transform> muzzles = new List <Transform>();

        foreach (Transform child in myTran)
        {
            if (child.tag == Common.CO.TAG_MUZZLE)
            {
                muzzles.Add(child);
            }
            //{
            //muzzle = child;
            //break;
            //}
        }
        //if (muzzle == null) muzzle = myTran;
        if (muzzles.Count == 0)
        {
            muzzles.Add(myTran);
        }

        //子供生成
        float moveAngle = 360 / childeBulletCount;

        for (int i = 0; i < childeBulletCount; i++)
        {
            int        muzzleIndex = i % muzzles.Count;
            Transform  muzzle      = muzzles[muzzleIndex];
            Vector3    muzzlePos   = muzzle.position;
            Quaternion muzzleRot   = muzzle.rotation;
            if (purgeDiff > 0)
            {
                muzzleRot *= Quaternion.AngleAxis(Random.Range(-purgeDiff, purgeDiff), Vector3.up);
                muzzleRot *= Quaternion.AngleAxis(Random.Range(-purgeDiff, purgeDiff), Vector3.right);
            }
            else
            {
                if (muzzles.Count == 1)
                {
                    myTran.Rotate(Vector3.forward, moveAngle);
                }
            }
            GameObject ob       = PhotonNetwork.Instantiate(Common.Func.GetResourceBullet(childBullet.name), muzzlePos, muzzleRot, 0);
            int        bulletNo = Common.Func.GetBulletNo(myTran.root.name);
            ob.name = ob.name + "_" + bulletNo.ToString();
            BulletController bulletCtrl = ob.GetComponent <BulletController>();
            bulletCtrl.BulletSetting(ownerTran, targetTran, weaponTran, false);
        }
        prePurgeTime = 0;

        if (isPurgeDestroy)
        {
            //本体破棄
            DestoryObject();
        }
    }
Exemplo n.º 2
0
    protected void BulletSetting(GameObject bulletObj)
    {
        BulletController bulletCtrl = bulletObj.GetComponent <BulletController>();

        if (bulletCtrl != null)
        {
            bulletCtrl.BulletSetting(playerTran, targetTran, myTran);
        }
    }