using Adon.Game.BO;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
namespace AdonGameKit
{
///
/// 2301001子弹
///
public class Bullet2301001_1 : MonoBehaviour
{
///
/// 子弹步进速度
///
public float velocity = 10f;
///
/// 生命周期
///
public float lifeTime = 5f;
float timer = 0f; // 子弹生命周期计时
public BaseMonsterAdon m_BaseMonsterAdon;
private Vector3 bulletDir = Vector3.zero;
private int skillIndex = 0;
public void SetMonster(BaseMonsterAdon monster, Vector3 dir, int _skillIndex)
{
m_BaseMonsterAdon = monster;
bulletDir = dir;
skillIndex = _skillIndex;
}
void FixedUpdate()
{
Vector3 step = bulletDir * Time.deltaTime * velocity;//子弹步进
timer += Time.deltaTime;
// 生命周期到了则销毁
if (timer >= lifeTime)
{
Destroy(gameObject);
}
transform.position += step;//向前步进
}
///
/// 武器技能触发事件
///
///
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(gameObject);
}
}
}
}