2025-01-27 10:29:38 -05:00
|
|
|
|
using System;
|
|
|
|
|
|
using System.Collections;
|
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
using Dreamteck.Splines;
|
|
|
|
|
|
using Sirenix.OdinInspector;
|
|
|
|
|
|
using UnityEngine;
|
|
|
|
|
|
|
|
|
|
|
|
namespace Ichni.RhythmGame
|
|
|
|
|
|
{
|
2025-02-08 23:09:50 -05:00
|
|
|
|
public abstract partial class NoteBase : GameElement, IHaveTransformSubmodule, IHaveTimeDurationSubmodule
|
2025-01-27 10:29:38 -05:00
|
|
|
|
{
|
|
|
|
|
|
[Title("Basic Info")]
|
|
|
|
|
|
public float exactJudgeTime;
|
|
|
|
|
|
|
|
|
|
|
|
[Title("Track Info")]
|
|
|
|
|
|
public bool isOnTrack;
|
|
|
|
|
|
public Track track;
|
|
|
|
|
|
public SplinePositioner trackPositioner;
|
|
|
|
|
|
|
2025-01-29 23:49:18 -05:00
|
|
|
|
[Title("NoteVisual")]
|
|
|
|
|
|
public NoteVisualBase noteVisual;
|
|
|
|
|
|
|
2025-02-08 02:31:39 -05:00
|
|
|
|
[Title("Submodules")]
|
|
|
|
|
|
public TransformSubmodule transformSubmodule { get; set; }
|
|
|
|
|
|
public TimeDurationSubmodule timeDurationSubmodule { get; set; }
|
|
|
|
|
|
public NoteJudgeSubmodule noteJudgeSubmodule { get; set; }
|
2025-01-27 10:29:38 -05:00
|
|
|
|
|
|
|
|
|
|
[Title("In-Game Info")]
|
|
|
|
|
|
public Vector2 noteScreenPosition;
|
|
|
|
|
|
public bool isJudged;
|
2025-01-30 22:45:33 -05:00
|
|
|
|
|
2025-01-28 11:58:39 -05:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 在MovableTrack上更新Note的位置,注意HoldNote需要重写这个方法
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public virtual void UpdateNoteInMovableTrack()
|
|
|
|
|
|
{
|
|
|
|
|
|
trackPositioner.SetPercent((track.trackTimeSubmodule as TrackTimeSubmoduleMovable).GetTrackPercent(exactJudgeTime));
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 在StaticTrack上更新Note的位置,注意HoldNote需要重写这个方法
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public virtual void UpdateNoteInStaticTrack()
|
|
|
|
|
|
{
|
|
|
|
|
|
float songTime = EditorManager.instance.songModule.songTime;
|
|
|
|
|
|
TrackTimeSubmoduleStatic trackTimeSubmoduleStatic = track.trackTimeSubmodule as TrackTimeSubmoduleStatic;
|
|
|
|
|
|
|
|
|
|
|
|
float startMove = exactJudgeTime - trackTimeSubmoduleStatic.trackTotalTime;
|
|
|
|
|
|
float percent = AnimationCurveEvaluator.Evaluate(trackTimeSubmoduleStatic.animationCurveType, (songTime - startMove) / trackTimeSubmoduleStatic.trackTotalTime);
|
|
|
|
|
|
|
|
|
|
|
|
percent = Mathf.Max(percent, 0);
|
|
|
|
|
|
percent = Mathf.Min(percent, 1);
|
|
|
|
|
|
|
|
|
|
|
|
trackPositioner.SetPercent(1 - percent);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-02-08 02:31:39 -05:00
|
|
|
|
protected override void SetDefaultSubmodules()
|
2025-01-28 11:58:39 -05:00
|
|
|
|
{
|
2025-02-08 02:31:39 -05:00
|
|
|
|
transformSubmodule = new TransformSubmodule(this);
|
|
|
|
|
|
timeDurationSubmodule = new TimeDurationSubmodule(this);
|
|
|
|
|
|
noteJudgeSubmodule = new NoteJudgeSubmodule(this);
|
2025-02-07 10:49:26 -05:00
|
|
|
|
|
2025-02-08 02:31:39 -05:00
|
|
|
|
submoduleList.Add(transformSubmodule);
|
|
|
|
|
|
submoduleList.Add(timeDurationSubmodule);
|
|
|
|
|
|
submoduleList.Add(noteJudgeSubmodule);
|
2025-01-28 11:58:39 -05:00
|
|
|
|
}
|
2025-02-08 02:31:39 -05:00
|
|
|
|
|
2025-01-28 11:58:39 -05:00
|
|
|
|
private void Update()
|
|
|
|
|
|
{
|
|
|
|
|
|
if (isOnTrack)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (track.trackTimeSubmodule is TrackTimeSubmoduleStatic)
|
|
|
|
|
|
{
|
|
|
|
|
|
UpdateNoteInStaticTrack();
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
float songTime = EditorManager.instance.songModule.songTime;
|
|
|
|
|
|
|
|
|
|
|
|
if (isJudged && songTime < exactJudgeTime)
|
|
|
|
|
|
{
|
|
|
|
|
|
isJudged = false;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (!isJudged && songTime >= exactJudgeTime)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (!isJudged)
|
|
|
|
|
|
{
|
2025-01-30 22:45:33 -05:00
|
|
|
|
//AudioSource.PlayClipAtPoint(EditorManager.instance.basePrefabs.tapNoteSound, Camera.main.transform.position, 1f);
|
2025-01-28 11:58:39 -05:00
|
|
|
|
isJudged = true;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2025-02-08 23:09:50 -05:00
|
|
|
|
|
|
|
|
|
|
if (noteVisual != null)
|
2025-01-28 11:58:39 -05:00
|
|
|
|
{
|
2025-02-08 23:09:50 -05:00
|
|
|
|
noteVisual.effectSubmodule.effectCollection["Generate"].ForEach(e => e.UpdateEffect());
|
|
|
|
|
|
noteVisual.effectSubmodule.effectCollection["GeneralJudge"].ForEach(e => e.UpdateEffect());
|
|
|
|
|
|
|
|
|
|
|
|
switch (EditorManager.instance.currentJudgeType)
|
|
|
|
|
|
{
|
|
|
|
|
|
case NoteJudgeType.Perfect:
|
|
|
|
|
|
noteVisual.effectSubmodule.effectCollection["Perfect"].ForEach(e => e.UpdateEffect());
|
|
|
|
|
|
break;
|
|
|
|
|
|
case NoteJudgeType.Good:
|
|
|
|
|
|
noteVisual.effectSubmodule.effectCollection["Good"].ForEach(e => e.UpdateEffect());
|
|
|
|
|
|
break;
|
|
|
|
|
|
case NoteJudgeType.Bad:
|
|
|
|
|
|
noteVisual.effectSubmodule.effectCollection["Bad"].ForEach(e => e.UpdateEffect());
|
|
|
|
|
|
break;
|
|
|
|
|
|
case NoteJudgeType.Miss:
|
|
|
|
|
|
noteVisual.effectSubmodule.effectCollection["Miss"].ForEach(e => e.UpdateEffect());
|
|
|
|
|
|
break;
|
|
|
|
|
|
}
|
2025-01-28 11:58:39 -05:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public void ExecuteStartJudge()
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public void UpdateNoteInTrack()
|
|
|
|
|
|
{
|
|
|
|
|
|
if (isOnTrack && track.trackTimeSubmodule != null)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (track.trackTimeSubmodule is TrackTimeSubmoduleMovable)
|
|
|
|
|
|
{
|
|
|
|
|
|
UpdateNoteInMovableTrack();
|
|
|
|
|
|
}
|
|
|
|
|
|
else if (track.trackTimeSubmodule is TrackTimeSubmoduleStatic)
|
|
|
|
|
|
{
|
|
|
|
|
|
UpdateNoteInStaticTrack();
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2025-01-27 10:29:38 -05:00
|
|
|
|
}
|
2025-02-02 08:34:54 -05:00
|
|
|
|
|
|
|
|
|
|
public abstract partial class NoteBase
|
|
|
|
|
|
{
|
|
|
|
|
|
public enum NoteJudgeType
|
|
|
|
|
|
{
|
|
|
|
|
|
Perfect,
|
|
|
|
|
|
Good,
|
|
|
|
|
|
Bad,
|
|
|
|
|
|
Miss
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2025-02-08 02:31:39 -05:00
|
|
|
|
|
|
|
|
|
|
namespace Beatmap
|
|
|
|
|
|
{
|
|
|
|
|
|
public abstract class NoteBase_BM : GameElement_BM
|
|
|
|
|
|
{
|
|
|
|
|
|
public float exactJudgeTime;
|
|
|
|
|
|
|
|
|
|
|
|
public NoteBase_BM()
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public NoteBase_BM(string elementName, Guid elementGuid, List<string> tags, GameElement_BM attachedElement, float exactJudgeTime)
|
|
|
|
|
|
: base(elementName, elementGuid, tags, attachedElement)
|
|
|
|
|
|
{
|
|
|
|
|
|
this.exactJudgeTime = exactJudgeTime;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public override void ExecuteBM()
|
|
|
|
|
|
{
|
|
|
|
|
|
throw new NotImplementedException();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public override GameElement DuplicateBM(GameElement parent)
|
|
|
|
|
|
{
|
|
|
|
|
|
throw new NotImplementedException();
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2025-01-27 10:29:38 -05:00
|
|
|
|
}
|