SceneEventSunkensLogic.cs 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using UnityEngine.UI;
  5. using UnityGameFramework.Runtime;
  6. /// <summary>
  7. /// 场景组件 地刺
  8. /// </summary>
  9. public class SceneEventSunkensLogic : MonoBehaviour
  10. {
  11. public int hurtHP = 0;
  12. public float hurtTime = 2;
  13. private float nowTime = 0;
  14. private float animTime = 1;
  15. private bool isHurt = false;
  16. private Animator anim;
  17. private Role player;
  18. private void Awake()
  19. {
  20. anim = this.GetComponent<Animator>();
  21. }
  22. // Start is called before the first frame update
  23. void Start()
  24. {
  25. SceneCmptManager.Instance.AddMechanism(this.gameObject);
  26. SceneEventSunkens info = this.gameObject.GetComponent<SceneEventSunkens>();
  27. this.hurtHP = info.hurtHP;
  28. this.hurtTime = info.hurtTime;
  29. }
  30. private void Update()
  31. {
  32. nowTime += Time.deltaTime;
  33. if (nowTime > hurtTime)
  34. {
  35. nowTime -= hurtTime;
  36. Animator anim = this.GetComponent<Animator>();
  37. anim.Play("running2", 0, 0);
  38. }
  39. }
  40. public void Hurt()
  41. {
  42. if (!player || player.isDie || !player.IsTeamLeader)
  43. {
  44. return;
  45. }
  46. X2Battle.X2BattleManager.Instance.mBulletModel.OnCastSkill(
  47. 0, "702002",
  48. false, X2Battle.EBulletCastPoint.ECAST_POINT_DEFLUAT, player.mData.UID, false);
  49. }
  50. public void CloseHurt()
  51. {
  52. isHurt = false;
  53. }
  54. public void OnTriggerEnter(Collider collider)
  55. {
  56. Role role = collider.GetComponent<Role>();
  57. if (role != null && role.IsTeamLeader)
  58. {
  59. player = collider.GetComponent<Role>();
  60. SceneCmptManager.Instance.OpenMechanism(this.gameObject);
  61. }
  62. }
  63. public void OnTriggerStay(Collider other)
  64. {
  65. }
  66. public void OnTriggerExit(Collider collider)
  67. {
  68. Role role = collider.GetComponent<Role>();
  69. if (role != null && role.IsTeamLeader)
  70. {
  71. player = null;
  72. }
  73. }
  74. public void EnableCollider()
  75. {
  76. }
  77. public void OnClickInteractive()
  78. {
  79. }
  80. }