ItemBaseFirearm.cs 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using Sirenix.OdinInspector;
  5. using KairoEngine.SFX;
  6. namespace KairoEngine.Inventory
  7. {
  8. public enum FirearmType
  9. {
  10. pistol,
  11. rifle
  12. }
  13. [CreateAssetMenu(fileName = "Item", menuName = "KairoEngine/Items/Weapon Item", order = 3)]
  14. public class ItemBaseFirearm : ItemBaseHoldable
  15. {
  16. [TitleGroup("Weapon Properties")]
  17. public FirearmType firearmType;
  18. [TitleGroup("Weapon Properties")]
  19. public int damage = 1;
  20. [TitleGroup("Weapon Properties")]
  21. public bool isAutomatic = false;
  22. [TitleGroup("Weapon Properties"), SuffixLabel("shoots", true)]
  23. public int burstFire = 1;
  24. [TitleGroup("Weapon Properties"), SuffixLabel("seconds", true)]
  25. public float firingSpeed = 0.2f;
  26. [TitleGroup("Weapon Properties"), SuffixLabel("seconds", true)]
  27. public float reloadSpeed = 1.5f;
  28. [TitleGroup("Weapon Properties")]
  29. public ItemBaseAmmo ammoType;
  30. [TitleGroup("Weapon Properties")]
  31. public int ammoCapacity;
  32. [TitleGroup("Weapon Properties")]
  33. public int bulletsPerShot = 1;
  34. [Tooltip("Weapon acuracy ranges perfect accuracy at 100% to total random directions at 0%")]
  35. [TitleGroup("Weapon Properties"), Range(0, 100), SuffixLabel("%", true)]
  36. public float accuracy;
  37. [Tooltip("Adds this percentage to the critial hit chance at each bullet hit")]
  38. [TitleGroup("Weapon Properties"), Range(0, 100), SuffixLabel("%", true)]
  39. public float criticalChanceModifier = 3f;
  40. [TitleGroup("Weapon Properties"), LabelText("Point Blank distance"), SuffixLabel("min", true)]
  41. public float minDistance = 1.5f;
  42. [TitleGroup("Weapon Properties"), LabelText("Half distance"), SuffixLabel("half", true)]
  43. public float halfDistance = 12f;
  44. [TitleGroup("Weapon Properties"), LabelText("Max travel distance"), SuffixLabel("max", true)]
  45. public float maxDistance = 20f;
  46. [TitleGroup("Weapon Properties")]
  47. public SFXClip shootSound;
  48. [TitleGroup("Weapon Properties")]
  49. public SFXClip emptySound;
  50. [TitleGroup("Weapon Properties")]
  51. public SFXClip reloadSound;
  52. public int CalculateDamage(ItemFirearmRef firearmRef, Vector3 firearmPos, Vector3 impactPos)
  53. {
  54. return damage + ammoType.damageModifier;
  55. }
  56. public float Accuracy(ItemFirearmRef firearmRef)
  57. {
  58. return accuracy + ammoType.accuracyModifier;
  59. }
  60. }
  61. }