SmokeDestroy.cs 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. public class SmokeDestroy : MonoBehaviour
  5. {
  6. public float stayTime;
  7. [HideInInspector]
  8. public float time;
  9. public float hitRate;
  10. public GameObject MissUI;
  11. private void Update()
  12. {
  13. time += Time.deltaTime;
  14. if(time >= stayTime)
  15. {
  16. gameObject.SetActive(false);
  17. }
  18. }
  19. private void OnTriggerEnter(Collider other)
  20. {
  21. AttackTrigger attackTrigger = other.GetComponent<AttackTrigger>();
  22. if (attackTrigger != null && attackTrigger.transform.parent.gameObject.layer == 8)
  23. {
  24. attackTrigger.Miss = MissUI;
  25. attackTrigger.hitRate = hitRate;
  26. return;
  27. }
  28. CharacterColliders characterColliders = other.GetComponentInParent<CharacterColliders>();
  29. if(characterColliders != null && characterColliders.owner.attackType == AttackType.Shoot)
  30. {
  31. characterColliders.smoke = gameObject;
  32. characterColliders.hitRate = hitRate;
  33. }
  34. }
  35. }