Files
ichni_Official/Assets/Scripts/Game/GameElements/Notes/NoteObjects/Flick.cs
SoulliesOfficial d4e860fa16 initial
2025-06-03 02:42:28 -04:00

107 lines
3.7 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 Ichni.RhythmGame.Beatmap;
using Lean.Pool;
using Unity.VisualScripting;
using UnityEngine;
namespace Ichni.RhythmGame
{
public partial class Flick : NoteBase
{
public static readonly NoteJudgeIntervals judgeIntervals = new NoteJudgeIntervals(
new TimeInterval(-0.25f, -0.25f), new TimeInterval(-0.25f, -0.25f),
new TimeInterval(-0.25f, -0.25f), new TimeInterval(-0.25f, 0.15f),
new TimeInterval(0.15f, 0.25f), new TimeInterval(0.25f, 0.25f), 0.25f);
public List<Vector2> availableFlickDirections;
public float flickBufferAngle = 60f;
public static Flick GenerateElement(string elementName, Guid id, List<string> tags, bool isFirstGenerated,
GameElement parentElement, float exactJudgeTime, List<Vector2> directions)
{
Flick flick = Instantiate(GameManager.instance.basePrefabs.flickNote, parentElement.transform).GetComponent<Flick>();
flick.Initialize(elementName, id, tags, isFirstGenerated, parentElement);
flick.exactJudgeTime = exactJudgeTime;
flick.availableFlickDirections = directions;
if (parentElement.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 void SetFirstJudge(Vector3 deltaPosition)
{
}
}
public partial class Flick
{
public override void SetDefaultSubmodules()
{
base.SetDefaultSubmodules();
noteAudioSubmodule = new NoteAudioSubmodule(this, "DefaultStay");
}
public override void SaveBM()
{
matchedBM = new Flick_BM(elementName, elementGuid, tags, parentElement.matchedBM as GameElement_BM,
exactJudgeTime, availableFlickDirections);
}
}
namespace Beatmap
{
public class Flick_BM : NoteBase_BM
{
public List<Vector2> availableFlickDirections;
public Flick_BM()
{
}
public Flick_BM(string elementName, Guid elementGuid, List<string> tags, GameElement_BM attachedElement,
float exactJudgeTime,
List<Vector2> directions) : base(elementName, elementGuid, tags, attachedElement, exactJudgeTime)
{
availableFlickDirections = directions;
}
public override void ExecuteBM()
{
matchedElement = Flick.GenerateElement(elementName, elementGuid, tags, false,
GetElement(attachedElementGuid), exactJudgeTime, availableFlickDirections);
}
public override GameElement DuplicateBM(GameElement parent)
{
return Flick.GenerateElement(elementName, Guid.NewGuid(), tags, false, parent,
exactJudgeTime, availableFlickDirections);
}
}
}
}