44 lines
1.2 KiB
C#
44 lines
1.2 KiB
C#
using HurricaneVR.Framework.Weapons;
|
|
using UnityEngine;
|
|
|
|
namespace Zero
|
|
{
|
|
public class ExtGunShotgun : ExtGunBase
|
|
{
|
|
[Header("Shotgun Settings")]
|
|
public int NumberOfPellets = 5;
|
|
public float ShotRadius = 0.05f;
|
|
|
|
[SerializeField] private ShotgunReload shotgunReload;
|
|
|
|
protected override void Awake()
|
|
{
|
|
base.Awake();
|
|
Ammo = GetComponent<HVRShotgunMagazine>();
|
|
}
|
|
|
|
protected override bool CanFire()
|
|
{
|
|
return base.CanFire() && shotgunReload.IsPrepareToShoot;
|
|
}
|
|
|
|
protected override void OnFire(Vector3 direction)
|
|
{
|
|
for (int i = 0; i < NumberOfPellets; i++)
|
|
{
|
|
var xy = Random.insideUnitCircle * ShotRadius;
|
|
var newDirection = direction + transform.TransformDirection(xy);
|
|
FireBullet(newDirection);
|
|
}
|
|
}
|
|
|
|
protected override void OnCockingHandleEjected()
|
|
{
|
|
base.OnCockingHandleEjected();
|
|
if (ChamberedCasing && ChamberedCasing.activeSelf)
|
|
{
|
|
EjectCasing();
|
|
}
|
|
}
|
|
}
|
|
} |