45 lines
1.6 KiB
C#
45 lines
1.6 KiB
C#
using System.Collections;
|
||
using System.Collections.Generic;
|
||
using Dreamteck.Splines;
|
||
using Lean.Pool;
|
||
using Unity.VisualScripting;
|
||
using UnityEngine;
|
||
|
||
namespace Ichni.RhythmGame
|
||
{
|
||
public class Stay : NoteBase
|
||
{
|
||
public static Stay GenerateElement(string elementName, float exactJudgeTime, BaseElement attach)
|
||
{
|
||
Stay stay = Instantiate(EditorManager.instance.basePrefabs.tapNote, attach.transform).GetComponent<Stay>();
|
||
stay.Initialize(elementName);
|
||
stay.exactJudgeTime = exactJudgeTime;
|
||
stay.transformSubmodule = new TransformSubmodule(stay);
|
||
stay.timeDurationSubmodule = new TimeDurationSubmodule(stay);
|
||
stay.SetParent(attach);
|
||
|
||
if (attach.TryGetComponent(out Track track))
|
||
{
|
||
if (track.trackTimeSubmodule != null)
|
||
{
|
||
stay.track = track;
|
||
stay.trackPositioner = stay.AddComponent<SplinePositioner>();
|
||
stay.trackPositioner.spline = track.trackPathSubmodule.path;
|
||
stay.isOnTrack = true;
|
||
stay.UpdateNoteInTrack();
|
||
}
|
||
else
|
||
{
|
||
throw new System.Exception("如果Note要生成在Track上,Track必须有TrackTimeSubmodule组件。");
|
||
}
|
||
}
|
||
else
|
||
{
|
||
stay.track = null;
|
||
stay.isOnTrack = false;
|
||
}
|
||
|
||
return stay;
|
||
}
|
||
}
|
||
} |