2025-02-02 08:34:54 -05:00
|
|
|
|
using System;
|
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>
|
2025-02-02 21:59:43 -05:00
|
|
|
|
public partial class TrackPercentPoint : BaseElement
|
2025-01-27 10:29:38 -05:00
|
|
|
|
{
|
|
|
|
|
|
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
|
|
|
|
|
2025-02-02 08:34:54 -05:00
|
|
|
|
public static TrackPercentPoint GenerateElement(string elementName, Guid id, List<string> tags,
|
|
|
|
|
|
Track track, FlexibleFloat trackPercent)
|
2025-01-27 10:29:38 -05:00
|
|
|
|
{
|
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
|
|
|
|
|
2025-02-02 08:34:54 -05:00
|
|
|
|
point.Initialize(elementName, id, tags);
|
|
|
|
|
|
point.track = track;
|
|
|
|
|
|
point.trackPositioner = point.gameObject.AddComponent<SplinePositioner>();
|
|
|
|
|
|
point.trackPositioner.spline = track.trackPathSubmodule.path;
|
|
|
|
|
|
point.trackPercent = trackPercent;
|
2025-01-27 10:29:38 -05:00
|
|
|
|
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;
|
|
|
|
|
|
}
|
2025-02-02 08:34:54 -05:00
|
|
|
|
|
2025-01-27 10:29:38 -05:00
|
|
|
|
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
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2025-02-02 21:59:43 -05:00
|
|
|
|
|
|
|
|
|
|
public partial class TrackPercentPoint
|
|
|
|
|
|
{
|
|
|
|
|
|
public override void SaveBM()
|
|
|
|
|
|
{
|
|
|
|
|
|
matchedBM = new Beatmap.TrackPercentPoint_BM(elementName, elementGuid, tags, parentElement.matchedBM, trackPercent.ConvertToBM());
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
namespace Beatmap
|
|
|
|
|
|
{
|
|
|
|
|
|
public class TrackPercentPoint_BM : BaseElement_BM
|
|
|
|
|
|
{
|
|
|
|
|
|
public FlexibleFloat_BM trackPercent;
|
|
|
|
|
|
public TrackPercentPoint_BM()
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public TrackPercentPoint_BM(string elementName, Guid elementGuid, List<string> tags,
|
|
|
|
|
|
BaseElement_BM attachedElement, FlexibleFloat_BM trackPercent)
|
|
|
|
|
|
: base(elementName, elementGuid, tags, attachedElement)
|
|
|
|
|
|
{
|
|
|
|
|
|
this.trackPercent = trackPercent;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public override void ExecuteBM()
|
|
|
|
|
|
{
|
|
|
|
|
|
TrackPercentPoint.GenerateElement(elementName, elementGuid, tags, GetElement(attachedElementGuid) as Track, trackPercent.ConvertToGameType());
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public override BaseElement DuplicateBM(BaseElement parent)
|
|
|
|
|
|
{
|
|
|
|
|
|
return TrackPercentPoint.GenerateElement(elementName, elementGuid, tags, parent as Track, trackPercent.ConvertToGameType());
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2025-01-27 10:29:38 -05:00
|
|
|
|
}
|