基础内容-7

Trail
完整Note
This commit is contained in:
SoulliesOfficial
2025-02-02 08:34:54 -05:00
parent 38ec74bfef
commit efca87e9cd
60 changed files with 1503 additions and 228 deletions

View File

@@ -0,0 +1,59 @@
using System;
using System.Collections;
using System.Collections.Generic;
using Dreamteck.Splines;
using Ichni.RhythmGame;
using UnityEngine;
namespace Ichni.RhythmGame
{
public class CrossTrackPoint : BaseElement
{
public ElementFolder trackListFolder;
public Track nowAttachedTrack;
private int nowAttachedTrackIndex;
public SplinePositioner trackPositioner;
public FlexibleInt trackSwitch;
public FlexibleFloat trackPercent;
public static CrossTrackPoint GenerateElement(string elementName, Guid id, List<string> tags,
ElementFolder elementFolder, FlexibleInt trackSwitch, FlexibleFloat trackPercent)
{
CrossTrackPoint point = Instantiate(EditorManager.instance.basePrefabs.emptyObject, elementFolder.transform).AddComponent<CrossTrackPoint>();
point.Initialize(elementName, id, tags);
point.trackPositioner = point.gameObject.AddComponent<SplinePositioner>();
point.nowAttachedTrackIndex = -1;
point.trackListFolder = elementFolder;
point.trackSwitch = trackSwitch;
point.trackPercent = trackPercent;
point.transformSubmodule = new TransformSubmodule(point);
point.timeDurationSubmodule = new TimeDurationSubmodule(point);
point.SetParent(elementFolder);
return point;
}
private void Update()
{
if (trackPercent.animations.Count > 0)
{
trackSwitch.UpdateFlexibleInt(EditorManager.instance.songModule.songTime);
trackPercent.UpdateFlexibleFloat(EditorManager.instance.songModule.songTime);
SetPoint();
}
}
private void SetPoint()
{
if (nowAttachedTrackIndex != trackSwitch.value && trackSwitch.value >= 0 && trackSwitch.value < trackListFolder.trackList.Count)
{
nowAttachedTrack = trackListFolder.trackList[trackSwitch.value];
nowAttachedTrackIndex = trackSwitch.value;
trackPositioner.spline = trackListFolder.trackList[trackSwitch.value].trackPathSubmodule.path;
}
trackPositioner.SetPercent(trackPercent.value);
}
}
}