123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176 |
- using System.Collections.Generic;
- using Core.Audio;
- using Core.Triiger;
- using Core.Utility;
- using GameLogic.Combat.CombatTool;
- using GameLogic.Combat.Hero;
- using UnityEngine;
- using UTool.CustomizeTimeLogic.FxLogic.TimeLineEventinterface;
- namespace Common.Combat.FxAILogic
- {
- [AddComponentMenu("特效脚本/弹道/功法通用弹道")]
- public class FxParabolaBulletLogic : FxAILogicBasic
- {
- public float speed;
- private IUnRegister UnRegister = null;
- [Header("释放碰撞到地面时结束")] public bool isTriggerGroundEnd;
- [Header("碰撞到地面时的特效")] public string GroundHitFxName;
- private Vector3 endPos;
- private Vector3 dir;
- public float maxDis = 20;
- protected float maxDisSpr;
- private BesselPath _besselPath;
- private float _addTime;
- protected override void ProInit()
- {
- maxDisSpr = maxDis * maxDis;
- 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);
- }
- if (_besselPath == null)
- {
- _besselPath = new BesselPath();
- }
- Vector3 CrossNormalized = Vector3.Cross(CurrPos, endPos).normalized;
- CrossNormalized = new Vector3(CrossNormalized.x, 0, CrossNormalized.z);
- Vector3 pos2 = (endPos - CurrPos) * 0.5f + CurrPos + CrossNormalized * Random.Range(-15,15);
- List<Vector3> PosList = new List<Vector3>();
- PosList.Add(CurrPos);
- PosList.Add(pos2);
- PosList.Add(endPos);
- _besselPath.SetPos(PosList);
- float d = _besselPath.GetPathCount(10);
- _addTime = 1.0f / (d / speed);
- // dir = (endPos - CurrPos).normalized;
- // gameObject.transform.rotation = Quaternion.LookRotation(dir);
- }
- void TriggerGround()
- {
- ITimeLineTriggerEvent timeLineTriggerEvent =
- TimeLineEventParticleLogicBasic.ITimeLineTriggerEntity as ITimeLineTriggerEvent;
- FinishHit(new Vector3(_currPos.x, 0.5f, _currPos.z), GroundHitFxName);
- AudioManager.Instance.PlayAudio(hitAudioName, false);
- if (timeLineTriggerEvent != null)
- {
- timeLineTriggerEvent.TimeLineTriggerGround(
- TimeLineEventParticleLogicBasic.TimeLineEventLogicGroup.groupName,
- this, triggerData);
- }
- AudioManager.Instance.PlayAudio(hitAudioName, false);
- Dispose();
- }
- protected void OnTriggerEnterEvent(Collider collision)
- {
- ITimeLineTriggerEvent timeLineTriggerEvent =
- TimeLineEventParticleLogicBasic.ITimeLineTriggerEntity as ITimeLineTriggerEvent;
- if (isTriggerGroundEnd)
- {
- if (collision.gameObject.CompareTag("dimian"))
- {
- TriggerGround();
- return;
- }
- }
- HeroEntityMono heroEntityMono = collision.gameObject.GetComponent<HeroEntityMono>();
- if (heroEntityMono == null)
- {
- return;
- }
- CombatHeroEntity target = heroEntityMono.combatHeroEntity;
- if (target.IsEnemy == CombatHeroEntity.IsEnemy)
- {
- return;
- }
- if (timeLineTriggerEvent != null)
- {
- timeLineTriggerEvent.TimeLineTrigger(TimeLineEventParticleLogicBasic.TimeLineEventLogicGroup.groupName,
- target.GetMainHotPoin<ILifetCycleHitPoint>(), this, triggerData);
- if (!string.IsNullOrEmpty(hitFxName))
- {
- FinishHit(collision.ClosestPoint(gameObject.transform.position), hitFxName);
- }
- AudioManager.Instance.PlayAudio(hitAudioName, false);
- if (!isPenetrate)
- {
- Dispose();
- }
- }
- }
- private void FinishHit(Vector3 pos, string hitFxName)
- {
- if (!string.IsNullOrEmpty(hitFxName))
- {
- CombatController.currActiveCombat.GameTimeLineParticleFactory.CreateParticle(hitFxName,
- pos, null, false, null, null);
- }
- }
- protected override void ProCombatUpdate(float time)
- {
- currTime += _addTime * time;
- Vector3 movePos = _besselPath.GetValue(currTime);
- Vector3 dir = (movePos - _currPos).normalized;
- _currPos = movePos;
- gameObject.transform.position = _currPos;
- if (currTime >= 1)
- {
- Dispose();
- }
- // if (!isTriggerGroundEnd)
- // {
- // if (Vector3.SqrMagnitude(_currPos - startPos) > maxDisSpr)
- // {
- // Dispose();
- // }
- // }
- // else
- // {
- // if (_currPos.y < 0.3f)
- // {
- // TriggerGround();
- // }
- // }
- }
- protected override void ProDispose()
- {
- if (UnRegister != null)
- {
- UnRegister.UnRegister();
- }
- UnRegister = null;
- }
- }
- }
|