private IEnumerator ReloadWeapon(Unit.UnitController unit) { BulletsQuantityUnit bulletsQuantity = unit.bulletsQuantity; ShootingCheck shootingCheck = unit.shootingCheck; Animator animator = unit.animator; //m_LinkManager.shootingController.StopAllCoroutines(); shootingCheck.DisableShooting(); shootingCheck.isShoot = false; shootingCheck.isNoAmmo = true; shootingCheck.StopAllCoroutines(); animator.SetTrigger("ReloadGun"); m_AudioSource.PlayOneShot(m_SoundReload); yield return(new WaitForSeconds(bulletsQuantity.currentWeapon.ReloadTime)); if (!bulletsQuantity.currentWeapon.InfinityBullets) { bulletsQuantity.allBulletsWeapon -= bulletsQuantity.defaultBulletsInClip; } m_AudioSource.Stop(); bulletsQuantity.quantityBulletsInClip = bulletsQuantity.defaultBulletsInClip; SetUIWeaponParameters(unit); shootingCheck.isNoAmmo = false; shootingCheck.isShoot = true; }
private void SetBullets(BulletsQuantityUnit bulletsQuantity, DataWeapons weapon) { bulletsQuantity.allBulletsWeapon = weapon.QuantityAllBulletsWeapon; bulletsQuantity.quantityBulletsInClip = weapon.QuantityBulletsInClip; bulletsQuantity.defaultBulletsInClip = weapon.QuantityBulletsInClip; bulletsQuantity.currentWeapon = weapon; }
private void NextWeapon(Unit.UnitController unit) { BulletsQuantityUnit bulletsQuantity = unit.bulletsQuantity; m_AudioSource.PlayOneShot(m_NextWeapon); bulletsQuantity.lastWeapon = bulletsQuantity.currentWeapon.IdWeapon; bulletsQuantity.nextWeapon = bulletsQuantity.currentWeapon.IdWeapon + 1; if (bulletsQuantity.nextWeapon >= m_DataWeapons.Length) { bulletsQuantity.nextWeapon = 0; } SetWeaponParameters(bulletsQuantity.nextWeapon, unit); }
public void SetShootLogic(Unit.UnitController unit) { BulletsQuantityUnit bulletsQuantityUnit = unit.bulletsQuantity; var currentWeaponId = bulletsQuantityUnit.currentWeapon.IdWeapon; switch (unit.bulletsQuantity.currentWeapon.TypeShooting) { case DataWeapons.ChoiceTypeShooting.Automatic: m_ShotLogic = bulletsQuantityUnit.allWeaponUnit[currentWeaponId].GetComponent <AutoWeapon>(); break; case DataWeapons.ChoiceTypeShooting.Shotgun: m_ShotLogic = bulletsQuantityUnit.allWeaponUnit[currentWeaponId].GetComponent <ShotgunWeapon>(); break; } m_ShotLogic.shootingCheck = this; }
public void SetWeaponParameters(int idWeapon, Unit.UnitController unit) { LinkManager linkManager = LinkManager.instance; DataWeapons weapon = m_DataWeapons[idWeapon]; BulletsQuantityUnit bulletsQuantity = unit.bulletsQuantity; SetBullets(bulletsQuantity, weapon); unit.shootingCheck.SetShootLogic(unit); if (unit.isBot) { return; } SetUIWeaponParameters(linkManager, bulletsQuantity, weapon); bulletsQuantity.allWeaponUnit[bulletsQuantity.lastWeapon].SetActive(false); bulletsQuantity.allWeaponUnit[bulletsQuantity.currentWeapon.IdWeapon].SetActive(true); }
public void BulletsCount(Unit.UnitController unit) { BulletsQuantityUnit bulletsQuantity = unit.bulletsQuantity; if (bulletsQuantity.quantityBulletsInClip == 0) { return; } bulletsQuantity.quantityBulletsInClip--; if (bulletsQuantity.quantityBulletsInClip == 0 & bulletsQuantity.allBulletsWeapon != 0) { StartCoroutine(ReloadWeapon(unit)); } if (bulletsQuantity.quantityBulletsInClip == 0 & bulletsQuantity.allBulletsWeapon == 0) { NoBullets(unit); } SetUIWeaponParameters(unit); }
private void SetUIWeaponParameters(LinkManager linkManager, BulletsQuantityUnit bulletsQuantity, DataWeapons weapon) { linkManager.uiManager.SetQuantityBullets(bulletsQuantity); linkManager.uiManager.SetWeaponIcon(weapon.Icon); }