using Thousandto.Code.Logic; using Thousandto.Code.Logic.WarningField; using Thousandto.Core.Asset; using Thousandto.Core.Base; using Thousandto.SkillEditor; using Thousandto.SkillEditor.DIY; using Thousandto.SkillEditor.Support; using System; using System.Collections.Generic; using System.IO; using System.Text.RegularExpressions; using UnityEditor; using UnityEngine; namespace Thousandto.SkillEditor.DIY { //飞行特效 public class EditorLockFlyVfx { public EditorEntity Target { get; private set; } public Transform TargetTrans { get; private set; } public Transform RootTrans { get; private set; } public GameObject RootGo { get; private set; } public PlayLockTrajectoryEventInfo EventInfo { get; private set; } public bool IsFinish { get; private set; } public float SprRadius { get; private set; } private float _curMoveSpeed = 0f; public EditorLockFlyVfx(GameObject vfxGo, EditorEntity target, PlayLockTrajectoryEventInfo eventInfo) { IsFinish = false; Target = target; RootGo = vfxGo; RootTrans = RootGo.transform; EventInfo = eventInfo; _curMoveSpeed = EventInfo.FlySpeed; TargetTrans = SlotUtils.GetSlotTransform(Target.RootTrans, Slot.Hit); var dir = TargetTrans.position - vfxGo.transform.position; dir = dir.normalized; RootTrans.transform.forward = dir; SprRadius = eventInfo.VfxRadius * eventInfo.VfxRadius; } public void Update(float dt) { if (IsFinish) return; _curMoveSpeed += EventInfo.FlyAddSpeed * dt; var dir = TargetTrans.position - RootTrans.position; dir = dir.normalized; RootTrans.forward = dir; RootTrans.position += dir * _curMoveSpeed * dt; if(Vector3.SqrMagnitude(RootTrans.position - TargetTrans.position) <= SprRadius) { //播放受击效果 Target.DoHitEffect(this, EventInfo.HitInfo); //碰撞到了,结束移动 Stop(); } } public void Stop() { GameObject.DestroyImmediate(RootGo); RootGo = null; IsFinish = true; } } }