IEnumerator TriggerAttack() { ammo = (ignoreAmmo == false) ? ammo - 1 : ammo; if (ammo > 0) { attacks++; if (muzzleFlash != null) { muzzleFlash.Play(); } if (casing != null && ejectPoint != null) { WeaponHelpers.EjectShell(casing, ejectPoint, ejectDirection); } yield return(new WaitForSeconds(attackSpeed)); if (attacks >= attacksPerNumber) { attacking = false; } yield return(TriggerAttack()); } else { animator.PlayReload(); yield return(new WaitForSeconds(behavior.combat.reloadSpeed)); ammo = fullAmmo; attacks = 0; attacking = false; } }
//Effects On fire void FireShot() { if (shot_timer != 0) { return; } shot_timer = baseSettings.waitBetweenShots; if (baseSettings.bullet_left == 0) { PlayEmptySound(); return; } baseSettings.bullet_left -= (baseSettings.bullet_left > 0) ? 1 : 0; ui_bullets.text = baseSettings.bullet_left.ToString(); SetRecoilValues(true); StartCoroutine(MuzzleFlash()); StartCoroutine(PlayWeaponShotAnim()); Tracer(); PlayFireSound(); if (weaponEffects.ejectPoint == null || weaponEffects.ejectShell == null) { WeaponHelpers.EjectShell(weaponEffects.ejectShell, weaponEffects.ejectPoint, weaponEffects.ejectDirection); } AddAimerPosition(aimerVisuals.increaseAimerEveryShot); for (int i = 0; i < baseSettings.bulletsPerShot; i++) { RaycastDamage(); } ThrowGrenade(); if (baseSettings.auto_reload == true && baseSettings.bullet_left < 1 && can_reload == true) { Reload(); } }
void SpawnDecal(RaycastHit hit) { if (particleEffects.bulletDecal != null) { GameObject bullet_hit = Instantiate(particleEffects.bulletDecal, hit.point, Quaternion.LookRotation(hit.normal)) as GameObject; StartCoroutine(WeaponHelpers.DestroyGameObject(bullet_hit, 20.0f)); } }
void SpawnParticle(RaycastHit hit) { ParticleSystem particle = GetParticle(hit.transform.tag); if (particle == null) { return; } ParticleSystem spawned = Instantiate(particle, hit.point, Quaternion.LookRotation(hit.normal)) as ParticleSystem; spawned.Play(); StartCoroutine(WeaponHelpers.DestroyGameObject(spawned.transform.gameObject, 1.0f)); }
//Effects On fire void FireShot() { if (shot_timer != 0) { return; } if (reloading == true) { return; } shot_timer = baseSettings.waitBetweenShots; if (baseSettings.loaded_ammo == 0 && baseSettings.infiniteAmmo == false) { PlayEmptySound(); return; } if (baseSettings.infiniteAmmo == false) { baseSettings.loaded_ammo -= (baseSettings.loaded_ammo > 0) ? 1 : 0; // gui_manager.gui_ammo.bullets_left.text = baseSettings.loaded_ammo.ToString(); } events.OnFire.Invoke(); SetUIVisuals(true); StartCoroutine(PlayWeaponShotAnim()); SetRecoilValues(true); StartCoroutine(MuzzleFlash()); Tracer(); PlayFireSound(); if (weaponEffects.ejectPoint == null || weaponEffects.ejectShell == null) { WeaponHelpers.EjectShell(weaponEffects.ejectShell, weaponEffects.ejectPoint, weaponEffects.ejectDirection); } AddAimerPosition(aimerVisuals.increaseAimerEveryShot); for (int i = 0; i < baseSettings.raysPerShot; i++) { RaycastDamage(); } ThrowGrenade(); if (baseSettings.auto_reload == true && baseSettings.loaded_ammo < 1 && can_reload == true) { Reload(); } }