Exemplo n.º 1
0
 // Start is called before the first frame update
 void Awake()
 {
     player         = GameObject.FindGameObjectWithTag("Player").transform;
     nav            = GetComponent <UnityEngine.AI.NavMeshAgent>();
     myPlayerHealth = player.GetComponent <MyPlayerHealth>();
     myEnemyHealth  = GetComponent <MyEnemyHealth>();
 }
Exemplo n.º 2
0
 void Awake()
 {
     player = GameObject.FindGameObjectWithTag("Player").transform;
     playerHealth = player.GetComponent<MyPlayerHeath>();
     enemyHealth = GetComponent<MyEnemyHealth>();
     nav = GetComponent<NavMeshAgent>();
 }
Exemplo n.º 3
0
 // Start is called before the first frame update
 void Awake()
 {
     player         = GameObject.FindGameObjectWithTag("Player");
     myPlayerHealth = player.GetComponent <MyPlayerHealth>();
     anim           = GetComponent <Animator>();
     myEnemyHealth  = GetComponent <MyEnemyHealth>();
 }
    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))
        {
            MyEnemyHealth myEnemyHealth = shootHit.collider.GetComponent <MyEnemyHealth>();
            if (myEnemyHealth != null)
            {
                myEnemyHealth.TakeDamage(damagePerShot, shootHit.point);
            }
            gunLine.SetPosition(1, shootHit.point);
        }
        else
        {
            gunLine.SetPosition(1, shootRay.origin + shootRay.direction * range);
        }
    }
Exemplo n.º 5
0
 void OnTriggerEnter2D(Collider2D hitInfo)
 {
     if (hitInfo.name != "Player" && hitInfo.name != "Tilemap" && hitInfo.tag != "Light" && hitInfo.tag != "Fire" && hitInfo.tag != "Sign")
     {
         MyEnemyHealth enemy = hitInfo.GetComponent <MyEnemyHealth>();
         if (enemy != null)
         {
             enemy.TakeDamage(damage);
         }
         GameObject boom = Instantiate(impactEffect, transform.position, transform.rotation);
         Destroy(gameObject);
         Destroy(boom, time);
     }
 }
 void Start()
 {
     myHealth = gameObject.GetComponent <MyEnemyHealth>();
 }