Example #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);
            }
        }
        private void EmitLightnings(ElectricityMagazine magazine, Nozzle nozzle, Unit owner)
        {
            var rays  = nozzle.GetRays();
            int count = magazine.TakeAtMost(rays.Count);

            EnsureDevicesNumber(lightningEmitters, lightningEmitterPrefab, count);
            for (int i = 0; i < count; i++)
            {
                var lightningEmitter = lightningEmitters[i];
                lightningEmitter.transform.AlignWithRay(rays[i]);
                lightningEmitter.Fire(owner);
            }
        }
Example #3
0
        private void LaunchHooks(Nozzle nozzle)
        {
            var rays = nozzle.GetRays();

            EnsureDevicesNumber(hooks, hookPrefab, rays.Count, parentIsThis: false);
            for (int i = 0; i < rays.Count; i++)
            {
                var hook = hooks[i];
                var ray  = rays[i];
                hook.transform.AlignWithRay(ray);
                hook.Launch(this.transform, ray.direction);
            }
        }
        private void ThrowFlames(FireMagazine magazine, Nozzle nozzle, Unit owner)
        {
            flamethrowersAreShut = false;

            var rays  = nozzle.GetRays();
            int count = magazine.TakeAtMost(rays.Count);

            EnsureDevicesNumber(flamethrowers, flamethrowerPrefab, count);
            int i;

            for (i = 0; i < count; i++)
            {
                var flamethrower = flamethrowers[i];
                flamethrower.transform.AlignWithRay(rays[i]);
                flamethrower.StartFlameParticlesOnly();
                flamethrower.ApplyAreaDamage(owner);
            }
            for (; i < flamethrowers.Count; i++)
            {
                flamethrowers[i].Stop();
            }
        }