Esempio n. 1
0
    void AddToList(BulletsScriptableObject.Bullet currBullet, ref List <Transform> currList)
    {
        GameObject parent = new GameObject();

        parent.name = "Parent_" + currBullet.prefab.name;

        for (int j = 0; j < currBullet.count; j++)
        {
            Transform trans = Instantiate(currBullet.prefab, Vector3.zero, Quaternion.identity);
            trans.SetParent(parent.transform);
            trans.gameObject.SetActive(false);

            currList.Add(trans);
        }
    }
Esempio n. 2
0
    // Instantiate the bullets at the start of the game.
    void CacheBullets()
    {
        for (int i = 0; i < m_BulletData.prefabList.Count; i++)
        {
            BulletsScriptableObject.Bullet currBullet = m_BulletData.prefabList[i];

            if (currBullet.prefab.CompareTag("PlayerBullet"))
            {
                AddToList(currBullet, ref mPlayerBulletList);
            }
            else if (currBullet.prefab.CompareTag("PlayerRocket"))
            {
                AddToList(currBullet, ref mPlayerRocketList);
            }
            else if (currBullet.prefab.CompareTag("EnemyBullet"))
            {
                AddToList(currBullet, ref mEnemyBulletList);
            }
        }
    }