Files
ichni_Creator_Studio/Assets/Scripts/GameElements/Notes/NoteObjects/Tap.cs

85 lines
2.8 KiB
C#
Raw Normal View History

2025-02-02 08:34:54 -05:00
using System;
using System.Collections;
using System.Collections.Generic;
using Dreamteck.Splines;
using Ichni.RhythmGame.Beatmap;
using Lean.Pool;
using Unity.VisualScripting;
using UnityEngine;
namespace Ichni.RhythmGame
{
2025-02-02 08:34:54 -05:00
public partial class Tap : NoteBase
{
public static Tap GenerateElement(string elementName, Guid id, List<string> tags, bool isFirstGenerated,
GameElement parentElement, float exactJudgeTime)
{
Tap tap = Instantiate(EditorManager.instance.basePrefabs.tapNote, parentElement.transform)
.GetComponent<Tap>();
2025-02-09 23:47:42 -05:00
tap.Initialize(elementName, id, tags, isFirstGenerated, parentElement);
tap.exactJudgeTime = exactJudgeTime;
tap.transformSubmodule = new TransformSubmodule(tap);
tap.timeDurationSubmodule = new TimeDurationSubmodule(tap);
if (parentElement.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;
}
}
2025-02-02 08:34:54 -05:00
public partial class Tap
{
public override void SaveBM()
{
matchedBM = new Tap_BM(elementName, elementGuid, tags, parentElement.matchedBM as GameElement_BM, exactJudgeTime);
2025-02-02 08:34:54 -05:00
}
}
2025-02-02 08:34:54 -05:00
namespace Beatmap
{
public class Tap_BM : NoteBase_BM
2025-02-02 08:34:54 -05:00
{
public Tap_BM()
{
2025-02-02 08:34:54 -05:00
}
public Tap_BM(string elementName, Guid elementGuid, List<string> tags,
GameElement_BM attachedElement, float exactJudgeTime)
: base(elementName, elementGuid, tags, attachedElement, exactJudgeTime)
2025-02-02 08:34:54 -05:00
{
2025-02-02 08:34:54 -05:00
}
public override void ExecuteBM()
{
matchedElement = Tap.GenerateElement(elementName, elementGuid, tags, false,
GetElement(attachedElementGuid), exactJudgeTime);
2025-02-02 08:34:54 -05:00
}
public override GameElement DuplicateBM(GameElement parent)
2025-02-02 08:34:54 -05:00
{
return Tap.GenerateElement(elementName, elementGuid, tags, false, parent, exactJudgeTime);
2025-02-02 08:34:54 -05:00
}
}
}
}