Files
ichni_Creator_Studio/Assets/Scripts/GameElements/Notes/Tap.cs
SoulliesOfficial efca87e9cd 基础内容-7
Trail
完整Note
2025-02-02 08:34:54 -05:00

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