Add new weapon

This commit is contained in:
Kotrba Filip
2020-02-02 12:23:38 +01:00
parent 25fd284880
commit 97541dfa05
7 changed files with 5425 additions and 130 deletions

View File

@@ -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;
}