Ejemplo n.º 1
0
        protected void ShootBullets(GameObjectPool pool, Magazine magazine, Nozzle nozzle, Unit owner, int cost = 1)
        {
            var rays       = nozzle.GetRays();
            int ammosTaken = magazine.TakeAtMost(rays.Count * cost);
            int count      = Mathf.CeilToInt((float)ammosTaken / cost);

            for (int i = 0; i < count; i++)
            {
                ReleaseBullet(rays[i], pool, owner);
            }
        }
Ejemplo n.º 2
0
        protected override void OnFire()
        {
            status = null;

            Magazine magazine = weapon.magazine;

            if (magazine.isEmpty)
            {
                return;
            }
            switch (magazine)
            {
            case BulletMagazine bulletMag:
                ShootBullets(bulletMag.heavyBulletPool, magazine, weapon.nozzle, weapon.owner, 20);
                break;

            case ElectricityMagazine electroMag:
                EmitLightnings(electroMag, weapon.nozzle, weapon.owner, 35);
                break;
            }
        }
        private void Fire()
        {
            Magazine magazine = weapon.magazine;

            if (magazine.isEmpty)
            {
                return;
            }
            switch (magazine)
            {
            case BulletMagazine bulletMag:
                ShootBullets(bulletMag.bulletPool, magazine, weapon.nozzle, weapon.owner);
                break;

            case FireMagazine fireMag:
                ThrowFlames(fireMag, weapon.nozzle, weapon.owner);
                break;

            case ElectricityMagazine electroMag:
                EmitLightnings(electroMag, weapon.nozzle, weapon.owner);
                break;
            }
        }