started building logics for enemy
This commit is contained in:
@@ -6,7 +6,7 @@ using VContainer;
|
||||
|
||||
namespace Darkmatter.Presentation
|
||||
{
|
||||
public class GunWeapon : WeaponBase
|
||||
public class GunWeapon : MonoBehaviour, IReloadableWeapon
|
||||
{
|
||||
[Header("VFX")]
|
||||
public ParticleSystem MuzzleFlashParticle;
|
||||
@@ -14,24 +14,21 @@ namespace Darkmatter.Presentation
|
||||
|
||||
[Header("Weapon Data")]
|
||||
public float fireRate = 0.1f;
|
||||
[SerializeField] private int ammoCount = 40;
|
||||
public bool isReloading { get; set; }
|
||||
public int AmmoCount { get; set; } = 40;
|
||||
public int initialAmmoCount { get; set; } = 40;
|
||||
private float lastUsedTime;
|
||||
public GameObject BulletHole;
|
||||
public override string WeaponName => "Rifel";
|
||||
public override int AmmoCount { get => this.ammoCount; set => ammoCount = value; }
|
||||
|
||||
|
||||
public override bool canAttack => Time.time >= lastUsedTime + fireRate && ammoCount > 0;
|
||||
public bool canAttack => Time.time >= lastUsedTime + fireRate && AmmoCount > 0 && !isReloading;
|
||||
|
||||
[Inject] private ITargetProvider targetProvider;
|
||||
private RaycastHit hitPoint => targetProvider.hitPoint;
|
||||
|
||||
|
||||
|
||||
public override void Attack()
|
||||
public void Attack()
|
||||
{
|
||||
lastUsedTime = Time.time;
|
||||
ammoCount--;
|
||||
AmmoCount--;
|
||||
|
||||
PlayMuzzleFlash();
|
||||
if (hitPoint.transform != null) PlayBulletHitEffectParticle();
|
||||
@@ -55,14 +52,13 @@ namespace Darkmatter.Presentation
|
||||
|
||||
BulletHitEffectParticle.transform.position = spawnPos;
|
||||
BulletHitEffectParticle.transform.rotation = Quaternion.LookRotation(hitPoint.normal);
|
||||
|
||||
|
||||
BulletHitEffectParticle.Play(true);
|
||||
}
|
||||
|
||||
public override void Reload()
|
||||
public void Reload()
|
||||
{
|
||||
base.Reload();
|
||||
ammoCount = maxAmmoCount;
|
||||
AmmoCount = initialAmmoCount;
|
||||
}
|
||||
|
||||
private void PlayMuzzleFlash()
|
||||
|
||||
Reference in New Issue
Block a user