Example #1
0
    private void Start()
    {
        if (rb == null)
        {
            rb = GetComponent <Rigidbody>();
        }
        //Make sure there's a spawnpoint!
        if (m_BulletSpawnPoint == null)
        {
            throw new NullReferenceException("No bullet spawnpoint was found!");
        }
        else
        {
            bulletSpawnPoint = m_BulletSpawnPoint;
        }
        cannonHead            = bulletSpawnPoint.transform.parent.parent.gameObject;
        originalRotationValue = cannonHead.transform.rotation;

        //Check so there's a bullet Prefab
        if (m_BulletPrefab != null)
        {
            bulletPrefab = m_BulletPrefab; bulletPrefab.GetComponent <BulletController>().SetBulletType();
        }

        //Setup the Object Pools!
        if (bulletPrefab.GetComponent <BulletController>().bulletType == Scriptable.BulletTypes.Freeze)
        {
            if (freezeBulletPool == null)
            {
                freezeBulletPool = new Tools.GameObjectPool(1, bulletPrefab);
            }
            bulletPool = freezeBulletPool;
        }

        if (bulletPrefab.GetComponent <BulletController>().bulletType == Scriptable.BulletTypes.AreaDamage)
        {
            if (normalBulletPool == null)
            {
                normalBulletPool = new Tools.GameObjectPool(1, bulletPrefab);
            }
            bulletPool = normalBulletPool;
        }
    }