84 lines
2.8 KiB
C#
84 lines
2.8 KiB
C#
using System;
|
||
using System.Collections;
|
||
using System.Collections.Generic;
|
||
using Dreamteck.Splines;
|
||
using Lean.Pool;
|
||
using Unity.VisualScripting;
|
||
using UnityEngine;
|
||
|
||
namespace Ichni.RhythmGame
|
||
{
|
||
public partial class Stay : NoteBase
|
||
{
|
||
public static Stay GenerateElement(string elementName, Guid id, List<string> tags,
|
||
float exactJudgeTime, BaseElement attach)
|
||
{
|
||
Stay stay = Instantiate(EditorManager.instance.basePrefabs.tapNote, attach.transform).GetComponent<Stay>();
|
||
stay.Initialize(elementName, id, tags);
|
||
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;
|
||
}
|
||
}
|
||
|
||
public partial class Stay
|
||
{
|
||
public override void SaveBM()
|
||
{
|
||
matchedBM = new Beatmap.Stay_BM(elementName, elementGuid, tags, parentElement.matchedBM, exactJudgeTime);
|
||
}
|
||
}
|
||
|
||
namespace Beatmap
|
||
{
|
||
public class Stay_BM : BaseElement_BM
|
||
{
|
||
public float exactJudgeTime;
|
||
|
||
public Stay_BM()
|
||
{
|
||
|
||
}
|
||
|
||
public Stay_BM(string elementName, Guid elementGuid, List<string> tags, BaseElement_BM attachedElement, float exactJudgeTime)
|
||
: base(elementName, elementGuid, tags, attachedElement)
|
||
{
|
||
this.exactJudgeTime = exactJudgeTime;
|
||
}
|
||
|
||
public override void ExecuteBM()
|
||
{
|
||
matchedElement = Stay.GenerateElement(elementName, elementGuid, tags, exactJudgeTime, GetElement(attachedElementGuid));
|
||
}
|
||
|
||
public override BaseElement DuplicateBM(BaseElement parent)
|
||
{
|
||
return Stay.GenerateElement(elementName, elementGuid, tags, exactJudgeTime, parent);
|
||
}
|
||
}
|
||
}
|
||
} |