Ejemplo n.º 1
0
        public BulletsPool(BaseBullet baseBullet, int poolSize)
        {
            _poolSize = poolSize;
            bullets   = new List <BaseBullet>();

            for (var i = 0; i < _poolSize; i++)
            {
                var bullet = Object.Instantiate(baseBullet);
                bullet.gameObject.SetActive(false);
                bullets.Add(bullet);
            }
        }
Ejemplo n.º 2
0
        protected virtual void Start()
        {
            switch (_weaponType)
            {
            case WeaponType.Gun:
                Bullet = Resources.Load <BaseBullet>("AmmoPrefabs/Bullet_gun");
                break;

            case WeaponType.ShortGun:
                Bullet = Resources.Load <BaseBullet>("AmmoPrefabs/Bullet_gun");
                break;

            case WeaponType.GranadeGun:
                Bullet = Resources.Load <BaseBullet>("AmmoPrefabs/Bullet_granade");
                break;

            case WeaponType.MineGun:
                Bullet = Resources.Load <BaseBullet>("AmmoPrefabs/Bullet_mine");
                break;

            case WeaponType.BolaGun:
                Bullet = Resources.Load <BaseBullet>("AmmoPrefabs/Bullet_bola");
                break;

            case WeaponType.TurrtGun:
                Bullet = Resources.Load <BaseBullet>("AmmoPrefabs/Bullet_turret");
                break;

            case WeaponType.GunOnTurret:
                Bullet = Resources.Load <BaseBullet>("AmmoPrefabs/Bullet_gun");
                break;

            case WeaponType.Railgun:
                Bullet = Resources.Load <BaseBullet>("AmmoPrefabs/Bullet_railgun");
                break;

            default:
                Bullet = Resources.Load <BaseBullet>("AmmoPrefabs/Bullet_gun");
                break;
            }

            bulletsPool = new BulletsPool(Bullet, 10);

            for (var i = 0; i <= _countClip; i++)
            {
                AddClip(new Clip {
                    BulletsCount = Random.Range(_minBulletsCount, _maxBulletsCount)
                });
            }

            ReloadClip();
        }