SkillShoot.cs 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. using UnityEngine;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. namespace YLBattle
  5. {
  6. /// <summary>
  7. /// 技能发射阶段效果.
  8. /// </summary>
  9. public class SkillShoot : MonoBehaviour
  10. {
  11. /// <summary>
  12. /// 发动方目标点列表
  13. /// </summary>
  14. public List<Transform> onsetTransforms;
  15. /// <summary>
  16. /// 被动方目标点列表
  17. /// </summary>
  18. public List<Transform> targetTransforms;
  19. /// 子弹光效
  20. /// 枪口光效
  21. public GameObject muzzleEff;
  22. /// <summary>
  23. /// 生命周期.
  24. /// </summary>
  25. public float lifeTime = 1f;
  26. /// <summary>
  27. /// 消失延迟.
  28. /// </summary>
  29. public float despawnDelay;
  30. /// <summary>
  31. /// 子弹数量.
  32. /// </summary>
  33. public int number;
  34. /// <summary>
  35. /// 生成子弹频率.
  36. /// </summary>
  37. public float projectileRate;
  38. /// <summary>
  39. /// 投射层.
  40. /// </summary>
  41. public LayerMask layerMask;
  42. /// <summary>
  43. /// 发射.
  44. /// </summary>
  45. /// <param name="_projectileBase"></param>
  46. /// <param name="_targetPoint"></param>
  47. /// <param name="_targetTransform"></param>
  48. public void Shoot(ProjectileBase _projectileBase,
  49. Vector3 _targetPoint,
  50. Transform _targetTransform)
  51. {
  52. GameObject projectileEff = _projectileBase.gameObject;
  53. BulletLoadParam bulletLoadParam = _projectileBase.bulletLoadParam;
  54. Fighter temp = FightingManager.Instance.GetFighter(bulletLoadParam.uid);//发起者
  55. float velocity = bulletLoadParam.speed;
  56. layerMask.value = LayerMask.NameToLayer("UI");
  57. projectileEff.SetActive(true);
  58. Vector3 shoopPos = temp.mBodyCenterPos;
  59. #region 生成枪口特效
  60. ResourceHelper.Instance.LoadAssetBundle(bulletLoadParam.res + "_shoot", ab =>
  61. {
  62. if (ab != null)
  63. {
  64. //获取枪口坐标
  65. GameObject muzzleEff = (GameObject)Instantiate(ab.LoadAsset(bulletLoadParam.res + "_shoot"), shoopPos, Quaternion.identity);
  66. muzzleEff.transform.SetParent(transform);
  67. //枪口光效脚本
  68. ShootBase Explode = muzzleEff.GetComponent<ShootBase>();
  69. if (Explode == null)
  70. {
  71. Explode = muzzleEff.AddComponent<ShootBase>();
  72. }
  73. SkillControl.Instance.TranformHandle(muzzleEff.transform, shoopPos);
  74. AudioManager.Instance.PlaySkillSoundEffect(bulletLoadParam.audio[0]);
  75. }
  76. else
  77. {
  78. LogHelper.LogWarning("子弹枪口模版数据有误!!! " + bulletLoadParam.tid);
  79. }
  80. });
  81. #endregion
  82. AudioManager.Instance.PlaySkillSoundEffect(bulletLoadParam.audio[1]);
  83. _projectileBase.init(temp.transform.position, _targetPoint, _targetTransform, layerMask, lifeTime, velocity);
  84. }
  85. }
  86. }