separated weapon class left to separate logic and implementation
This commit is contained in:
54
Assets/Darkmatter/Code/Presentation/Weapons/GunWeapon.cs
Normal file
54
Assets/Darkmatter/Code/Presentation/Weapons/GunWeapon.cs
Normal file
@@ -0,0 +1,54 @@
|
||||
using Darkmatter.Core;
|
||||
using Darkmatter.Domain;
|
||||
using UnityEngine;
|
||||
using VContainer;
|
||||
|
||||
namespace Darkmatter.Presentation
|
||||
{
|
||||
public class GunWeapon : WeaponBase
|
||||
{
|
||||
[Header("VFX")]
|
||||
public ParticleSystem MuzzleFlashParticle;
|
||||
public ParticleSystem BulletHitEffectParticle;
|
||||
|
||||
[Header("Weapon Data")]
|
||||
public float fireRate = 1f;
|
||||
public int ammoCount = 40;
|
||||
private float lastUsedTime;
|
||||
public override string WeaponName => "Rifel";
|
||||
|
||||
|
||||
public override bool canAttack => Time.time >= lastUsedTime + fireRate;
|
||||
|
||||
[Inject] private IAimProvider aimProvider;
|
||||
|
||||
|
||||
|
||||
public override void Attack()
|
||||
{
|
||||
lastUsedTime = Time.time;
|
||||
ammoCount--;
|
||||
PlayMuzzleFlash();
|
||||
|
||||
Vector3 startPos = transform.position;
|
||||
Vector3 direction = aimProvider.AimDir;
|
||||
|
||||
Debug.Log("Attack using Gun");
|
||||
|
||||
//use ray cast here
|
||||
|
||||
|
||||
//after ray cast use damage logic too
|
||||
}
|
||||
public override void Reload()
|
||||
{
|
||||
base.Reload();
|
||||
ammoCount = 40;
|
||||
}
|
||||
|
||||
private void PlayMuzzleFlash()
|
||||
{
|
||||
MuzzleFlashParticle.Play(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: bf22e36737a853040b18d29e45fa59ee
|
||||
Reference in New Issue
Block a user