YLMagicCircleBomb.cs 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. using Adon.Game.BO;
  2. using Adon.Game.Helper;
  3. using System.Collections;
  4. using System.Collections.Generic;
  5. using UnityEngine;
  6. namespace AdonGameKit
  7. {
  8. /// <summary>
  9. /// 言灵法阵爆炸
  10. /// </summary>
  11. public class YLMagicCircleBomb : MonoBehaviour
  12. {
  13. /// <summary>
  14. /// 爆炸范围
  15. /// </summary>
  16. public float m_AttackSight = 3;
  17. /// <summary>
  18. /// 爆炸角度
  19. /// </summary>
  20. public float m_AttackAngle = 360;
  21. public BaseYLPartAdon m_YL;//释放者挂件(言灵)
  22. public BaseHero m_Hero;
  23. public Transform m_BombEff;
  24. public float m_FireTimeMax = 1;
  25. public string m_CurUseSkill;
  26. float fireTime;
  27. bool isFire;
  28. void Awake()
  29. {
  30. fireTime = m_FireTimeMax;
  31. }
  32. // Start is called before the first frame update
  33. void Start()
  34. {
  35. gameObject.GetComponentInChildren<FBXEventYL>().SetOwner(this.gameObject);
  36. }
  37. private void Update()
  38. {
  39. if (isFire)
  40. {
  41. //计时,周期发送伤害
  42. if (fireTime >= m_FireTimeMax)
  43. {
  44. fireTime = 0;
  45. ///检测范围内的怪
  46. List<GameObject> monsters = PlayerHelperAdon.GetNearMonsters(m_AttackSight, m_AttackAngle, gameObject);
  47. for (int i = 0; i < monsters.Count; i++)
  48. {
  49. BaseMonsterAdon monster = monsters[i].GetComponent<BaseMonsterAdon>();
  50. //X2Battle.X2BattleManager.Instance.mBulletModel.OnCastSkill(
  51. // m_Hero.mData.UID, m_CurUseSkill,
  52. // false, m_YL.M_YLType, monster.mData.UID, false);
  53. BulletMessage.catSkillFun(m_Hero.mData.UID, m_CurUseSkill,
  54. false, (int)m_YL.M_YLType, monster.mData.UID, false);
  55. //实例化克隆爆炸光效
  56. Transform effobj = Instantiate(m_BombEff);
  57. effobj.position = monster.m_HitObj.position;//设置爆炸位置
  58. effobj.gameObject.SetActive(true);
  59. effobj.gameObject.AddComponent<DestroyObjectDelayed>();
  60. }
  61. }
  62. fireTime += Time.deltaTime;
  63. }
  64. }
  65. public void SetHero(BaseHero _hero)
  66. {
  67. m_Hero = _hero;
  68. }
  69. public void SetBombEff(Transform _bombEff)
  70. {
  71. m_BombEff = _bombEff;
  72. }
  73. /// <summary>
  74. /// 攻击触发
  75. /// </summary>
  76. /// <param name="attackId">子连击id</param>
  77. public void OnAttackOn(string attackId)
  78. {
  79. isFire = true;
  80. }
  81. public void OnAttackOff()
  82. {
  83. isFire = false;
  84. }
  85. #if UNITY_EDITOR
  86. /// <summary>
  87. /// 绘制打击配置
  88. /// </summary>
  89. private void OnDrawGizmosSelected()
  90. {
  91. Vector3 forward = transform.forward;
  92. UnityEditor.Handles.color = new Color(1.0f, 0.0f, 0.0f, 0.1f);
  93. Vector3 rotatedForward = Quaternion.Euler(0, -m_AttackAngle * 0.5f, 0) * transform.forward;
  94. UnityEditor.Handles.DrawSolidArc(transform.position, Vector3.up, rotatedForward, m_AttackAngle, m_AttackSight);
  95. }
  96. #endif
  97. }
  98. }