using Adon.Game.BO;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
namespace AdonGameKit
{
///
/// 2501001 激光子弹
///
public class Bullet2501001_1 : MonoBehaviour
{
///
/// 子弹步进速度
///
public float velocity = 5;
///
/// 生命周期
///
public float lifeTime = 5f;
public BaseMonsterAdon m_BaseMonsterAdon;
private Vector3 bulletPos = Vector3.zero;
private Transform bulletLine = null;
private int skillIndex = 0;
private bool run = false;
private float bulletVal = 0;
public void SetMonster(BaseMonsterAdon monster, Transform _bulletLine, Vector3 pos, int _skillIndex)
{
m_BaseMonsterAdon = monster;
bulletLine = _bulletLine;
bulletPos = pos;
bulletPos.y = bulletLine.position.y;
skillIndex = _skillIndex;
run = true;
bulletVal = 0;
}
void FixedUpdate()
{
if (run == false)
{
return;
}
bulletVal += Time.deltaTime * 4;
if (bulletVal <= 1.0f)
{
transform.position = Vector3.Lerp(m_BaseMonsterAdon.transform.position, bulletPos, bulletVal);
float dis = Vector3.Distance(m_BaseMonsterAdon.transform.position, transform.position);
bulletLine.localScale = new Vector3(1, 1, dis);
}
else
{
Destroy(transform.parent.gameObject);
}
}
///
/// 武器技能触发事件
///
///
void OnTriggerEnter(Collider collision)
{
if (collision.gameObject.layer == LayerMask.NameToLayer("Player"))//玩家层
{
Debug.Log("碰撞敌人");
// //Debug.Log("OnTriggerEnter:" + collision.gameObject.name);
BaseHero component = collision.gameObject.GetComponent();
//发送战斗信息,等待后台处理逻辑返回数据
BulletMessage.catSkillFun(m_BaseMonsterAdon.mData.UID, m_BaseMonsterAdon.mData.GetSKillNormal(skillIndex, 1),
false, (int)X2Battle.EBulletCastPoint.ECAST_POINT_DEFLUAT, component.mData.UID, false);
Destroy(transform.parent.gameObject);
}
}
}
}