Beispiel #1
0
    protected override void OnFire(byte fireStatue, Vector3 dir)
    {
        if (fireStatue == 1 && !fireCD)
        {
            fireCD = true;
            float offset = row % 2 == 1 ? 0 : bulletSpace / 2;
            float start  = -Mathf.Floor(row / 2) * bulletSpace + offset;
            for (int i = 0; i < row; i++)
            {
                GameObject bulletGo = ObjectPool.goPool.GetObj(bulletPrefab.GetInstanceID());
                if (bulletGo == null)
                {
                    bulletGo = Instantiate(bulletPrefab) as GameObject;
                }
                float x = start + i * bulletSpace;
                bulletGo.transform.position = transform.localToWorldMatrix.MultiplyPoint(new Vector3(x, 0, 0));
                bulletGo.transform.rotation = transform.rotation;

                BaseBullet bullet = bulletGo.GetComponent <BaseBullet>();
                bullet.ResetBullet();
                bullet.tagetTag = tagetTag;
                bullet.master   = master;
                bullet.pookKey  = bulletPrefab.GetInstanceID();
                if (bullet != null)
                {
                    bullet.SetDir(dir);
                }
                bulletGo.SetActive(true);
            }
            ShowFireEff();
        }
    }