Example #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);
                    }
                }
            }
        }
Example #3
0
        void OnAggro(Transform trackableTarget)
        {
            if (alien.target == null)
            {
                alien.SetTarget(trackableTarget);

                /*SOUND*/
                //if (alien.onAggroSound) alien.onAggroSound.Play();
            }
        }
Example #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;
     }
 }
Example #5
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);
                }
            }
        }