FxManagerAdon.cs 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. public class FxManagerAdon : MonoBehaviour
  5. {
  6. /// <summary>
  7. /// 攻击释放特效数组
  8. /// </summary>
  9. public Transform[] m_AttackEff;
  10. /// <summary>
  11. /// 攻击弹道特效数组
  12. /// </summary>
  13. public Transform[] m_TrajectEff;
  14. /// <summary>
  15. /// 攻击爆炸特效数组
  16. /// </summary>
  17. public Transform[] m_BombEff;
  18. /// <summary>
  19. /// 被击特效数组
  20. /// </summary>
  21. public Transform[] m_AttackedEff;
  22. /// <summary>
  23. /// 极限闪避提示光效
  24. /// </summary>
  25. public Transform m_ExtermePointEff;
  26. /// <summary>
  27. /// 死亡光效
  28. /// </summary>
  29. public Transform[] m_DieEffs;
  30. /// <summary>
  31. /// 眩晕光效
  32. /// </summary>
  33. public Transform m_DizzEff;
  34. // Start is called before the first frame update
  35. private void Awake()
  36. {
  37. //获取攻击特效对象
  38. Transform OBJ = transform.Find("FBX/Effect_000/Attacks");
  39. if(OBJ)
  40. {
  41. m_AttackEff = new Transform[OBJ.childCount];
  42. for (int i = 0; i < OBJ.childCount; i++)
  43. {
  44. m_AttackEff[i] = OBJ.GetChild(i);
  45. m_AttackEff[i].gameObject.SetActive(false);
  46. }
  47. }
  48. //获取弹道特效对象
  49. OBJ = transform.Find("FBX/Effect_000/Traject");
  50. if (OBJ)
  51. {
  52. m_TrajectEff = new Transform[OBJ.childCount];
  53. for (int i = 0; i < OBJ.childCount; i++)
  54. {
  55. m_TrajectEff[i] = OBJ.GetChild(i);
  56. m_TrajectEff[i].gameObject.SetActive(false);
  57. }
  58. }
  59. //获取爆炸特效对象
  60. OBJ = transform.Find("FBX/Effect_000/Bomb");
  61. if(OBJ)
  62. {
  63. m_BombEff = new Transform[OBJ.childCount];
  64. for (int i = 0; i < OBJ.childCount; i++)
  65. {
  66. m_BombEff[i] = OBJ.GetChild(i);
  67. m_BombEff[i].gameObject.SetActive(false);
  68. }
  69. }
  70. //获取被击特效对象
  71. OBJ = transform.Find("FBX/Effect_000/Attackeds");
  72. if(OBJ)
  73. {
  74. m_AttackedEff = new Transform[OBJ.childCount];
  75. for (int i = 0; i < OBJ.childCount; i++)
  76. {
  77. m_AttackedEff[i] = OBJ.GetChild(i);
  78. m_AttackedEff[i].gameObject.SetActive(false);
  79. }
  80. }
  81. //获取死亡特效对象
  82. OBJ = transform.Find("FBX/Effect_000/Die");
  83. if(OBJ)
  84. {
  85. m_DieEffs = new Transform[OBJ.childCount];
  86. for (int i = 0; i < OBJ.childCount; i++)
  87. {
  88. m_DieEffs[i] = OBJ.GetChild(i);
  89. m_DieEffs[i].gameObject.SetActive(false);
  90. }
  91. }
  92. m_DizzEff = transform.Find("FBX/Effect_ZhongXin/buff_801028");
  93. m_ExtermePointEff = transform.Find("FBX/Effect_000/ExtermePointEff");
  94. if(m_ExtermePointEff != null) m_ExtermePointEff.gameObject.SetActive(false);
  95. }
  96. void Start()
  97. {
  98. }
  99. /// <summary>
  100. /// 播放攻击特效
  101. /// </summary>
  102. /// <returns>特效对象.</returns>
  103. /// <param name="effId">特效id.</param>
  104. /// <param name="position">特效位置.</param>
  105. /// <param name="dir">角度.</param>
  106. /// <param name="lifeTimeMax">生命周期.</param>
  107. /// <param name="effT">特效类型.</param>
  108. public GameObject PlayAttackEff(int effId,bool bFollowing = false,Transform effParent = null)
  109. {
  110. GameObject effObj = m_AttackEff[effId].gameObject;//发出特效
  111. effObj.SetActive(true);//启用
  112. if (bFollowing)//跟随
  113. {
  114. effObj.transform.parent = effParent;
  115. }
  116. return effObj;
  117. }
  118. public void StopAttackEff(int effId)
  119. {
  120. GameObject effObj = m_AttackEff[effId].gameObject;//发出特效
  121. effObj.SetActive(false);//发送启用事件
  122. }
  123. /// <summary>
  124. /// 播放受击特效
  125. /// </summary>
  126. /// <returns>特效对象.</returns>
  127. /// <param name="effId">特效id.</param>
  128. /// <param name="position">特效位置.</param>
  129. /// <param name="dir">角度.</param>
  130. /// <param name="lifeTimeMax">生命周期.</param>
  131. /// <param name="effT">特效类型.</param>
  132. public GameObject PlayAttackedEff(int effId, bool bFollowing = false, Transform effParent = null)
  133. {
  134. if(m_AttackedEff == null)
  135. {
  136. return null;
  137. }
  138. //发出特效
  139. GameObject effObj = Instantiate(m_AttackedEff[effId].gameObject);
  140. effObj.SetActive(true);//发送启用事件
  141. if (bFollowing)//跟随
  142. {
  143. effObj.transform.parent = effParent;
  144. effObj.transform.localPosition = Vector3.zero;
  145. }
  146. return effObj;
  147. }
  148. /// <summary>
  149. /// 播放死亡特效
  150. /// </summary>
  151. /// <returns>特效对象.</returns>
  152. /// <param name="effId">特效id.</param>
  153. /// <param name="position">特效位置.</param>
  154. /// <param name="dir">角度.</param>
  155. /// <param name="lifeTimeMax">生命周期.</param>
  156. /// <param name="effT">特效类型.</param>
  157. public GameObject PlayDieEff(int effId, bool bFollowing = false, Transform effParent = null)
  158. {
  159. //发出特效
  160. GameObject effObj = Instantiate(m_DieEffs[effId].gameObject);
  161. effObj.SetActive(true);//发送启用事件
  162. if (bFollowing)//跟随
  163. {
  164. effObj.transform.parent = effParent;
  165. effObj.transform.localPosition = Vector3.zero;
  166. }
  167. else
  168. {
  169. effObj.transform.position = effParent.position;
  170. }
  171. return effObj;
  172. }
  173. public void StopAttackedEff(int effId)
  174. {
  175. GameObject effObj = m_AttackEff[effId].gameObject;//发出特效
  176. effObj.SetActive(false);//发送启用事件
  177. }
  178. /// <summary>
  179. /// 播放极限闪避提示特效
  180. /// </summary>
  181. public void PlayExtermePointEff()
  182. {
  183. m_ExtermePointEff.gameObject.SetActive(false);
  184. m_ExtermePointEff.gameObject.SetActive(true);//发送启用
  185. //StartCoroutine(playExtermePointEff());
  186. }
  187. }