45 lines
1.5 KiB
C#
45 lines
1.5 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 Tap : NoteBase
|
||
{
|
||
public static Tap GenerateElement(string elementName, float exactJudgeTime, BaseElement attach)
|
||
{
|
||
Tap tap = Instantiate(EditorManager.instance.basePrefabs.tapNote, attach.transform).GetComponent<Tap>();
|
||
tap.Initialize(elementName);
|
||
tap.exactJudgeTime = exactJudgeTime;
|
||
tap.transformSubmodule = new TransformSubmodule(tap);
|
||
tap.timeDurationSubmodule = new TimeDurationSubmodule(tap);
|
||
tap.SetParent(attach);
|
||
|
||
if (attach.TryGetComponent(out Track track))
|
||
{
|
||
if (track.trackTimeSubmodule != null)
|
||
{
|
||
tap.track = track;
|
||
tap.trackPositioner = tap.AddComponent<SplinePositioner>();
|
||
tap.trackPositioner.spline = track.trackPathSubmodule.path;
|
||
tap.isOnTrack = true;
|
||
tap.UpdateNoteInTrack();
|
||
}
|
||
else
|
||
{
|
||
throw new System.Exception("如果Note要生成在Track上,Track必须有TrackTimeSubmodule组件。");
|
||
}
|
||
}
|
||
else
|
||
{
|
||
tap.track = null;
|
||
tap.isOnTrack = false;
|
||
}
|
||
|
||
return tap;
|
||
}
|
||
}
|
||
} |