Add new weapon
This commit is contained in:
@@ -12,6 +12,7 @@ public class WeaponManager : MonoBehaviour
|
||||
public float damage = 0;
|
||||
public float fireRate = 0.5f;
|
||||
private float fireTime;
|
||||
public int ammoCost = 2;
|
||||
public Animator animator;
|
||||
public PlayerManager player;
|
||||
public bool hit = false;
|
||||
@@ -36,7 +37,7 @@ public class WeaponManager : MonoBehaviour
|
||||
if (Input.GetMouseButtonDown(0) && fireTime <= Time.time) {
|
||||
if (weaponType == WeaponType.Shoot)
|
||||
{
|
||||
if (particleShoot != null && player.ammo > 1)
|
||||
if (particleShoot != null && player.ammo > (ammoCost - 1))
|
||||
{
|
||||
GameObject shoot = Instantiate(particleShoot, spawnShoot.transform.position, spawnShoot.transform.rotation);
|
||||
if (shootSound.Count > 0)
|
||||
@@ -44,7 +45,7 @@ public class WeaponManager : MonoBehaviour
|
||||
int rand = Random.Range(0, shootSound.Count);
|
||||
audioSource.PlayOneShot(shootSound[rand]);
|
||||
}
|
||||
player.ammo -= 2;
|
||||
player.ammo -= ammoCost;
|
||||
Destroy(shoot, 0.3f);
|
||||
fireTime = fireRate + Time.time;
|
||||
}
|
||||
|
Reference in New Issue
Block a user