2025-06-03 02:42:28 -04:00
|
|
|
|
using System;
|
|
|
|
|
|
using System.Collections;
|
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
using System.Linq;
|
|
|
|
|
|
using Dreamteck.Splines;
|
|
|
|
|
|
using Ichni.RhythmGame.Beatmap;
|
|
|
|
|
|
using UnityEngine;
|
|
|
|
|
|
|
|
|
|
|
|
namespace Ichni.RhythmGame
|
|
|
|
|
|
{
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 在轨道上根据百分比进行运动的点
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public partial class TrackPercentPoint : GameElement, IHaveTimeDurationSubmodule
|
|
|
|
|
|
{
|
|
|
|
|
|
public Track track;
|
|
|
|
|
|
public SplinePositioner trackPositioner;
|
|
|
|
|
|
public FlexibleFloat trackPercent;
|
|
|
|
|
|
|
|
|
|
|
|
public TimeDurationSubmodule timeDurationSubmodule { get; set; }
|
|
|
|
|
|
|
|
|
|
|
|
private bool isBeyond1 = false;
|
|
|
|
|
|
|
|
|
|
|
|
public static TrackPercentPoint GenerateElement(string elementName, Guid id, List<string> tags,
|
|
|
|
|
|
bool isFirstGenerated, Track track, FlexibleFloat trackPercent)
|
|
|
|
|
|
{
|
|
|
|
|
|
TrackPercentPoint point = Instantiate(GameManager.instance.basePrefabs.emptyObject, track.transform).AddComponent<TrackPercentPoint>();
|
|
|
|
|
|
|
|
|
|
|
|
point.Initialize(elementName, id, tags, isFirstGenerated, track);
|
|
|
|
|
|
point.track = track;
|
|
|
|
|
|
point.trackPositioner = point.gameObject.AddComponent<SplinePositioner>();
|
|
|
|
|
|
point.trackPositioner.spline = track.trackPathSubmodule.path;
|
|
|
|
|
|
point.trackPercent = trackPercent;
|
|
|
|
|
|
|
|
|
|
|
|
point.isBeyond1 = trackPercent.animations.Any(animation => animation.endValue > 1); //判断是否有超过1的动画,超过1将会循环
|
2025-07-21 05:42:20 -04:00
|
|
|
|
point.trackPositioner.motion.applyRotation = false;
|
2025-06-03 02:42:28 -04:00
|
|
|
|
return point;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public override void SetDefaultSubmodules()
|
|
|
|
|
|
{
|
|
|
|
|
|
timeDurationSubmodule = new TimeDurationSubmodule(this);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public void Update()
|
|
|
|
|
|
{
|
|
|
|
|
|
if (trackPercent.animations.Count > 0)
|
|
|
|
|
|
{
|
|
|
|
|
|
trackPercent.UpdateFlexibleFloat(GameManager.instance.songTime);
|
|
|
|
|
|
if (trackPercent.returnType == FlexibleReturnType.MiddleExecuting)
|
|
|
|
|
|
{
|
|
|
|
|
|
float finalValue = trackPercent.value;
|
|
|
|
|
|
|
|
|
|
|
|
if (isBeyond1)
|
|
|
|
|
|
{
|
|
|
|
|
|
finalValue -= Mathf.Floor(finalValue);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
trackPositioner.SetPercent(finalValue);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public partial class TrackPercentPoint
|
|
|
|
|
|
{
|
|
|
|
|
|
public override void SaveBM()
|
|
|
|
|
|
{
|
|
|
|
|
|
matchedBM = new TrackPercentPoint_BM(elementName, elementGuid, tags,
|
|
|
|
|
|
parentElement.matchedBM as GameElement_BM,
|
|
|
|
|
|
trackPercent.ConvertToBM());
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
namespace Beatmap
|
|
|
|
|
|
{
|
|
|
|
|
|
public class TrackPercentPoint_BM : GameElement_BM
|
|
|
|
|
|
{
|
|
|
|
|
|
public FlexibleFloat_BM trackPercent;
|
|
|
|
|
|
|
|
|
|
|
|
public TrackPercentPoint_BM()
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public TrackPercentPoint_BM(string elementName, Guid elementGuid, List<string> tags,
|
|
|
|
|
|
GameElement_BM attachedElement, FlexibleFloat_BM trackPercent)
|
|
|
|
|
|
: base(elementName, elementGuid, tags, attachedElement)
|
|
|
|
|
|
{
|
|
|
|
|
|
this.trackPercent = trackPercent;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public override void ExecuteBM()
|
|
|
|
|
|
{
|
|
|
|
|
|
matchedElement = TrackPercentPoint.GenerateElement(elementName, elementGuid, tags, false,
|
|
|
|
|
|
GetElement(attachedElementGuid) as Track, trackPercent.ConvertToGameType());
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public override GameElement DuplicateBM(GameElement parent)
|
|
|
|
|
|
{
|
|
|
|
|
|
return TrackPercentPoint.GenerateElement(elementName, Guid.NewGuid(), tags, false, parent as Track,
|
|
|
|
|
|
trackPercent.ConvertToGameType());
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|