Beispiel #1
0
        protected override void OnHit(RaycastHit hit)
        {
            IDamageable damageable = hit.collider.GetComponent(typeof(IDamageable)) as IDamageable;

            if (damageable != null)
            {
                damageable.TakeDirectDamage(baseDamage);

                if (damageable is LocalDamage)
                {
                    AlienBase alien = ((damageable as LocalDamage).m_entity) as AlienBase;

                    if (alien)
                    {
                        alien.SetTarget(damageSource.transform);
                    }
                }
                else if (damageable is CocoonSpawner)
                {
                    (damageable as CocoonSpawner).TriggerSpawning(damageSource.transform);
                }
                else if (damageable is AlienBase)
                {
                    (damageable as AlienBase).SetTarget(damageSource.transform);
                }
            }

            Destroy(gameObject);
        }
        void OnTriggerEnter(Collider other)
        {
            if (other.CompareTag("Player"))
            {
                return;
            }

            if (Time.time < timer)
            {
                if (!targetsAlreadyTouched.Contains(other.gameObject.GetInstanceID()))
                {
                    IDamageable damageable = other.GetComponent(typeof(IDamageable)) as IDamageable;

                    if (damageable == null)
                    {
                        return;
                    }
                    targetsAlreadyTouched.Add(other.gameObject.GetInstanceID());
                    damageable.TakeDirectDamage(DoDamage());

                    //Target spreading.
                    if (damageable is AlienBase)
                    {
                        AlienBase alien = damageable as AlienBase;
                        alien.SetTarget(damageSource.transform);
                    }

                    if (damageable is CocoonSpawner)
                    {
                        (damageable as CocoonSpawner).TriggerSpawning(damageSource.transform);
                    }
                }
            }
        }
Beispiel #3
0
        void SpawnBaby()
        {
            AlienBase alien = Instantiate(m_babies, transform.position, transform.rotation) as AlienBase;

            alien.m_entity.maxHealth *= 2;
            alien.m_entity.health    *= 2;
            alien.LockTarget(m_target);
            alien.DisablePersistency();
        }
Beispiel #4
0
 void DoPop()
 {
     if (counter < maximumAlienByCycle)
     {
         Transform loc = GetSpawnLoc();
         AlienBase pop = Instantiate(typeOfAlien, loc.position, loc.rotation) as AlienBase;
         pop.SetTarget(target);
         counter++;
     }
     else
     {
         currentState  = CocoonState.COOLDOWN;
         nextCycleTime = Time.time + cycleCooldown;
     }
 }
Beispiel #5
0
        internal void SpawnOnDeath()
        {
            AlienBase alien = Instantiate(m_alienOnDeath, transform.position, transform.rotation) as AlienBase;

            alien.DisablePersistency();
            alien.m_entity.maxHealth *= 2;
            alien.m_entity.health    *= 2;
            alien.LockTarget(m_target);
            m_boss.m_minions.Add(alien);

            AmmoBox drop = Instantiate(m_dropAmmo, transform.position, transform.rotation) as AmmoBox;

            drop.DisablePersistency();
            drop.useRandomAmount  = true;
            drop.minRangeToRandom = m_minimumDropAmmo;
            drop.maxRangeToRandom = m_maximumDropAmmo;
        }
Beispiel #6
0
        void OnTriggerStay(Collider other)
        {
            if (alien == null)
            {
                return;
            }

            if (alien.target == null && other.gameObject.tag == "Player")
            {
                OnAggro(other.transform);
            }

            if (alien.target != null && other.gameObject.tag == "Alien")
            {
                AlienBase spreaded = other.gameObject.GetComponent <AlienBase>();
                if (spreaded.target == null)
                {
                    spreaded.SetTarget(alien.target);
                }
            }
        }