From f22c59590af267a81796f555d257e94ad786d358 Mon Sep 17 00:00:00 2001 From: Agilham <13521118@std.stei.itb.ac.id> Date: Sat, 11 May 2024 14:34:15 +0700 Subject: [PATCH] fix: owner for projectile statistics --- Assets/Scripts/Managers/StatisticsManager.cs | 4 ++-- Assets/Scripts/Weapon/MachinePistolAttack.cs | 3 +-- Assets/Scripts/Weapon/ShotgunAttack.cs | 2 +- 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/Assets/Scripts/Managers/StatisticsManager.cs b/Assets/Scripts/Managers/StatisticsManager.cs index 5c78dff..c88d13f 100644 --- a/Assets/Scripts/Managers/StatisticsManager.cs +++ b/Assets/Scripts/Managers/StatisticsManager.cs @@ -49,9 +49,9 @@ public class StatisticsManager : MonoBehaviour SaveStatistics(); } - public void ShotFired(int bullets) + public void ShotFired() { - shotsFired += bullets; + shotsFired++; Debug.Log("Shots fired this session: " + shotsFired); } diff --git a/Assets/Scripts/Weapon/MachinePistolAttack.cs b/Assets/Scripts/Weapon/MachinePistolAttack.cs index cc75ac2..e18f314 100644 --- a/Assets/Scripts/Weapon/MachinePistolAttack.cs +++ b/Assets/Scripts/Weapon/MachinePistolAttack.cs @@ -50,7 +50,7 @@ public class MachinePistolAttack : MonoBehaviour GameObject projectile = Instantiate(projectilePrefab, projectilePoint.position, projectilePoint.rotation); projectile.GetComponent<ProjectileController>().damage = damage; projectile.GetComponent<ProjectileController>().ownerTag = owner.tag; - + if (owner.CompareTag("Player")) StatisticsManager.Instance.ShotFired(); audioSource.PlayOneShot(audioClips[Random.Range(0, audioClips.Count)]); @@ -63,6 +63,5 @@ public class MachinePistolAttack : MonoBehaviour rb.AddForce(direction * shotForce, ForceMode.VelocityChange); lastShotTime = Time.time; - StatisticsManager.Instance.ShotFired(1); } } diff --git a/Assets/Scripts/Weapon/ShotgunAttack.cs b/Assets/Scripts/Weapon/ShotgunAttack.cs index 384fe84..65100a1 100644 --- a/Assets/Scripts/Weapon/ShotgunAttack.cs +++ b/Assets/Scripts/Weapon/ShotgunAttack.cs @@ -92,6 +92,7 @@ public class ShotgunAttack : MonoBehaviour projectile.GetComponent<ProjectileController>().damage = damage; projectile.GetComponent<ProjectileController>().ownerTag = owner.tag; if(owner.CompareTag("Player")) projectile.GetComponent<ProjectileController>().isShotgunBullet = true; + if (owner.CompareTag("Player")) StatisticsManager.Instance.ShotFired(); } GameObject ammo; @@ -118,7 +119,6 @@ public class ShotgunAttack : MonoBehaviour lastShotTime = Time.time; Recoil(); - StatisticsManager.Instance.ShotFired(projectilesPerShot); } void Recoil() -- GitLab