2025-01-27 10:29:38 -05:00
|
|
|
|
using System.Collections;
|
|
|
|
|
|
using System.Collections.Generic;
|
2025-01-29 23:49:18 -05:00
|
|
|
|
using System.Linq;
|
2025-01-27 10:29:38 -05:00
|
|
|
|
using Dreamteck.Splines;
|
|
|
|
|
|
using Lean.Pool;
|
|
|
|
|
|
using UniRx;
|
|
|
|
|
|
using UnityEngine;
|
|
|
|
|
|
|
|
|
|
|
|
namespace Ichni.RhythmGame
|
|
|
|
|
|
{
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 在轨道上根据百分比进行运动的点
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public class TrackPercentPoint : BaseElement
|
|
|
|
|
|
{
|
|
|
|
|
|
public Track track;
|
|
|
|
|
|
public SplinePositioner trackPositioner;
|
|
|
|
|
|
public FlexibleFloat trackPercent;
|
2025-01-29 23:49:18 -05:00
|
|
|
|
|
|
|
|
|
|
private bool isBeyond1 = false;
|
2025-01-27 10:29:38 -05:00
|
|
|
|
|
|
|
|
|
|
public static TrackPercentPoint GenerateElement(string elementName, Track track, FlexibleFloat trackPercent)
|
|
|
|
|
|
{
|
2025-01-30 22:45:33 -05:00
|
|
|
|
TrackPercentPoint point = Instantiate(EditorManager.instance.basePrefabs.emptyObject, track.transform).AddComponent<TrackPercentPoint>();
|
2025-01-27 10:29:38 -05:00
|
|
|
|
|
|
|
|
|
|
point.NewInitialize(elementName, track, trackPercent);
|
|
|
|
|
|
point.SetParent(track);
|
|
|
|
|
|
|
2025-01-29 23:49:18 -05:00
|
|
|
|
point.isBeyond1 = trackPercent.animations.Any(animation => animation.endValue > 1);//判断是否有超过1的动画,超过1将会循环
|
|
|
|
|
|
|
2025-01-27 10:29:38 -05:00
|
|
|
|
return point;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void NewInitialize(string elementName, Track track, FlexibleFloat trackPercent)
|
|
|
|
|
|
{
|
2025-01-30 22:45:33 -05:00
|
|
|
|
base.Initialize(elementName);
|
2025-01-27 10:29:38 -05:00
|
|
|
|
this.track = track;
|
|
|
|
|
|
this.trackPositioner = gameObject.AddComponent<SplinePositioner>();
|
|
|
|
|
|
this.trackPositioner.spline = track.trackPathSubmodule.path;
|
|
|
|
|
|
this.trackPercent = trackPercent;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public void Update()
|
|
|
|
|
|
{
|
|
|
|
|
|
if (trackPercent.animations.Count > 0)
|
|
|
|
|
|
{
|
|
|
|
|
|
trackPercent.UpdateFlexibleFloat(EditorManager.instance.songModule.songTime);
|
|
|
|
|
|
if (trackPercent.returnType == FlexibleReturnType.MiddleExecuting)
|
|
|
|
|
|
{
|
2025-01-29 23:49:18 -05:00
|
|
|
|
float finalValue = trackPercent.value;
|
|
|
|
|
|
|
|
|
|
|
|
if (isBeyond1)
|
|
|
|
|
|
{
|
|
|
|
|
|
finalValue -= Mathf.Floor(finalValue);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
trackPositioner.SetPercent(finalValue);
|
2025-01-27 10:29:38 -05:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|