perf
This commit is contained in:
@@ -1,9 +1,11 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Dreamteck.Splines;
|
||||
using Ichni.RhythmGame.Beatmap;
|
||||
using Lean.Pool;
|
||||
using UniRx;
|
||||
using Unity.VisualScripting;
|
||||
using UnityEngine;
|
||||
|
||||
@@ -11,13 +13,8 @@ namespace Ichni.RhythmGame
|
||||
{
|
||||
public partial class Flick : NoteBase
|
||||
{
|
||||
public static readonly NoteJudgeIntervals judgeIntervals = new NoteJudgeIntervals(
|
||||
new TimeInterval(-0.15f, -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 float flickBuffer = 0.5f;
|
||||
|
||||
public static Flick GenerateElement(string elementName, Guid id, List<string> tags, bool isFirstGenerated,
|
||||
GameElement parentElement, float exactJudgeTime, List<Vector2> directions)
|
||||
@@ -26,7 +23,11 @@ namespace Ichni.RhythmGame
|
||||
|
||||
flick.Initialize(elementName, id, tags, isFirstGenerated, parentElement);
|
||||
flick.exactJudgeTime = exactJudgeTime;
|
||||
flick.availableFlickDirections = directions;
|
||||
flick.availableFlickDirections = new List<Vector2>() { Vector2.left, Vector2.right };
|
||||
flick.judgeIntervals = new NoteJudgeIntervals(
|
||||
new TimeInterval(-0.15f, -0.15f), new TimeInterval(-0.15f, -0.15f),
|
||||
new TimeInterval(-0.15f, -0.15f), new TimeInterval(-0.15f, 0.15f),
|
||||
new TimeInterval(0.15f, 0.15f), new TimeInterval(0.15f, 0.15f), 0.15f);
|
||||
|
||||
if (parentElement.TryGetComponent(out Track track))
|
||||
{
|
||||
@@ -48,13 +49,83 @@ namespace Ichni.RhythmGame
|
||||
flick.track = null;
|
||||
flick.isOnTrack = false;
|
||||
}
|
||||
|
||||
|
||||
return flick;
|
||||
}
|
||||
|
||||
public void SetFirstJudge(Vector3 deltaPosition)
|
||||
protected override void Update()
|
||||
{
|
||||
float songTime = GameManager.instance.songTime;
|
||||
|
||||
if (!isFirstJudged && !isDuringJudging &&
|
||||
songTime >= exactJudgeTime + judgeIntervals.beforeMiss.intervalStart &&
|
||||
!GameManager.instance.inputManager.checkingFlickList.Contains(this))
|
||||
{
|
||||
isDuringJudging = true;
|
||||
GameManager.instance.inputManager.checkingFlickList.Add(this);
|
||||
}
|
||||
|
||||
base.Update();
|
||||
}
|
||||
|
||||
protected override void RemoveFromCheckingList()
|
||||
{
|
||||
GameManager.instance.inputManager.checkingFlickList.Remove(this);
|
||||
}
|
||||
|
||||
public override void ExecuteStartJudge()
|
||||
{
|
||||
base.ExecuteStartJudge();
|
||||
|
||||
isFinalJudged = true;
|
||||
|
||||
if (GameManager.instance.inputManager.checkingFlickList.Contains(this))
|
||||
{
|
||||
GameManager.instance.inputManager.checkingFlickList.Remove(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public partial class Flick
|
||||
{
|
||||
public bool CheckJudgeAvailability(InputUnitSwipe inputUnitSwipe)
|
||||
{
|
||||
return noteJudgeSubmodule.judgeUnitList.All(judgeUnit => judgeUnit.CheckJudgeAvailability(inputUnitSwipe));
|
||||
}
|
||||
|
||||
public bool CheckSwipeDirection(Vector2 screenSwipeDirection)
|
||||
{
|
||||
Camera gameCamera = GameManager.instance.cameraManager.gameCamera.gameCamera;
|
||||
|
||||
foreach (Vector2 localDir in availableFlickDirections)
|
||||
{
|
||||
Vector3 worldDirection = noteVisual.transform.TransformDirection(localDir.normalized);
|
||||
Vector3 noteOriginWorld = noteVisual.transform.position;
|
||||
Vector3 noteTargetWorld = noteOriginWorld + worldDirection;
|
||||
|
||||
Vector3 screenOrigin = gameCamera.WorldToScreenPoint(noteOriginWorld);
|
||||
Vector3 screenTarget = gameCamera.WorldToScreenPoint(noteTargetWorld);
|
||||
|
||||
Vector2 noteScreenDirection = new Vector2(screenTarget.x - screenOrigin.x, screenTarget.y - screenOrigin.y).normalized;
|
||||
|
||||
if (noteScreenDirection.sqrMagnitude < 0.01f)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
float dotProduct = Vector2.Dot(screenSwipeDirection, noteScreenDirection);
|
||||
|
||||
// 4. 检查点积是否满足阈值
|
||||
if (dotProduct >= flickBuffer)
|
||||
{
|
||||
// 匹配成功!无需再检查其他方向。
|
||||
Debug.Log($"匹配成功! 输入方向 {screenSwipeDirection} 匹配了本地方向 {localDir} (屏幕投影: {noteScreenDirection}), 点积: {dotProduct}");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
Debug.Log($"匹配失败. 输入方向 {screenSwipeDirection} 未匹配任何允许的方向。");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@ using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Dreamteck.Splines;
|
||||
using Ichni.RhythmGame.Beatmap;
|
||||
using UniRx;
|
||||
using Unity.VisualScripting;
|
||||
using UnityEngine;
|
||||
|
||||
@@ -14,6 +15,11 @@ namespace Ichni.RhythmGame
|
||||
public float holdEndTime;
|
||||
public float holdingTime;
|
||||
public bool isHolding;
|
||||
public float holdingBufferTime;
|
||||
public float bufferTimer;
|
||||
|
||||
public NoteJudgeType preJudgeType;
|
||||
public NoteJudgeType postJudgeType;
|
||||
|
||||
public static Hold GenerateElement(string elementName, Guid id, List<string> tags, bool isFirstGenerated,
|
||||
GameElement parentElement, float exactJudgeTime, float holdEndTime)
|
||||
@@ -24,7 +30,14 @@ namespace Ichni.RhythmGame
|
||||
hold.exactJudgeTime = exactJudgeTime;
|
||||
hold.holdEndTime = holdEndTime;
|
||||
hold.holdingTime = 0;
|
||||
|
||||
hold.holdingBufferTime = 0.1f;
|
||||
hold.judgeIntervals = new NoteJudgeIntervals(
|
||||
new TimeInterval(-0.15f, -0.15f), new TimeInterval(-0.15f, -0.125f),
|
||||
new TimeInterval(-0.125f, -0.1f), new TimeInterval(-0.1f, 0.1f),
|
||||
new TimeInterval(0.1f, 0.125f), new TimeInterval(0.125f, 0.15f), 0.15f);
|
||||
hold.preJudgeType = NoteJudgeType.NotJudged;
|
||||
hold.postJudgeType = NoteJudgeType.NotJudged;
|
||||
|
||||
if (parentElement.TryGetComponent(out Track track))
|
||||
{
|
||||
if (track.trackTimeSubmodule != null)
|
||||
@@ -49,6 +62,70 @@ namespace Ichni.RhythmGame
|
||||
|
||||
return hold;
|
||||
}
|
||||
|
||||
public override void ExecuteStartJudge()
|
||||
{
|
||||
float triggerTime = GameManager.instance.songTime;
|
||||
float timeDifference = triggerTime - exactJudgeTime;
|
||||
|
||||
NoteJudgeType startJudgeType = GetStartJudgeType(timeDifference);
|
||||
preJudgeType = startJudgeType;
|
||||
|
||||
isFirstJudged = true;
|
||||
isHolding = true;
|
||||
|
||||
Debug.Log($"Hold Note Start Judge: {startJudgeType} at {triggerTime}");
|
||||
}
|
||||
|
||||
public void ExecuteProcessJudge()
|
||||
{
|
||||
isHolding = true;
|
||||
}
|
||||
|
||||
public void ExecuteFinalJudge()
|
||||
{
|
||||
float triggerTime = GameManager.instance.songTime;
|
||||
float timeDifference = holdEndTime - triggerTime;
|
||||
|
||||
if (timeDifference <= 0.1f)
|
||||
{
|
||||
postJudgeType = NoteJudgeType.Perfect;
|
||||
}
|
||||
else if (timeDifference <= 0.125f)
|
||||
{
|
||||
postJudgeType = NoteJudgeType.Good;
|
||||
}
|
||||
else
|
||||
{
|
||||
postJudgeType = NoteJudgeType.Bad;
|
||||
}
|
||||
|
||||
Debug.Log($"Hold Note Final Judge: {postJudgeType} at {triggerTime} of difference {timeDifference}");
|
||||
|
||||
NoteJudgeType finalJudge = NoteBase.GetLowerType(preJudgeType, postJudgeType);
|
||||
|
||||
if (finalJudge == NoteJudgeType.Perfect)
|
||||
{
|
||||
Perfect(triggerTime);
|
||||
}
|
||||
else if (finalJudge == NoteJudgeType.Good)
|
||||
{
|
||||
Good(triggerTime);
|
||||
}
|
||||
else if (finalJudge == NoteJudgeType.Bad)
|
||||
{
|
||||
Bad(triggerTime);
|
||||
}
|
||||
else if (finalJudge == NoteJudgeType.Miss)
|
||||
{
|
||||
Miss(triggerTime);
|
||||
}
|
||||
|
||||
if (finalJudge != NoteJudgeType.Miss)
|
||||
{
|
||||
noteAudioSubmodule.PlayGeneralJudgeAudios();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public partial class Hold
|
||||
@@ -60,7 +137,7 @@ namespace Ichni.RhythmGame
|
||||
base.UpdateNoteInMovableTrack();
|
||||
}
|
||||
|
||||
if (noteVisual is NoteVisualBaseHold noteVisualHold)
|
||||
if (noteVisual is INoteVisualHold noteVisualHold)
|
||||
{
|
||||
noteVisualHold.UpdateHoldInMovableTrack();
|
||||
}
|
||||
@@ -69,11 +146,17 @@ namespace Ichni.RhythmGame
|
||||
public override void UpdateNoteInStaticTrack()
|
||||
{
|
||||
base.UpdateNoteInStaticTrack();
|
||||
if (noteVisual is NoteVisualBaseHold noteVisualHold)
|
||||
|
||||
if (noteVisual is INoteVisualHold noteVisualHold)
|
||||
{
|
||||
noteVisualHold.UpdateHoldInStaticTrack();
|
||||
}
|
||||
}
|
||||
|
||||
protected override void RemoveFromCheckingList()
|
||||
{
|
||||
GameManager.instance.inputManager.checkingHoldList.Remove(this);
|
||||
}
|
||||
}
|
||||
|
||||
public partial class Hold
|
||||
@@ -89,100 +172,102 @@ namespace Ichni.RhythmGame
|
||||
matchedBM = new Hold_BM(elementName, elementGuid, tags, parentElement.matchedBM as GameElement_BM, exactJudgeTime, holdEndTime);
|
||||
}
|
||||
}
|
||||
|
||||
public partial class Hold
|
||||
{
|
||||
public bool CheckJudgeAvailability(InputUnitTap inputUnitTap)
|
||||
{
|
||||
return !isFirstJudged && noteJudgeSubmodule.judgeUnitList.All(judgeUnit => judgeUnit.CheckJudgeAvailability(inputUnitTap));
|
||||
}
|
||||
|
||||
public bool CheckJudgeAvailability(InputUnitTouch inputUnitTouch)
|
||||
{
|
||||
return isFirstJudged && noteJudgeSubmodule.judgeUnitList.All(judgeUnit => judgeUnit.CheckJudgeAvailability(inputUnitTouch));
|
||||
}
|
||||
}
|
||||
|
||||
public partial class Hold
|
||||
{
|
||||
protected override void Update()
|
||||
{
|
||||
if (!GameManager.instance.audioManager.isUpdating)
|
||||
float songTime = GameManager.instance.songTime;
|
||||
|
||||
if (!isFirstJudged && !isDuringJudging &&
|
||||
songTime >= exactJudgeTime + judgeIntervals.beforeMiss.intervalStart &&
|
||||
!GameManager.instance.inputManager.checkingHoldList.Contains(this))
|
||||
{
|
||||
return;
|
||||
isDuringJudging = true;
|
||||
GameManager.instance.inputManager.checkingHoldList.Add(this);
|
||||
}
|
||||
|
||||
float songTime = GameManager.instance.songTime;
|
||||
|
||||
if (isFirstJudged && songTime < exactJudgeTime)
|
||||
if (!GameManager.instance.audioManager.isUpdating || isFinalJudged)
|
||||
{
|
||||
isFirstJudged = false;
|
||||
isHolding = false;
|
||||
isFinalJudged = false;
|
||||
holdingTime = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
if (isHolding)
|
||||
{
|
||||
holdingTime = songTime - exactJudgeTime;
|
||||
bufferTimer = holdingBufferTime;
|
||||
}
|
||||
else if(isFirstJudged)
|
||||
{
|
||||
bufferTimer -= Time.deltaTime;
|
||||
}
|
||||
|
||||
/*
|
||||
if (isHolding && songTime > holdEndTime)
|
||||
{
|
||||
isHolding = false;
|
||||
isFinalJudged = true;
|
||||
noteAudioSubmodule.PlayNoteJudgeAudios(EditorManager.instance.currentJudgeType);
|
||||
}
|
||||
|
||||
if (!isFirstJudged && songTime >= exactJudgeTime)
|
||||
{
|
||||
if (!isFirstJudged)
|
||||
{
|
||||
isFirstJudged = true;
|
||||
}
|
||||
|
||||
if (isFirstJudged && !isHolding && songTime < holdEndTime)
|
||||
{
|
||||
isHolding = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (noteJudgeSubmodule != null && !EditorManager.instance.cameraManager.isSceneCameraActive)
|
||||
{
|
||||
foreach (NoteJudgeUnit unit in noteJudgeSubmodule.judgeUnitList.Where(unit => unit.isShowingJudge))
|
||||
{
|
||||
unit.UpdateJudge();
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
noteScreenPosition = GameManager.instance.cameraManager.gameCamera.gameCamera.WorldToScreenPoint(noteVisual.transform.position);
|
||||
|
||||
/*
|
||||
if (noteVisual != null)
|
||||
{
|
||||
noteVisual.effectSubmodule.effectCollection["Generate"].ForEach(e => e.UpdateEffect(exactJudgeTime));
|
||||
noteVisual.effectSubmodule.effectCollection["GeneralJudge"].ForEach(e => e.UpdateEffect(holdEndTime));
|
||||
noteVisual.effectSubmodule.effectCollection["Holding"].ForEach(e => e.UpdateEffect(exactJudgeTime));
|
||||
|
||||
switch (EditorManager.instance.currentJudgeType)
|
||||
{
|
||||
case NoteJudgeType.Perfect:
|
||||
noteVisual.effectSubmodule.effectCollection["Perfect"].ForEach(e => e.UpdateEffect(holdEndTime));
|
||||
break;
|
||||
case NoteJudgeType.Good:
|
||||
noteVisual.effectSubmodule.effectCollection["Good"].ForEach(e => e.UpdateEffect(holdEndTime));
|
||||
break;
|
||||
case NoteJudgeType.Bad:
|
||||
noteVisual.effectSubmodule.effectCollection["Bad"].ForEach(e => e.UpdateEffect(holdEndTime));
|
||||
break;
|
||||
case NoteJudgeType.Miss:
|
||||
noteVisual.effectSubmodule.effectCollection["Miss"].ForEach(e => e.UpdateEffect(holdEndTime));
|
||||
break;
|
||||
}
|
||||
|
||||
if (EditorManager.instance.cameraManager.haveGameCamera)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
private void LateUpdate()
|
||||
{
|
||||
if (isOnTrack)
|
||||
{
|
||||
UpdateNoteInTrack();
|
||||
}
|
||||
|
||||
if (isDuringJudging)
|
||||
{
|
||||
noteScreenPosition = GameManager.instance.cameraManager.gameCamera.gameCamera.WorldToScreenPoint(noteVisual.transform.position);
|
||||
}
|
||||
|
||||
foreach (EffectBase e in noteVisual.effectSubmodule.effectCollection["Generate"])
|
||||
{
|
||||
e.UpdateEffect(exactJudgeTime);
|
||||
}
|
||||
|
||||
foreach (EffectBase e in noteVisual.effectSubmodule.effectCollection["StartHold"])
|
||||
{
|
||||
e.UpdateEffect(exactJudgeTime);
|
||||
}
|
||||
|
||||
foreach (EffectBase e in noteVisual.effectSubmodule.effectCollection["Holding"])
|
||||
{
|
||||
e.UpdateEffect(exactJudgeTime);
|
||||
}
|
||||
|
||||
if (songTime > holdEndTime)
|
||||
{
|
||||
isHolding = false;
|
||||
isFinalJudged = true;
|
||||
ExecuteFinalJudge();
|
||||
RemoveFromCheckingList();
|
||||
}
|
||||
|
||||
if (isFirstJudged && bufferTimer < 0f)
|
||||
{
|
||||
isHolding = false;
|
||||
isFinalJudged = true;
|
||||
ExecuteFinalJudge();
|
||||
RemoveFromCheckingList();
|
||||
}
|
||||
|
||||
if (!isFirstJudged && GameManager.instance.songTime > exactJudgeTime + judgeIntervals.afterMiss)
|
||||
{
|
||||
Miss(exactJudgeTime + judgeIntervals.afterMiss);
|
||||
isFirstJudged = true;
|
||||
isFinalJudged = true;
|
||||
RemoveFromCheckingList();
|
||||
}
|
||||
}
|
||||
|
||||
private void LateUpdate()
|
||||
{
|
||||
isHolding = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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
|
||||
{
|
||||
|
||||
@@ -5,6 +5,7 @@ using System.Linq;
|
||||
using Dreamteck.Splines;
|
||||
using Ichni.RhythmGame.Beatmap;
|
||||
using Lean.Pool;
|
||||
using UniRx;
|
||||
using Unity.VisualScripting;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Serialization;
|
||||
@@ -25,8 +26,8 @@ namespace Ichni.RhythmGame
|
||||
stay.preJudgeType = NoteJudgeType.NotJudged;
|
||||
stay.judgeIntervals = new NoteJudgeIntervals(
|
||||
new TimeInterval(-0.15f, -0.15f), new TimeInterval(-0.15f, -0.15f),
|
||||
new TimeInterval(-0.15f, -0.15f), new TimeInterval(-0.15f, 0.125f),
|
||||
new TimeInterval(0.125f, 0.15f), new TimeInterval(0.15f, 0.15f), 0.15f);
|
||||
new TimeInterval(-0.15f, -0.15f), new TimeInterval(-0.15f, 0.15f),
|
||||
new TimeInterval(0.15f, 0.15f), new TimeInterval(0.15f, 0.15f), 0.15f);
|
||||
|
||||
if (parentElement.TryGetComponent(out Track track))
|
||||
{
|
||||
@@ -56,19 +57,24 @@ namespace Ichni.RhythmGame
|
||||
{
|
||||
float songTime = GameManager.instance.songTime;
|
||||
|
||||
if (!isFirstJudged &&
|
||||
if (!isFirstJudged && !isDuringJudging &&
|
||||
songTime >= exactJudgeTime + judgeIntervals.beforeMiss.intervalStart &&
|
||||
!GameManager.instance.inputManager.checkingStayList.Contains(this))
|
||||
{
|
||||
isDuringJudging = true;
|
||||
GameManager.instance.inputManager.checkingStayList.Add(this);
|
||||
}
|
||||
|
||||
ExecuteFinalJudge(songTime);
|
||||
|
||||
base.Update();
|
||||
ExecuteFinalJudge(songTime);
|
||||
}
|
||||
|
||||
protected override void RemoveFromCheckingList()
|
||||
{
|
||||
GameManager.instance.inputManager.checkingStayList.Remove(this);
|
||||
}
|
||||
|
||||
public override NoteJudgeType GetStartJudgeType(float timeDifference)
|
||||
protected override NoteJudgeType GetStartJudgeType(float timeDifference)
|
||||
{
|
||||
return judgeIntervals.GetNoteJudgeType(timeDifference);
|
||||
}
|
||||
@@ -137,9 +143,9 @@ namespace Ichni.RhythmGame
|
||||
|
||||
public partial class Stay
|
||||
{
|
||||
public bool CheckJudgeAvailability(InputUnitSlide inputUnitSlide)
|
||||
public bool CheckJudgeAvailability(InputUnitTouch inputUnitTouch)
|
||||
{
|
||||
return noteJudgeSubmodule.judgeUnitList.All(judgeUnit => judgeUnit.CheckJudgeAvailability(inputUnitSlide));
|
||||
return noteJudgeSubmodule.judgeUnitList.All(judgeUnit => judgeUnit.CheckJudgeAvailability(inputUnitTouch));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -52,18 +52,24 @@ namespace Ichni.RhythmGame
|
||||
protected override void Update()
|
||||
{
|
||||
float songTime = GameManager.instance.songTime;
|
||||
|
||||
if (!isFirstJudged &&
|
||||
|
||||
if (!isFirstJudged && !isDuringJudging &&
|
||||
songTime >= exactJudgeTime + judgeIntervals.beforeMiss.intervalStart &&
|
||||
!GameManager.instance.inputManager.checkingTapList.Contains(this))
|
||||
{
|
||||
isDuringJudging = true;
|
||||
GameManager.instance.inputManager.checkingTapList.Add(this);
|
||||
}
|
||||
|
||||
base.Update();
|
||||
}
|
||||
|
||||
public override NoteJudgeType GetStartJudgeType(float timeDifference)
|
||||
protected override void RemoveFromCheckingList()
|
||||
{
|
||||
GameManager.instance.inputManager.checkingTapList.Remove(this);
|
||||
}
|
||||
|
||||
protected override NoteJudgeType GetStartJudgeType(float timeDifference)
|
||||
{
|
||||
return judgeIntervals.GetNoteJudgeType(timeDifference);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user