Files
ichni_Creator_Studio/Assets/Scripts/GameElements/Track/TrackPoints/TrackPercentPoint.cs
SoulliesOfficial 39b4a5e7ff 基础内容-5
主题包;
测试NoteVisual与NoteEffect;
LookAt旋转动画与FlexibleBool
动画杂项
控制台初步
2025-01-29 23:49:18 -05:00

62 lines
2.1 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
using System.Collections;
using System.Collections.Generic;
using System.Linq;
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;
private bool isBeyond1 = false;
public static TrackPercentPoint GenerateElement(string elementName, Track track, FlexibleFloat trackPercent)
{
TrackPercentPoint point = LeanPool.Spawn(EditorManager.instance.basePrefabs.emptyObject, track.transform).AddComponent<TrackPercentPoint>();
point.NewInitialize(elementName, track, trackPercent);
point.SetParent(track);
point.isBeyond1 = trackPercent.animations.Any(animation => animation.endValue > 1);//判断是否有超过1的动画超过1将会循环
return point;
}
private void NewInitialize(string elementName, Track track, FlexibleFloat trackPercent)
{
base.NewInitialize(elementName);
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)
{
float finalValue = trackPercent.value;
if (isBeyond1)
{
finalValue -= Mathf.Floor(finalValue);
}
trackPositioner.SetPercent(finalValue);
}
}
}
}
}