1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798 |
- using System;
- using Core.Audio;
- using Core.Triiger;
- using GameLogic.Combat.CombatTool;
- using GameLogic.Combat.Hero;
- using UnityEngine;
- using UTool.CustomizeTimeLogic.FxLogic.TimeLineEventinterface;
- namespace Common.Combat.FxAILogic
- {
- [AddComponentMenu("特效脚本/弹道/直线飞行弹道")]
- public class FxAIBeelineBulletLogic : FxAILogicBasic
- {
- public float speed;
- private IUnRegister UnRegister = null;
- private Vector3 endPos;
- private Vector3 dir;
- protected override void ProInit()
- {
- UnRegister = gameObject.OnTriggerEnterEvent(OnTriggerEnterEvent);
- if (isUseCustomTargetEndPos)
- {
- endPos = TimeLineEventParticleLogicBasic.customizePos[
- customTargetEndPosIndex];
- }
- else
- {
- endPos = AttTarget.GetSpecialDotInfo("hitpos").GetWorlPos();
- }
- endPos = new Vector3(endPos.x, CurrPos.y, endPos.z);
- dir = (endPos - CurrPos).normalized;
- gameObject.transform.rotation = Quaternion.LookRotation(dir);
- }
- protected void OnTriggerEnterEvent(Collider collision)
- {
- HeroEntityMono heroEntityMono = collision.gameObject.GetComponent<HeroEntityMono>();
- if (heroEntityMono == null)
- {
- return;
- }
- CombatHeroEntity target = heroEntityMono.combatHeroEntity;
- if (target.IsEnemy == CombatHeroEntity.IsEnemy)
- {
- return;
- }
- ITimeLineTriggerEvent timeLineTriggerEvent =
- TimeLineEventParticleLogicBasic.ITimeLineTriggerEntity as ITimeLineTriggerEvent;
- if (timeLineTriggerEvent != null)
- {
- timeLineTriggerEvent.TimeLineTrigger(TimeLineEventParticleLogicBasic.TimeLineEventLogicGroup.groupName,
- target.GetMainHotPoin<ILifetCycleHitPoint>(), this, triggerData);
- if (!string.IsNullOrEmpty(hitFxName))
- {
- CombatController.currActiveCombat.GameTimeLineParticleFactory.CreateParticle(hitFxName,
- collision.ClosestPoint(gameObject.transform.position), null, false, null, null);
- }
- AudioManager.Instance.PlayAudio(hitAudioName, false);
- if (!isPenetrate)
- {
- Dispose();
- }
- }
- }
- protected override void ProCombatUpdate(float time)
- {
- Vector3 lastPos = _currPos;
- Vector3 movePos = dir * speed * time;
- _currPos += movePos;
- gameObject.transform.position = _currPos;
- if (Vector3.SqrMagnitude(_currPos - startPos) > 200)
- {
- Dispose();
- }
- }
- protected override void ProDispose()
- {
- if (UnRegister != null)
- {
- UnRegister.UnRegister();
- }
- UnRegister = null;
- }
- }
- }
|