public void RefillAmmo(GunHandling g)
 {
     if (id != g.currentWeapon && id != g.sideWeapon)
     {
         return;
     }
     g.addPoints(-refillPrice);
     g.refillAmmo(id == g.currentWeapon);
 }
    public void Die()
    {
        isDead = true;
        agent.Stop();
        GunHandling g = target.GetComponentInChildren <GunHandling> ();

        if (g != null)
        {
            g.addPoints(100);
        }
    }
Exemplo n.º 3
0
    IEnumerator Fire()
    {
        if (muzzleFlash != null)
        {
            muzzleFlash.Play();
        }
        Vector3 direction = mainCamera.transform.forward;
        float   spread    = aiming ? aimSpread : hipSpread;

        direction.x += Random.Range(0f, spread);
        direction.y += Random.Range(0f, spread);
        direction.z += Random.Range(0f, spread);

        RaycastHit hit;

        if (Physics.Raycast(mainCamera.transform.position, direction, out hit, range))
        {
            Target t = hit.transform.GetComponent <Target> ();
            if (t != null)
            {
                t.TakeDamage(damage);
                gh.addPoints(10);
            }
            if (hit.rigidbody != null)
            {
                hit.rigidbody.AddForce(-hit.normal * impactForce);
            }
            if (impactEffect != null)
            {
                GameObject o = Instantiate(impactEffect, hit.point, Quaternion.LookRotation(hit.normal));
                Destroy(o, 1f);
            }
            Debug.Log(hit.transform.name);
        }
        clipAmmo--;
        yield return(new WaitForSeconds(1f / fireRate));

        fireing = false;
    }
 public void Replace(GunHandling g)
 {
     g.addPoints(-price);
     g.setCurrent(id);
 }