tpsGunData.cs 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. using HQFPSWeapons;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using UnityEngine;
  5. public class tpsGunData : MonoBehaviour
  6. {
  7. public string weaponName;
  8. public Transform holding_rightHandPosition;
  9. public Transform aiming_rightHandPosition;
  10. public Transform leftHandPosition;
  11. public Transform headTarget;
  12. [Header("Shooting Properties")]
  13. public GameObject tracerPref;
  14. public GameObject muzzleFlashPref;
  15. public Transform weaponTip;
  16. public Light muzzleLight;
  17. public float muzzleLightIntensity = 0;
  18. public float muzzleLightMaxIntensity = 2;
  19. private void Update()
  20. {
  21. muzzleLight.intensity = muzzleLightIntensity;
  22. if(muzzleLightIntensity > 0)
  23. {
  24. muzzleLightIntensity -= 0.1f;
  25. }
  26. }
  27. public void triggerMuzzleFlash()
  28. {
  29. muzzleLightIntensity = muzzleLightMaxIntensity;
  30. if (tracerPref != null)
  31. {
  32. PoolableObject tracer = PoolingManager.Instance.GetObject(
  33. tracerPref,
  34. weaponTip.position,
  35. weaponTip.rotation
  36. );
  37. }
  38. if (muzzleFlashPref != null)
  39. {
  40. Quaternion muzzleFlashRot = Quaternion.Euler(new Vector3(
  41. Random.Range(0, 180),
  42. Random.Range(0, 180),
  43. Random.Range(0, 180)));
  44. PoolableObject muzzleFlash = PoolingManager.Instance.GetObject(
  45. muzzleFlashPref,
  46. weaponTip.position,
  47. muzzleFlashRot
  48. );
  49. }
  50. // foreach (GameObject go in muzzleFlash)
  51. // {
  52. // go.SetActive(true);
  53. // }
  54. // StartCoroutine(disableMuzzleFlashAfterTime(2));
  55. }
  56. IEnumerator disableMuzzleFlashAfterTime(float timeInSeconds)
  57. {
  58. yield return new WaitForSeconds(timeInSeconds);
  59. // foreach (GameObject go in muzzleFlash)
  60. // {
  61. // go.SetActive(false);
  62. // }
  63. }
  64. }