Пример #1
0
    public void Fire()
    {
        Vector3    pos = muzzle.position + player.transform.forward / 2 + Vector3.up / 2;
        RaycastHit hit;

        laserLine.SetPosition(0, muzzle.position + lineRejectVector3);
        if (Physics.Raycast(pos, player.transform.forward, out hit, weaponRange))
        {
            laserLine.SetPosition(1, hit.point + lineRejectVector3);
            if (hit.collider.transform.tag == "Ghost" || hit.collider.transform.tag == "Gargoyle")
            {
                enemies.BeAttacked(hit.collider.transform.name);
                fireEffect.transform.SetPositionAndRotation(hit.collider.transform.position, fireEffect.transform.rotation);
                fireEffect.SetActive(true);
            }
        }
        else
        {
            laserLine.SetPosition(1, muzzle.position + (player.transform.forward * weaponRange) + lineRejectVector3);
        }

        GetComponent <AudioSource>().Play();
        StartCoroutine(ShowLineEffect());
        Invoke("Reload", 0.5f);
    }
Пример #2
0
 void KillEnemiesInRange()
 {
     m_enemies = enemies.enemies;
     for (int i = 0; i < m_enemies.Count; i++)
     {
         float distance = (m_enemies[i].position - switchLight.transform.position).sqrMagnitude;
         if (distance <= switchLight.range * switchLight.range)
         {
             enemies.BeAttacked(m_enemies[i].name);
         }
     }
 }