177 lines
6.1 KiB
C#
177 lines
6.1 KiB
C#
using System;
|
||
using System.Collections;
|
||
using System.Collections.Generic;
|
||
using Dreamteck.Splines;
|
||
using Sirenix.OdinInspector;
|
||
using UnityEngine;
|
||
|
||
namespace Ichni.RhythmGame
|
||
{
|
||
public abstract partial class NoteBase : GameElement, IHaveTransformSubmodule, IHaveTimeDurationSubmodule
|
||
{
|
||
[Title("Basic Info")]
|
||
public float exactJudgeTime;
|
||
|
||
[Title("Track Info")]
|
||
public bool isOnTrack;
|
||
public Track track;
|
||
public SplinePositioner trackPositioner;
|
||
|
||
[Title("NoteVisual")]
|
||
public NoteVisualBase noteVisual;
|
||
|
||
[Title("Submodules")]
|
||
public TransformSubmodule transformSubmodule { get; set; }
|
||
public TimeDurationSubmodule timeDurationSubmodule { get; set; }
|
||
public NoteJudgeSubmodule noteJudgeSubmodule { get; set; }
|
||
|
||
[Title("In-Game Info")]
|
||
public Vector2 noteScreenPosition;
|
||
public bool isJudged;
|
||
|
||
/// <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.songInformation.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);
|
||
}
|
||
|
||
protected override void SetDefaultSubmodules()
|
||
{
|
||
transformSubmodule = new TransformSubmodule(this);
|
||
timeDurationSubmodule = new TimeDurationSubmodule(this);
|
||
noteJudgeSubmodule = new NoteJudgeSubmodule(this);
|
||
|
||
submoduleList.Add(transformSubmodule);
|
||
submoduleList.Add(timeDurationSubmodule);
|
||
submoduleList.Add(noteJudgeSubmodule);
|
||
}
|
||
|
||
private void Update()
|
||
{
|
||
if (isOnTrack)
|
||
{
|
||
if (track.trackTimeSubmodule is TrackTimeSubmoduleStatic)
|
||
{
|
||
UpdateNoteInStaticTrack();
|
||
}
|
||
}
|
||
|
||
float songTime = EditorManager.instance.songInformation.songTime;
|
||
|
||
if (isJudged && songTime < exactJudgeTime)
|
||
{
|
||
isJudged = false;
|
||
}
|
||
|
||
if (!isJudged && songTime >= exactJudgeTime)
|
||
{
|
||
if (!isJudged)
|
||
{
|
||
//AudioSource.PlayClipAtPoint(EditorManager.instance.basePrefabs.tapNoteSound, Camera.main.transform.position, 1f);
|
||
isJudged = true;
|
||
}
|
||
}
|
||
|
||
if (noteVisual != null)
|
||
{
|
||
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;
|
||
}
|
||
}
|
||
}
|
||
|
||
public void ExecuteStartJudge()
|
||
{
|
||
|
||
}
|
||
|
||
public void UpdateNoteInTrack()
|
||
{
|
||
if (isOnTrack && track.trackTimeSubmodule != null)
|
||
{
|
||
if (track.trackTimeSubmodule is TrackTimeSubmoduleMovable)
|
||
{
|
||
UpdateNoteInMovableTrack();
|
||
}
|
||
else if (track.trackTimeSubmodule is TrackTimeSubmoduleStatic)
|
||
{
|
||
UpdateNoteInStaticTrack();
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
public abstract partial class NoteBase
|
||
{
|
||
public enum NoteJudgeType
|
||
{
|
||
Perfect,
|
||
Good,
|
||
Bad,
|
||
Miss
|
||
}
|
||
}
|
||
|
||
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();
|
||
}
|
||
}
|
||
}
|
||
} |