123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100 |
- using UnityEngine;
- using System.Collections;
- using System.Collections.Generic;
- namespace YLBattle
- {
- /// <summary>
- /// 技能发射阶段效果.
- /// </summary>
- public class SkillShoot : MonoBehaviour
- {
- /// <summary>
- /// 发动方目标点列表
- /// </summary>
- public List<Transform> onsetTransforms;
- /// <summary>
- /// 被动方目标点列表
- /// </summary>
- public List<Transform> targetTransforms;
- /// 子弹光效
- /// 枪口光效
- public GameObject muzzleEff;
- /// <summary>
- /// 生命周期.
- /// </summary>
- public float lifeTime = 1f;
- /// <summary>
- /// 消失延迟.
- /// </summary>
- public float despawnDelay;
- /// <summary>
- /// 子弹数量.
- /// </summary>
- public int number;
- /// <summary>
- /// 生成子弹频率.
- /// </summary>
- public float projectileRate;
- /// <summary>
- /// 投射层.
- /// </summary>
- public LayerMask layerMask;
- /// <summary>
- /// 发射.
- /// </summary>
- /// <param name="_projectileBase"></param>
- /// <param name="_targetPoint"></param>
- /// <param name="_targetTransform"></param>
- public void Shoot(ProjectileBase _projectileBase,
- Vector3 _targetPoint,
- Transform _targetTransform)
- {
- GameObject projectileEff = _projectileBase.gameObject;
- BulletLoadParam bulletLoadParam = _projectileBase.bulletLoadParam;
- Fighter temp = FightingManager.Instance.GetFighter(bulletLoadParam.uid);//发起者
- float velocity = bulletLoadParam.speed;
- layerMask.value = LayerMask.NameToLayer("UI");
- projectileEff.SetActive(true);
- Vector3 shoopPos = temp.mBodyCenterPos;
- #region 生成枪口特效
- ResourceHelper.Instance.LoadAssetBundle(bulletLoadParam.res + "_shoot", ab =>
- {
- if (ab != null)
- {
- //获取枪口坐标
- GameObject muzzleEff = (GameObject)Instantiate(ab.LoadAsset(bulletLoadParam.res + "_shoot"), shoopPos, Quaternion.identity);
- muzzleEff.transform.SetParent(transform);
- //枪口光效脚本
- ShootBase Explode = muzzleEff.GetComponent<ShootBase>();
- if (Explode == null)
- {
- Explode = muzzleEff.AddComponent<ShootBase>();
- }
- SkillControl.Instance.TranformHandle(muzzleEff.transform, shoopPos);
- AudioManager.Instance.PlaySkillSoundEffect(bulletLoadParam.audio[0]);
- }
- else
- {
- LogHelper.LogWarning("子弹枪口模版数据有误!!! " + bulletLoadParam.tid);
- }
- });
- #endregion
- AudioManager.Instance.PlaySkillSoundEffect(bulletLoadParam.audio[1]);
- _projectileBase.init(temp.transform.position, _targetPoint, _targetTransform, layerMask, lifeTime, velocity);
- }
- }
- }
|