コード例 #1
0
        public void RecursiveAttack(Enemy attackEnemy, List <Enemy> enemies)
        {
            attackEnemy.DealDamage(damage);
            enemies.Add(attackEnemy);

            // Perform overlap sphere around current attack enemy
            Collider[] hits = Physics.OverlapSphere(attackEnemy.transform.position, electicityRange);
            foreach (var hit in hits)
            {
                // Is hit an Enemy and hasn't been hit yet
                Enemy hitEnemy = hit.GetComponent <Enemy>();
                if (hitEnemy && !enemies.Contains(hitEnemy))
                {
                    Ray enemyRay = new Ray();
                    enemyRay.direction = hitEnemy.transform.position - attackEnemy.transform.position;
                    enemyRay.origin    = attackEnemy.transform.position;
                    RaycastHit hitObject;
                    if (Physics.Raycast(enemyRay, out hitObject))
                    {
                        Enemy en = hitObject.collider.GetComponent <Enemy>();
                        if (en == hitEnemy)
                        {
                            RecursiveAttack(hitEnemy, enemies);
                        }
                    }
                }
            }
        }
コード例 #2
0
 public override void Attack(Enemy e)
 {
     // Enable the line
     line.enabled = true;
     // Deal damage to enemy
     e.DealDamage(damage);
 }
コード例 #3
0
        void OnTriggerEnter(Collider col)
        {
            Enemy e = col.GetComponent <Enemy>();

            if (e != null)
            {
                e.DealDamage(damage);
                Destroy(gameObject);
            }
            if (col.name == "Ground")
            {
                Destroy(this);
            }
        }
コード例 #4
0
ファイル: Projectile.cs プロジェクト: bananabiz/C-Features
        private void OnTriggerEnter(Collider col)
        {
            //Let e = col's Enemy component  (get Enemy script)
            Enemy e = col.GetComponent <Enemy>();

            //If e != null
            if (e != null)
            {
                //Call e.DealDamage(damage)
                e.DealDamage(damage);
                //Destroy self
                Destroy(gameObject);
            }
            //If col's name == "Wall"
            if (col.tag == "Wall")
            {
                //Destroy the projectile
                Destroy(gameObject);
            }
        }
コード例 #5
0
        void OnTriggerEnter(Collider col)
        {
            // LET e = col's Enemy component
            Enemy e = col.GetComponent <Enemy>();

            // IF e != null
            if (e != null)
            {
                // CALL e.DealDamage(damage)
                e.DealDamage(damage);
                // Destroy gameObject
                Destroy(gameObject);
            }

            // IF col's name == "Ground"
            if (col.name == "Ground")
            {
                // Destroy the projectile
                Destroy(gameObject);
            }
        }
コード例 #6
0
 public override void Attack(Enemy e)
 {
     line.enabled = true;
     e.DealDamage(damage);
 }
コード例 #7
0
ファイル: Laser.cs プロジェクト: nsi-games/TowerDefense
 public override void Attack(Enemy e)
 {
     e.DealDamage(damage);
     anim.SetBool("IsFiring", true);
 }
コード例 #8
0
 public override void Attack(Enemy e)
 {
     e.DealDamage(damage);
 }
コード例 #9
0
ファイル: Cannon.cs プロジェクト: nsi-games/TowerDefense
 public override void Attack(Enemy e)
 {
     line.enabled = true;
     e.DealDamage(damage);
     StartCoroutine(DisableLine());
 }