Exemplo n.º 1
0
    private void DisplayAmmo()
    {
        int ammoAmount = ammoSlot.GetCurrentAmmo(ammoType);

        ammoText.text = ammoAmount.ToString();

        switch (ammoType)
        {
        case AmmoType.Lightammo:
            lightAmmoIcon.enabled = true;
            heavyAmmoIcon.enabled = false;
            shellIcon.enabled     = false;
            break;

        case AmmoType.Heavyammo:
            lightAmmoIcon.enabled = false;
            heavyAmmoIcon.enabled = true;
            shellIcon.enabled     = false;
            break;

        case AmmoType.Shells:
            lightAmmoIcon.enabled = false;
            heavyAmmoIcon.enabled = false;
            shellIcon.enabled     = true;
            break;
        }
    }
Exemplo n.º 2
0
    private void DisplayAmmo()
    {
        int currentAmmo = ammoSlot.GetCurrentAmmo(ammoType);

        ammoCount.text = currentAmmo.ToString();
        ammoKind.text  = ammoType.ToString();
    }
Exemplo n.º 3
0
 private void Water()
 {
     if (ammoSlot.GetCurrentAmmo() > 0)
     {
         PlayWateringFx();
         ProccessRayCast();
         ammoSlot.ReduceCurrentAmmo();
     }
 }
Exemplo n.º 4
0
 void Update()
 {
     DisplayAmmo();
     if (ammoSlot.GetCurrentAmmo(ammoType) <= 0)
     {
         return;
     }
     if (Input.GetButtonDown("Fire1") && canShoot == true)
     {
         StartCoroutine(Shoot());
     }
 }
Exemplo n.º 5
0
    IEnumerator Shoot()
    {
        canShoot = false;
        if (ammoSlot.GetCurrentAmmo() > 0)
        {
            PlayMuzzleFlash();
            ProcessRaycast();
            ammoSlot.ReduceCurrentAmmo();
        }
        else if (ammoSlot.GetCurrentAmmo() <= 0)
        {
            Debug.Log("Out of Ammo!");
        }
        yield return(new WaitForSeconds(TimeBetweenShots));

        canShoot = true;
    }
Exemplo n.º 6
0
 private void Shoot()
 {
     if (ammoSlot.GetCurrentAmmo(ammoType) > 0)
     {
         PlayMuzzleFlash();
         Process();
         ammoSlot.ReduceCurrentAmmo(ammoType);
     }
 }
Exemplo n.º 7
0
    IEnumerator Shoot()
    {
        canShoot = false;
        if (ammoSlot.GetCurrentAmmo(ammoType) > 0)
        {
            PlayMuzzleFlash();
            ProcessRayCast();
            GetComponent <AudioSource>().Play();
            ammoSlot.ReduceAmmo(ammoType);
        }
        else
        {
            GetComponent <AudioSource>().PlayOneShot(noBulletSound);
        }
        yield return(new WaitForSeconds(timeBetweenShots));

        canShoot = true;
    }
Exemplo n.º 8
0
    void Update()
    {
        DisplayAmmo();
        if (Input.GetButtonDown("Fire1") && canShoot == true)
        {
            StartCoroutine(Shoot());
        }

        if (Input.GetKeyDown(KeyCode.R))
        {
            if (ammoSlot.GetCurrentAmmo(ammoType) == ammoSlot.GetAmmoInGun(ammoType))
            {
                //do nothing
            }
            else
            {
                StartCoroutine(Reload());
            }
        }
    }
Exemplo n.º 9
0
 void Update()
 {
     DisplayAmmo();
     if (semiAuto)
     {
         if (Input.GetMouseButtonDown(0) && ammoSlot.GetCurrentAmmo(ammoType) > 0 && ableToShoot)
         {
             Shoot();
             StartCoroutine(ShotDelay());
         }
     }
     else
     {
         if (Input.GetMouseButton(0) && ammoSlot.GetCurrentAmmo(ammoType) > 0 && ableToShoot)
         {
             Shoot();
             StartCoroutine(ShotDelay());
         }
     }
 }
Exemplo n.º 10
0
    void Update()
    {
        bool isValidShot =
            Input.GetMouseButtonDown(0) &&           // is mouse button down?
            ammoSlot.GetCurrentAmmo(ammoType) > 0 && // is ammo greater than 0?
            canShoot;                                // is shot too soon before last shot

        if (isValidShot)
        {
            StartCoroutine(Shoot());
        }
    }
Exemplo n.º 11
0
    private void Update()
    {
        DisplayAmmo();

        if (isReloading)
        {
            return;
        }

        if (ammoSlot.GetCurrentAmmo(ammoType) <= 0)
        {
            StartCoroutine(Reload());
            return;
        }

        if (Input.GetMouseButton(0) && Time.time >= nextTimeToFire)
        {
            nextTimeToFire = Time.time + 1f / fireRate;
            Shoot();
        }
    }
Exemplo n.º 12
0
 //
 private void Shoot()
 {
     if (ammoSlot.GetCurrentAmmo() > 0)
     {
         PlayMuzzleFlash();
         ammoSlot.ReduceCurrentAmmo();
         ProcessRaycast();
     }
     else
     {
         Debug.Log("CLICK CLICK ALL OUT!");
     }
 }
Exemplo n.º 13
0
    private IEnumerator Shoot()
    {
        canShoot = false;
        if (ammoSlot.GetCurrentAmmo(ammoType) > 0)
        {
            ammoSlot.ReduceCurrentAmmo(ammoType);
            PlayMuzzleFlash();
            ProcessRaycast();
        }
        yield return(new WaitForSeconds(shootingDelay));

        canShoot = true;
    }
Exemplo n.º 14
0
    IEnumerator Shoot()
    {
        canShoot = false;
        if (ammoSlot.GetCurrentAmmo(ammoType) > 0)
        {
            PlayMuzzleFlash();
            ProcessRaycast();
            ammoSlot.ReduceCurrentAmmo(ammoType);
        }
        yield return(new WaitForSeconds(timeBetweenShots));

        canShoot = true;
    }
 private void OnTriggerEnter(Collider other)
 {
     if (other.gameObject.tag == "Player")
     {
         int currentAmmo = ammo.GetCurrentAmmo(ammoType);
         int maxAmmo     = ammo.GetMaxAmmo(ammoType);
         if (currentAmmo == maxAmmo)
         {
             return;
         }
         ammo.RaiseAmmoAmount(ammoType, ammoAmount);
         Debug.Log(ammoType + " Item Pickup");
         Destroy(gameObject);
     }
 }
Exemplo n.º 16
0
    IEnumerator Shoot()
    {
        canShoot = false;

        if (ammoSlot.GetCurrentAmmo(activeWeapon.ammoType) > 0) //if the ammo of the type of the active weapon you hold are more than 0
        {
            onShootEvent?.Invoke(this, EventArgs.Empty);
            PlayShootingSound();

            if (activeWeapon.isHitscan) //If the weapon is hitscan shoot ray
            {
                float range  = activeWeapon.weaponRange;
                int   damage = activeWeapon.weaponDamage;

                RaycastHit hit;
                Ray        landingRay = new Ray(cameraPosition.position, cameraPosition.transform.forward);


                if (Physics.Raycast(landingRay, out hit, range))
                {
                    if (hit.transform.tag == "Enemy")
                    {
                        MessagesHandler.Instance.WriteMessage("hit " + hit.transform.name + " with " + activeWeapon.weaponDamage);
                        hit.transform.GetComponent <Health>().TakeDamage(damage);
                    }
                }
            }
            else //If the weapon is not hitscan shoot the weapon bullet
            {
                GameObject bullet = Instantiate(activeWeapon.bullet, shootingPoint.position, Quaternion.identity);
                bullet.GetComponent <Bullet>().SetBulletDirection(shootingPoint.transform.forward);
                Destroy(bullet, 3);
            }
        }

        yield return(new WaitForSeconds(activeWeapon.weaponDelay));

        canShoot = true;
    }
Exemplo n.º 17
0
 private void ShowAmmoAmount()
 {
     gameplayUI.GetComponentInChildren <Text>().text = ammoSlot.GetCurrentAmmo(ammoType).ToString();
 }
Exemplo n.º 18
0
 void OnEnable()
 {
     canShoot = true;
     UIcanvas.UpdateAmmoDisplay(ammoSlot.GetCurrentAmmo(ammoType));
 }
Exemplo n.º 19
0
    private void DisplayAmmo()
    {
        int currentAmmo = ammoSlot.GetCurrentAmmo();

        ammoText.text = currentAmmo.ToString();
    }
Exemplo n.º 20
0
    private void DisplayAmmo()
    {
        int ammo = ammoSlot.GetCurrentAmmo(ammoType);

        ammoDisplayText.text = ammo.ToString();
    }
Exemplo n.º 21
0
    private void UpdateAmmoUI()
    {
        int currentAmmo = ammoSlot.GetCurrentAmmo(ammoType);

        ammoUIText.text = currentAmmo.ToString("# ###");
    }
Exemplo n.º 22
0
 private void DisplayAmmo()
 {
     ammoText.text = ammoSlot.GetCurrentAmmo(ammoType).ToString();
 }