87 lines
3.2 KiB
C#
87 lines
3.2 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 Flick : NoteBase
|
||
{
|
||
public List<Vector2> availableFlickDirections;
|
||
public static Flick GenerateElement(string elementName, Guid id, List<string> tags,
|
||
float exactJudgeTime, BaseElement attach, List<Vector2> directions)
|
||
{
|
||
Flick flick = Instantiate(EditorManager.instance.basePrefabs.tapNote, attach.transform).GetComponent<Flick>();
|
||
flick.Initialize(elementName, id, tags);
|
||
flick.exactJudgeTime = exactJudgeTime;
|
||
flick.availableFlickDirections = directions;
|
||
flick.transformSubmodule = new TransformSubmodule(flick);
|
||
flick.timeDurationSubmodule = new TimeDurationSubmodule(flick);
|
||
flick.SetParent(attach);
|
||
|
||
if (attach.TryGetComponent(out Track track))
|
||
{
|
||
if (track.trackTimeSubmodule != null)
|
||
{
|
||
flick.track = track;
|
||
flick.trackPositioner = flick.AddComponent<SplinePositioner>();
|
||
flick.trackPositioner.spline = track.trackPathSubmodule.path;
|
||
flick.isOnTrack = true;
|
||
flick.UpdateNoteInTrack();
|
||
}
|
||
else
|
||
{
|
||
throw new System.Exception("如果Note要生成在Track上,Track必须有TrackTimeSubmodule组件。");
|
||
}
|
||
}
|
||
else
|
||
{
|
||
flick.track = null;
|
||
flick.isOnTrack = false;
|
||
}
|
||
|
||
return flick;
|
||
}
|
||
}
|
||
|
||
public partial class Flick
|
||
{
|
||
public override void SaveBM()
|
||
{
|
||
matchedBM = new Beatmap.Flick_BM(elementName, elementGuid, tags, parentElement.matchedBM, exactJudgeTime, availableFlickDirections);
|
||
}
|
||
}
|
||
|
||
namespace Beatmap
|
||
{
|
||
public class Flick_BM : BaseElement_BM
|
||
{
|
||
public float exactJudgeTime;
|
||
public List<Vector2> availableFlickDirections;
|
||
public Flick_BM()
|
||
{
|
||
|
||
}
|
||
|
||
public Flick_BM(string elementName, Guid elementGuid, List<string> tags, BaseElement_BM attachedElement, float exactJudgeTime, List<Vector2> directions)
|
||
: base(elementName, elementGuid, tags, attachedElement)
|
||
{
|
||
this.exactJudgeTime = exactJudgeTime;
|
||
availableFlickDirections = directions;
|
||
}
|
||
|
||
public override void ExecuteBM()
|
||
{
|
||
matchedElement = Flick.GenerateElement(elementName, elementGuid, tags, exactJudgeTime, GetElement(attachedElementGuid), availableFlickDirections);
|
||
}
|
||
|
||
public override BaseElement DuplicateBM(BaseElement parent)
|
||
{
|
||
return Flick.GenerateElement(elementName, elementGuid, tags, exactJudgeTime, parent, availableFlickDirections);
|
||
}
|
||
}
|
||
}
|
||
} |