Files
ichni_Creator_Studio/Assets/Scripts/GameElements/Notes/Flick.cs

48 lines
1.6 KiB
C#
Raw Normal View History

using System.Collections;
using System.Collections.Generic;
using Lean.Pool;
using UnityEngine;
namespace Ichni.RhythmGame
{
public class Flick : NoteBase
{
public List<Vector2> availableFlickDirections;
public static Flick GenerateElement(string elementName, float exactJudgeTime, BaseElement attach, List<Vector2> directions)
{
Flick flick = LeanPool.Spawn(EditorManager.instance.basePrefabs.tapNote, attach.transform).GetComponent<Flick>();
flick.NewInitialize(elementName, exactJudgeTime);
flick.availableFlickDirections = directions;
flick.SetParent(attach);
if (attach.TryGetComponent(out Track track))
{
if (track.trackTimeSubmodule != null)
{
flick.track = track;
flick.trackPositioner.spline = track.trackPathSubmodule.path;
flick.isOnTrack = true;
flick.UpdateNoteInTrack();
}
else
{
throw new System.Exception("如果Note要生成在Track上Track必须有TrackTimeSubmodule组件。");
}
}
else
{
}
return flick;
}
public void NewInitialize(string elementName, float exactJudgeTime)
{
base.NewInitialize(elementName);
this.exactJudgeTime = exactJudgeTime;
this.track = null;
this.isOnTrack = false;
}
}
}