[+] added
+ grenade.cs script
+ grenades can be thrown
+ grenades "explode" and spawn "explosion" (currently only a 50% transparent cube)

- NEEDS TO BE TESTED => BUG FIXED
This commit is contained in:
Noah4ever
2021-12-08 15:31:13 +01:00
parent 95f94d062d
commit 56f5aec9cc
14 changed files with 735 additions and 78 deletions

View File

@@ -9,10 +9,9 @@ public class Weapon : MonoBehaviour
Rifle, Pistole, Knife, Grenade
}
[SerializeField] weaponKinds weaponKind;
[SerializeField] bool active = false;
[SerializeField] float dropForce = 10f;
[SerializeField] int damage = 0;
[SerializeField] float firerate = 0;
[SerializeField] int roundsPerShot = 1;
[SerializeField] float recoilStrength = 0;
[SerializeField] int currentAmmunition = 0;
[SerializeField] int magazinSize = 0;
@@ -22,12 +21,17 @@ public class Weapon : MonoBehaviour
[SerializeField] Animator weaponAnimator;
[SerializeField] Transform gunRightREF;
[SerializeField] Transform gunLeftREF;
[Header("Grenade")]
[SerializeField] bool isGrenade = false;
[SerializeField] float timer = 2f;
[SerializeField] float explosionForce = 2f;
[SerializeField] float grenadeRadius = 3f;
[SerializeField] bool hasExploded = false;
[SerializeField] bool hasBeenThrown = false;
public bool Active { get => active; set => active = value; }
public weaponKinds WeaponKind { get => weaponKind; }
public int Damage { get => damage; set => damage = value; }
public float Firerate { get => firerate; set => firerate = value; }
public int RoundsPerShot { get => roundsPerShot; set => roundsPerShot = value; }
public float RecoilStrength { get => recoilStrength; set => recoilStrength = value; }
public int CurrentAmmunition { get => currentAmmunition; set => currentAmmunition = value; }
public int MagazinSize { get => magazinSize; set => magazinSize = value; }
@@ -37,10 +41,18 @@ public class Weapon : MonoBehaviour
public Animator WeaponAnimator { get => weaponAnimator; }
public Transform GunLeftREF { get => gunLeftREF; }
public Transform GunRightREF { get => gunRightREF; }
public float Timer { get => timer; set => timer = value; }
public float GrenadeRadius { get => grenadeRadius; set => grenadeRadius = value; }
public bool HasExploded { get => hasExploded; set => hasExploded = value; }
public bool IsGrenade { get => isGrenade; set => isGrenade = value; }
public bool HasBeenThrown { get => hasBeenThrown; set => hasBeenThrown = value; }
public float ExplosionForce { get => explosionForce; set => explosionForce = value; }
public float DropForce { get => dropForce; set => dropForce = value; }
private void Start()
{
private void Start() {
CurrentAmmunition = MagazinSize;
if (weaponKind == weaponKinds.Grenade) { IsGrenade = true; }
if (IsGrenade) { weaponKind = weaponKinds.Grenade; }
}
}