123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869 |
- using Adon.Game.BO;
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- namespace AdonGameKit
- {
- /// <summary>
- /// 2301001子弹(抛物线)
- /// </summary>
- public class Bullet2301001_2 : MonoBehaviour
- {
- public BaseMonsterAdon m_BaseMonsterAdon;
- private Vector3 bulletDir = Vector3.zero;
- private int skillIndex = 0;
- public float speed = 10;
- private float distanceToTarget;
- private Vector3 targetPos;
- public void SetMonster(BaseMonsterAdon monster, Vector3 dir, int _skillIndex, Vector3 _targetPos)
- {
- m_BaseMonsterAdon = monster;
- bulletDir = dir;
- skillIndex = _skillIndex;
- targetPos = _targetPos;
- distanceToTarget = Vector3.Distance(this.transform.position, targetPos);
- }
- void FixedUpdate()
- {
- this.transform.LookAt(targetPos);
- float angle = Mathf.Min(1, Vector3.Distance(this.transform.position, targetPos) / distanceToTarget) * 45;
- this.transform.rotation = this.transform.rotation * Quaternion.Euler(Mathf.Clamp(-angle, -45, 45), 0, 0);
- float currentDist = Vector3.Distance(this.transform.position, targetPos);
- if (currentDist < 0.5f)
- {
- // 爆炸特效
- GameObject effObj = Instantiate(m_BaseMonsterAdon.transform.Find("FBX/Effect_000/Bomb/Monster_Bomb2").gameObject, transform.position, Quaternion.identity);
- effObj.SetActive(true);
- Destroy(effObj, 2.0f);
- Destroy(gameObject);
- }
- this.transform.Translate(Vector3.forward * Mathf.Min(speed * Time.deltaTime, currentDist));
- }
- /// <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);
- }
- }
- }
- }
|