1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283 |
- using Adon.Game.BO;
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- namespace AdonGameKit
- {
- /// <summary>
- /// 2501001 激光子弹
- /// </summary>
- public class Bullet2501001_1 : MonoBehaviour
- {
- /// <summary>
- /// 子弹步进速度
- /// </summary>
- public float velocity = 5;
- /// <summary>
- /// 生命周期
- /// </summary>
- 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);
- }
- }
- /// <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(transform.parent.gameObject);
- }
- }
- }
- }
|