コード例 #1
0
 void Awake()
 {
     // Set up the references.
     player       = GameObject.FindGameObjectWithTag("Player").transform;
     playerHealth = player.GetComponent <PlayerHealth> ();
     enemyHealth  = GetComponent <TutorialEnemyHealth> ();
     nav          = GetComponent <UnityEngine.AI.NavMeshAgent> ();
 }
コード例 #2
0
        float timer;                                // Timer for counting up to the next attack.

        void Awake()
        {
            // Setting up the references.
            player       = GameObject.FindGameObjectWithTag("Player");
            playerHealth = player.GetComponent <PlayerHealth> ();
            enemyHealth  = GetComponent <TutorialEnemyHealth>();
            anim         = GetComponent <Animator> ();
            audio        = GetComponent <Zombie_Audio>();
        }
コード例 #3
0
    public void Shoot()
    {
        timer = 0f;

        gunAudio.Play();

        gunLight.enabled = true;

        gunParticles.Stop();
        gunParticles.Play();

        gunLine.enabled = true;
        gunLine.SetPosition(0, transform.position);

        shootRay.origin    = transform.position;
        shootRay.direction = transform.forward;

        if (Physics.Raycast(shootRay, out shootHit, range, shootableMask))
        {
            EnemyHealth         enemyHealth         = shootHit.collider.GetComponent <EnemyHealth> ();
            BossHealth          bossHealth          = shootHit.collider.GetComponent <BossHealth> ();
            TutorialEnemyHealth tutorialEnemyHealth = shootHit.collider.GetComponent <TutorialEnemyHealth> ();
            if (enemyHealth != null)
            {
                enemyHealth.TakeDamage(damagePerShot, shootHit.point);
            }
            if (bossHealth != null)
            {
                bossHealth.TakeDamage(damagePerShot, shootHit.point);
            }
            if (tutorialEnemyHealth != null)
            {
                tutorialEnemyHealth.TakeDamage(damagePerShot, shootHit.point);
            }
            gunLine.SetPosition(1, shootHit.point);
        }
        else
        {
            gunLine.SetPosition(1, shootRay.origin + shootRay.direction * range);
        }
    }