BossBulletAdon.cs 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. using Adon.Game.BO;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using UnityEngine;
  5. namespace AdonGameKit
  6. {
  7. /// <summary>
  8. /// boss子弹(boss2麻痹弹)
  9. /// </summary>
  10. public class BossBulletAdon : MonoBehaviour
  11. {
  12. /// <summary>
  13. /// 子弹步进速度
  14. /// </summary>
  15. public float velocity = 300f;
  16. /// <summary>
  17. /// 生命周期
  18. /// </summary>
  19. public float lifeTime = 5f;
  20. float timer = 0f; // 子弹生命周期计时
  21. public BaseMonsterAdon m_BaseMonsterAdon;
  22. public void SetMonster(BaseMonsterAdon monster)
  23. {
  24. m_BaseMonsterAdon = monster;
  25. }
  26. void Awake()
  27. {
  28. }
  29. // Start is called before the first frame update
  30. void Start()
  31. {
  32. }
  33. void FixedUpdate()
  34. {
  35. Vector3 step = transform.forward * Time.deltaTime * velocity;//子弹步进
  36. // 生命周期到了则销毁
  37. if (timer >= lifeTime)
  38. OnProjectileDestroy();
  39. transform.position += step;//向前步进
  40. timer += Time.deltaTime;
  41. }
  42. /// <summary>
  43. /// 子弹销毁
  44. /// </summary>
  45. void OnProjectileDestroy()
  46. {
  47. //销毁,后期改为对象池
  48. Destroy(this.gameObject);
  49. }
  50. /// <summary>
  51. /// 武器技能触发事件
  52. /// </summary>
  53. /// <param name="collision"></param>
  54. void OnTriggerEnter(Collider collision)
  55. {
  56. if (collision.gameObject.layer == LayerMask.NameToLayer("Player"))//玩家层
  57. {
  58. Debug.Log("碰撞敌人");
  59. // //Debug.Log("OnTriggerEnter:" + collision.gameObject.name);
  60. BaseHero component = collision.gameObject.GetComponent<BaseHero>();
  61. //发送战斗信息,等待后台处理逻辑返回数据
  62. //X2Battle.X2BattleManager.Instance.mBulletModel.OnCastSkill(
  63. // m_BaseMonsterAdon.mData.UID, m_BaseMonsterAdon.mData.GetSKillNormal(m_BaseMonsterAdon.m_SkillId, m_BaseMonsterAdon.m_CurAttackIdx),
  64. // false, X2Battle.EBulletCastPoint.ECAST_POINT_DEFLUAT, component.mData.UID, false);
  65. BulletMessage.catSkillFun(m_BaseMonsterAdon.mData.UID, m_BaseMonsterAdon.mData.GetSKillNormal(m_BaseMonsterAdon.m_SkillId, m_BaseMonsterAdon.m_CurAttackIdx),
  66. false, (int)X2Battle.EBulletCastPoint.ECAST_POINT_DEFLUAT, component.mData.UID, false);
  67. }
  68. }
  69. }
  70. }