Esempio n. 1
0
        private void SpawnAmmunition(Target target, bool passTarget, bool passEffects)
        {
            if (this.ammoPrefab == null)
            {
                return;
            }
            Transform transform = InstanceManager.Spawn(this.ammoPrefab.transform, this.emitter.position, this.emitter.rotation);

            if (!passTarget)
            {
                return;
            }
            Projectile component = transform.GetComponent <Projectile>();

            if (component == null)
            {
                string arg = string.Format("Ammo '{0}' must have an Projectile component", transform.name);
                UnityEngine.Debug.Log(string.Format("{0}: {1}", this, arg));
                return;
            }
            component.fireController = this;
            component.target         = target;
            if (passEffects)
            {
                component.effectsOnTarget = this.effectsOnTarget;
            }
        }
        /// <summary>
        /// Spawns a prefab if this.detonationPrefab is not null.
        /// If the detonationPrefab has a detonator component, it is optionally
        /// passed this Projectiles effects on target and range.
        /// </summary>
        /// <param name="passEffects"></param>
        private void SpawnDetonatorPrefab(bool passEffects)
        {
            // This is optional. If no ammo prefab is set, quit quietly
            if (this.detonationPrefab == null)
            {
                return;
            }

            Transform inst = InstanceManager.Spawn
                             (
                this.detonationPrefab.transform,
                this.xform.position,
                this.xform.rotation
                             );

            // Nothing left to do, this is just a simple spawn trigger.
            if (!passEffects)
            {
                return;
            }

            // Detonator....
            var detonator = inst.GetComponent <Detonator>();

            if (detonator == null)   // Protection
            {
                return;
            }

            detonator.effectsOnTarget = this.effectsOnTarget;
            detonator.perimeterShape  = this.perimeterShape;
            detonator.range           = this.range;
        }
Esempio n. 3
0
        protected void OnFire(List <Target> targets)
        {
            if (this.prefab == null)
            {
                return;
            }

            InstanceManager.Spawn
            (
                this.poolName,
                this.prefab,
                this.origin.position,
                this.origin.rotation
            );
        }