Exemple #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;
        }
    }
Exemple #2
0
    private void DisplayAmmo()
    {
        int currentAmmo = ammoSlot.GetCurrentAmmo(ammoType);

        ammoCount.text = currentAmmo.ToString();
        ammoKind.text  = ammoType.ToString();
    }
Exemple #3
0
 private void Water()
 {
     if (ammoSlot.GetCurrentAmmo() > 0)
     {
         PlayWateringFx();
         ProccessRayCast();
         ammoSlot.ReduceCurrentAmmo();
     }
 }
Exemple #4
0
 void Update()
 {
     DisplayAmmo();
     if (ammoSlot.GetCurrentAmmo(ammoType) <= 0)
     {
         return;
     }
     if (Input.GetButtonDown("Fire1") && canShoot == true)
     {
         StartCoroutine(Shoot());
     }
 }
Exemple #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;
    }
Exemple #6
0
 private void Shoot()
 {
     if (ammoSlot.GetCurrentAmmo(ammoType) > 0)
     {
         PlayMuzzleFlash();
         Process();
         ammoSlot.ReduceCurrentAmmo(ammoType);
     }
 }
    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;
    }
Exemple #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());
            }
        }
    }
Exemple #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());
         }
     }
 }
Exemple #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());
        }
    }
Exemple #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();
        }
    }
Exemple #12
0
 //
 private void Shoot()
 {
     if (ammoSlot.GetCurrentAmmo() > 0)
     {
         PlayMuzzleFlash();
         ammoSlot.ReduceCurrentAmmo();
         ProcessRaycast();
     }
     else
     {
         Debug.Log("CLICK CLICK ALL OUT!");
     }
 }
Exemple #13
0
    private IEnumerator Shoot()
    {
        canShoot = false;
        if (ammoSlot.GetCurrentAmmo(ammoType) > 0)
        {
            ammoSlot.ReduceCurrentAmmo(ammoType);
            PlayMuzzleFlash();
            ProcessRaycast();
        }
        yield return(new WaitForSeconds(shootingDelay));

        canShoot = true;
    }
Exemple #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);
     }
 }
    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;
    }
Exemple #17
0
 private void ShowAmmoAmount()
 {
     gameplayUI.GetComponentInChildren <Text>().text = ammoSlot.GetCurrentAmmo(ammoType).ToString();
 }
Exemple #18
0
 void OnEnable()
 {
     canShoot = true;
     UIcanvas.UpdateAmmoDisplay(ammoSlot.GetCurrentAmmo(ammoType));
 }
Exemple #19
0
    private void DisplayAmmo()
    {
        int currentAmmo = ammoSlot.GetCurrentAmmo();

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

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

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