perf
This commit is contained in:
@@ -10,7 +10,7 @@ using UnityEngine.Serialization;
|
||||
|
||||
namespace Ichni.RhythmGame
|
||||
{
|
||||
public abstract partial class NoteBase : GameElement, IHaveTimeDurationSubmodule
|
||||
public abstract partial class NoteBase : GameElement, IHaveTimeDurationSubmodule, IComparable<NoteBase>
|
||||
{
|
||||
[Title("Basic Info")]
|
||||
public float exactJudgeTime;
|
||||
@@ -32,7 +32,8 @@ namespace Ichni.RhythmGame
|
||||
public NoteJudgeSubmodule noteJudgeSubmodule { get; set; }
|
||||
public NoteAudioSubmodule noteAudioSubmodule { get; set; }
|
||||
|
||||
[Title("In-Game Info")]
|
||||
[Title("In-Game Info")]
|
||||
public bool isDuringJudging;
|
||||
public Vector2 noteScreenPosition;
|
||||
public bool isFirstJudged;
|
||||
public bool isFinalJudged;
|
||||
@@ -72,12 +73,24 @@ namespace Ichni.RhythmGame
|
||||
|
||||
public override void AfterInitialize()
|
||||
{
|
||||
noteVisual.effectSubmodule.effectCollection["Generate"].ForEach(e => e.Recover());
|
||||
float beyondTime = 0f;
|
||||
|
||||
foreach (NoteGenerateEffect ge in noteVisual.effectSubmodule.effectCollection["Generate"].Cast<NoteGenerateEffect>())
|
||||
{
|
||||
ge.Recover();
|
||||
beyondTime = Mathf.Max(beyondTime, ge.generateTime);
|
||||
}
|
||||
|
||||
if (exactJudgeTime - beyondTime - 0.5f > -GameManager.instance.songInformation.delay)
|
||||
{
|
||||
gameObject.SetActive(false);
|
||||
GameManager.instance.noteManager.RegisterNote(this, exactJudgeTime - beyondTime - 0.5f);
|
||||
}
|
||||
}
|
||||
|
||||
protected virtual void Update()
|
||||
{
|
||||
if (!GameManager.instance.audioManager.isUpdating)
|
||||
if (!GameManager.instance.audioManager.isUpdating || isFinalJudged)
|
||||
{
|
||||
return;
|
||||
}
|
||||
@@ -89,61 +102,38 @@ namespace Ichni.RhythmGame
|
||||
UpdateNoteInStaticTrack();
|
||||
}
|
||||
}
|
||||
|
||||
if (noteJudgeSubmodule != null)
|
||||
{
|
||||
if (GameManager.instance.songTime > exactJudgeTime - 0.25f && !isFirstJudged)
|
||||
{
|
||||
foreach (NoteJudgeUnit unit in noteJudgeSubmodule.judgeUnitList.Where(unit => !unit.isShowingJudge))
|
||||
{
|
||||
unit.SetShowingJudge(true);
|
||||
}
|
||||
}
|
||||
|
||||
foreach (NoteJudgeUnit unit in noteJudgeSubmodule.judgeUnitList.Where(unit => unit.isShowingJudge))
|
||||
{
|
||||
unit.UpdateJudge();
|
||||
}
|
||||
|
||||
if (GameManager.instance.songTime > exactJudgeTime + 0.25f)
|
||||
{
|
||||
foreach (NoteJudgeUnit unit in noteJudgeSubmodule.judgeUnitList.Where(unit => unit.isShowingJudge))
|
||||
{
|
||||
unit.SetShowingJudge(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
noteScreenPosition = GameManager.instance.cameraManager.gameCamera.gameCamera
|
||||
.WorldToScreenPoint(noteVisual.transform.position);
|
||||
|
||||
if (noteVisual != null)
|
||||
if (isDuringJudging)
|
||||
{
|
||||
noteVisual.effectSubmodule.effectCollection["Generate"].ForEach(e => e.UpdateEffect(exactJudgeTime));
|
||||
noteScreenPosition = GameManager.instance.cameraManager.gameCamera.gameCamera.WorldToScreenPoint(noteVisual.transform.position);
|
||||
}
|
||||
|
||||
if (!isFirstJudged && GameManager.instance.songTime > exactJudgeTime + 0.25f)
|
||||
foreach (EffectBase e in noteVisual.effectSubmodule.effectCollection["Generate"])
|
||||
{
|
||||
Debug.Log("Note judged too late, marking as Miss.");
|
||||
Miss(exactJudgeTime + 0.25f);
|
||||
e.UpdateEffect(exactJudgeTime);
|
||||
}
|
||||
|
||||
if (!isFirstJudged && GameManager.instance.songTime > exactJudgeTime + judgeIntervals.afterMiss)
|
||||
{
|
||||
Miss(exactJudgeTime + judgeIntervals.afterMiss);
|
||||
isFirstJudged = true;
|
||||
isFinalJudged = true;
|
||||
|
||||
if (this is Tap t)
|
||||
{
|
||||
GameManager.instance.inputManager.checkingTapList.Remove(t);
|
||||
}
|
||||
RemoveFromCheckingList();
|
||||
}
|
||||
}
|
||||
|
||||
public virtual NoteJudgeType GetStartJudgeType(float timeDifference)
|
||||
protected virtual NoteJudgeType GetStartJudgeType(float timeDifference)
|
||||
{
|
||||
return judgeIntervals.GetNoteJudgeType(timeDifference);
|
||||
}
|
||||
|
||||
protected virtual void RemoveFromCheckingList()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public virtual void ExecuteStartJudge()
|
||||
{
|
||||
Debug.Log("ExecuteStartJudge");
|
||||
float triggerTime = GameManager.instance.songTime;
|
||||
float timeDifference = triggerTime - exactJudgeTime;
|
||||
|
||||
@@ -190,6 +180,7 @@ namespace Ichni.RhythmGame
|
||||
|
||||
public virtual void Perfect(float triggerTime)
|
||||
{
|
||||
isDuringJudging = false;
|
||||
GameManager.instance.playingRecorder.AddPerfect();
|
||||
noteAudioSubmodule.PlayNoteJudgeAudios(NoteJudgeType.Perfect);
|
||||
Observable.EveryUpdate().Subscribe(_ =>
|
||||
@@ -198,10 +189,14 @@ namespace Ichni.RhythmGame
|
||||
noteVisual.effectSubmodule.effectCollection["Perfect"].ForEach(e => e.UpdateEffect(triggerTime));
|
||||
noteVisual.effectSubmodule.effectCollection["AfterJudge"].ForEach(e => e.UpdateEffect(exactJudgeTime));
|
||||
}).AddTo(gameObject);
|
||||
|
||||
if (isOnTrack) track.childElementList.Remove(this);
|
||||
Destroy(gameObject, 1.2f); //注意所有特效时间不得超过1.2秒
|
||||
}
|
||||
|
||||
public virtual void Good(float triggerTime)
|
||||
{
|
||||
isDuringJudging = false;
|
||||
GameManager.instance.playingRecorder.AddGood();
|
||||
noteAudioSubmodule.PlayNoteJudgeAudios(NoteJudgeType.Good);
|
||||
Observable.EveryUpdate().Subscribe(_ =>
|
||||
@@ -210,9 +205,13 @@ namespace Ichni.RhythmGame
|
||||
noteVisual.effectSubmodule.effectCollection["Good"].ForEach(e => e.UpdateEffect(triggerTime));
|
||||
noteVisual.effectSubmodule.effectCollection["AfterJudge"].ForEach(e => e.UpdateEffect(exactJudgeTime));
|
||||
}).AddTo(gameObject);
|
||||
|
||||
if (isOnTrack) track.childElementList.Remove(this);
|
||||
Destroy(gameObject, 1.2f);
|
||||
}
|
||||
public virtual void Bad(float triggerTime){
|
||||
{
|
||||
isDuringJudging = false;
|
||||
GameManager.instance.playingRecorder.AddBad();
|
||||
noteAudioSubmodule.PlayNoteJudgeAudios(NoteJudgeType.Bad);
|
||||
Observable.EveryUpdate().Subscribe(_ =>
|
||||
@@ -221,10 +220,14 @@ namespace Ichni.RhythmGame
|
||||
noteVisual.effectSubmodule.effectCollection["Bad"].ForEach(e => e.UpdateEffect(triggerTime));
|
||||
noteVisual.effectSubmodule.effectCollection["AfterJudge"].ForEach(e => e.UpdateEffect(exactJudgeTime));
|
||||
}).AddTo(gameObject);
|
||||
|
||||
if (isOnTrack) track.childElementList.Remove(this);
|
||||
Destroy(gameObject, 1.2f);
|
||||
}}
|
||||
|
||||
public virtual void Miss(float triggerTime)
|
||||
{
|
||||
isDuringJudging = false;
|
||||
GameManager.instance.playingRecorder.AddMiss();
|
||||
noteAudioSubmodule.PlayNoteJudgeAudios(NoteJudgeType.Miss);
|
||||
Observable.EveryUpdate().Subscribe(_ =>
|
||||
@@ -232,6 +235,44 @@ namespace Ichni.RhythmGame
|
||||
noteVisual.effectSubmodule.effectCollection["Miss"].ForEach(e => e.UpdateEffect(triggerTime));
|
||||
noteVisual.effectSubmodule.effectCollection["AfterJudge"].ForEach(e => e.UpdateEffect(exactJudgeTime));
|
||||
}).AddTo(gameObject);
|
||||
|
||||
if (isOnTrack) track.childElementList.Remove(this);
|
||||
Destroy(gameObject, 1.2f);
|
||||
}
|
||||
}
|
||||
|
||||
public abstract partial class NoteBase
|
||||
{
|
||||
protected void SetJudgeArea()
|
||||
{
|
||||
if (noteJudgeSubmodule != null)
|
||||
{
|
||||
if (GameManager.instance.songTime > exactJudgeTime - 0.25f && !isFirstJudged)
|
||||
{
|
||||
foreach (NoteJudgeUnit unit in noteJudgeSubmodule.judgeUnitList.Where(unit => !unit.isShowingJudge))
|
||||
{
|
||||
unit.SetShowingJudge(true);
|
||||
}
|
||||
}
|
||||
|
||||
foreach (NoteJudgeUnit unit in noteJudgeSubmodule.judgeUnitList.Where(unit => unit.isShowingJudge))
|
||||
{
|
||||
unit.UpdateJudge();
|
||||
}
|
||||
|
||||
if (GameManager.instance.songTime > exactJudgeTime + 0.25f)
|
||||
{
|
||||
foreach (NoteJudgeUnit unit in noteJudgeSubmodule.judgeUnitList.Where(unit => unit.isShowingJudge))
|
||||
{
|
||||
unit.SetShowingJudge(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public int CompareTo(NoteBase other)
|
||||
{
|
||||
return exactJudgeTime.CompareTo(other.exactJudgeTime);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -239,12 +280,21 @@ namespace Ichni.RhythmGame
|
||||
{
|
||||
public enum NoteJudgeType
|
||||
{
|
||||
Perfect,
|
||||
Good,
|
||||
Bad,
|
||||
Miss,
|
||||
NotJudged
|
||||
Perfect = 0,
|
||||
Good = 1,
|
||||
Bad = 2,
|
||||
Miss = 3,
|
||||
NotJudged = -999
|
||||
}
|
||||
|
||||
public static NoteJudgeType GetLowerType(NoteJudgeType typeA, NoteJudgeType typeB)
|
||||
{
|
||||
if (typeA == NoteJudgeType.NotJudged) return typeB;
|
||||
if (typeB == NoteJudgeType.NotJudged) return typeA;
|
||||
|
||||
return typeA > typeB ? typeA : typeB;
|
||||
}
|
||||
|
||||
|
||||
public class NoteJudgeIntervals
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user