using UnityEngine;
using System.Collections;
using System.Collections.Generic;
namespace YLBattle
{
///
/// 技能发射阶段效果.
///
public class SkillShoot : MonoBehaviour
{
///
/// 发动方目标点列表
///
public List onsetTransforms;
///
/// 被动方目标点列表
///
public List targetTransforms;
/// 子弹光效
/// 枪口光效
public GameObject muzzleEff;
///
/// 生命周期.
///
public float lifeTime = 1f;
///
/// 消失延迟.
///
public float despawnDelay;
///
/// 子弹数量.
///
public int number;
///
/// 生成子弹频率.
///
public float projectileRate;
///
/// 投射层.
///
public LayerMask layerMask;
///
/// 发射.
///
///
///
///
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();
if (Explode == null)
{
Explode = muzzleEff.AddComponent();
}
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);
}
}
}