12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394 |
- using System;
- using Core.Triiger;
- using GameLogic.Combat.CombatTool;
- using GameLogic.Combat.Hero;
- using UnityEngine;
- using UTool.CustomizeTimeLogic.FxLogic.TimeLineEventinterface;
- namespace Common.Combat.FxAILogic
- {
- 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);
- }
- 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;
- }
- }
- }
|