1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071 |
- using Adon.Game.BO;
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- namespace AdonGameKit
- {
- /// <summary>
- /// 2301001子弹
- /// </summary>
- public class Bullet2301001_1 : MonoBehaviour
- {
- /// <summary>
- /// 子弹步进速度
- /// </summary>
- public float velocity = 10f;
- /// <summary>
- /// 生命周期
- /// </summary>
- 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;//向前步进
- }
- /// <summary>
- /// 武器技能触发事件
- /// </summary>
- /// <param name="collision"></param>
- void OnTriggerEnter(Collider collision)
- {
- if (collision.gameObject.layer == LayerMask.NameToLayer("Player"))//玩家层
- {
- Debug.Log("碰撞敌人");
- // //Debug.Log("OnTriggerEnter:" + collision.gameObject.name);
- BaseHero component = collision.gameObject.GetComponent<BaseHero>();
- //发送战斗信息,等待后台处理逻辑返回数据
- 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);
- }
- }
- }
- }
|