更新
This commit is contained in:
@@ -119,7 +119,7 @@ namespace Ichni.RhythmGame
|
||||
attachedGameElement.gameObject.SetActive(false);
|
||||
disableAction?.Invoke();
|
||||
}
|
||||
});
|
||||
}).AddTo(attachedGameElement);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@ namespace Ichni.RhythmGame
|
||||
|
||||
flick.Initialize(elementName, id, tags, isFirstGenerated, parentElement);
|
||||
flick.exactJudgeTime = exactJudgeTime;
|
||||
flick.availableFlickDirections = new List<Vector2>() { Vector2.left, Vector2.right };
|
||||
//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),
|
||||
@@ -85,11 +85,7 @@ namespace Ichni.RhythmGame
|
||||
float timeDifference = triggerTime - exactJudgeTime;
|
||||
|
||||
NoteJudgeType startJudgeType = GetStartJudgeType(timeDifference);
|
||||
|
||||
if (startJudgeType != NoteJudgeType.Perfect)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
RemoveFromCheckingList();
|
||||
|
||||
preJudgeType = startJudgeType;
|
||||
@@ -127,6 +123,42 @@ namespace Ichni.RhythmGame
|
||||
isFinalJudged = true;
|
||||
}
|
||||
}
|
||||
|
||||
public void ExecuteTapJudge()
|
||||
{
|
||||
RemoveFromCheckingList();
|
||||
|
||||
float triggerTime = GameManager.instance.songTime;
|
||||
float timeDifference = triggerTime - exactJudgeTime;
|
||||
|
||||
NoteJudgeType startJudgeType = GetStartJudgeType(timeDifference);
|
||||
|
||||
if (startJudgeType == NoteJudgeType.Perfect)
|
||||
{
|
||||
Perfect(triggerTime);
|
||||
GameManager.instance.playingRecorder.resultData.Add(0);
|
||||
}
|
||||
else if (startJudgeType == NoteJudgeType.Good)
|
||||
{
|
||||
Good(triggerTime);
|
||||
}
|
||||
else if (startJudgeType == NoteJudgeType.Bad)
|
||||
{
|
||||
Bad(triggerTime);
|
||||
}
|
||||
else if (startJudgeType == NoteJudgeType.Miss)
|
||||
{
|
||||
Miss(triggerTime);
|
||||
}
|
||||
|
||||
if (startJudgeType != NoteJudgeType.Miss)
|
||||
{
|
||||
noteAudioSubmodule.PlayGeneralJudgeAudios();
|
||||
}
|
||||
|
||||
isFirstJudged = true;
|
||||
isFinalJudged = true;
|
||||
}
|
||||
}
|
||||
|
||||
public partial class Flick
|
||||
|
||||
@@ -127,10 +127,6 @@ public class GameInputManager : MonoBehaviour
|
||||
|
||||
GameManager.instance.noteJudgeManager.SetNewInputUnitSwipe(id, position, isGeneric, isFirst, direction);
|
||||
}
|
||||
|
||||
// =====================================================================
|
||||
// 核心处理逻辑 (Core Processing Logic)
|
||||
// =====================================================================
|
||||
|
||||
#if UNITY_STANDALONE
|
||||
/// <summary>
|
||||
@@ -315,7 +311,7 @@ public class GameInputManager : MonoBehaviour
|
||||
if (holdingSwipe0)
|
||||
{
|
||||
Vector2 inputPosition = new Vector2(Screen.width * 0.5f, 200f);
|
||||
OnSwipe(0, inputPosition, true, Vector2.zero);
|
||||
OnSwipe(0, inputPosition, true, false, Vector2.zero);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -362,8 +358,7 @@ public class GameInputManager : MonoBehaviour
|
||||
if (_activeTouches.TryGetValue(touchId, out TouchState movedState))
|
||||
{
|
||||
OnTouch(touchId, position);
|
||||
DetectSwipe(movedState, _activeTouches[touchId].isFirstSwipe, position);
|
||||
//_activeTouches[touchId].isFirstSwipe = false;
|
||||
DetectSwipe(movedState, position);
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -401,7 +396,7 @@ public class GameInputManager : MonoBehaviour
|
||||
/// <summary>
|
||||
/// 检测划动逻辑 (无需修改)
|
||||
/// </summary>
|
||||
private void DetectSwipe(TouchState state, bool isFirst, Vector2 currentPosition)
|
||||
private void DetectSwipe(TouchState state, Vector2 currentPosition)
|
||||
{
|
||||
Vector2 swipeVector = currentPosition - state.StartPosition;
|
||||
if (swipeVector.magnitude < minSwipeDistance) return;
|
||||
@@ -411,10 +406,11 @@ public class GameInputManager : MonoBehaviour
|
||||
// 检查是否是新的划动方向
|
||||
if (Vector2.Dot(direction, state.LastSwipeDirection) <= swipeAngleThreshold)
|
||||
{
|
||||
OnSwipe(state.TouchId, state.StartPosition, false, isFirst, direction);
|
||||
OnSwipe(state.TouchId, state.StartPosition, false, state.isFirstSwipe, direction);
|
||||
state.LastSwipeDirection = direction;
|
||||
state.StartPosition = currentPosition;
|
||||
state.StartTime = Time.time;
|
||||
state.isFirstSwipe = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -74,7 +74,7 @@ namespace Ichni
|
||||
|
||||
public static void ReturnToMenu()
|
||||
{
|
||||
InformationTransistor.instance.isReturnedFromGame = true;
|
||||
//InformationTransistor.instance.isReturnedFromGame = true;
|
||||
SceneManager.LoadScene("MenuScene");
|
||||
Time.timeScale = 1f; // 确保返回时时间缩放恢复正常
|
||||
}
|
||||
|
||||
@@ -36,6 +36,9 @@ namespace Ichni
|
||||
return;
|
||||
}
|
||||
|
||||
List<InputUnitSwipe> tapSwipeList = inputUnitSwipeList.Where(x => x.isFirst).ToList();
|
||||
List<InputUnitSwipe> holdSwipeList = inputUnitSwipeList.Where(x => !x.isFirst).ToList();
|
||||
|
||||
foreach (InputUnitTap inputUnitTap in inputUnitTapList)
|
||||
{
|
||||
List<Tap> availableTaps = new List<Tap>();
|
||||
@@ -61,8 +64,8 @@ namespace Ichni
|
||||
|
||||
if (haveHold && haveTap)
|
||||
{
|
||||
List<Hold> minHolds = GetAllMinHolds(availableHolds);
|
||||
List<Tap> minTaps = GetAllMinTaps(availableTaps);
|
||||
List<Hold> minHolds = GetAllMinNotes(availableHolds);
|
||||
List<Tap> minTaps = GetAllMinNotes(availableTaps);
|
||||
Hold closestHold = minHolds[0];
|
||||
Tap closestTap = minTaps[0];
|
||||
if (closestHold.exactJudgeTime < closestTap.exactJudgeTime)
|
||||
@@ -73,7 +76,7 @@ namespace Ichni
|
||||
}
|
||||
else
|
||||
{
|
||||
GetNearestHold(minHolds, inputUnitTap.inputPosition).ExecuteStartJudge();
|
||||
GetNearestNote(minHolds, inputUnitTap.inputPosition).ExecuteStartJudge();
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -84,40 +87,64 @@ namespace Ichni
|
||||
}
|
||||
else
|
||||
{
|
||||
GetNearestTap(minTaps, inputUnitTap.inputPosition).ExecuteStartJudge();
|
||||
GetNearestNote(minTaps, inputUnitTap.inputPosition).ExecuteStartJudge();
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (haveHold)
|
||||
{
|
||||
List<Hold> minHolds = GetAllMinHolds(availableHolds);
|
||||
List<Hold> minHolds = GetAllMinNotes(availableHolds);
|
||||
if (minHolds.Count == 1)
|
||||
{
|
||||
minHolds[0].ExecuteStartJudge();
|
||||
}
|
||||
else
|
||||
{
|
||||
GetNearestHold(minHolds, inputUnitTap.inputPosition).ExecuteStartJudge();
|
||||
GetNearestNote(minHolds, inputUnitTap.inputPosition).ExecuteStartJudge();
|
||||
}
|
||||
}
|
||||
else if (haveTap)
|
||||
{
|
||||
List<Tap> minTaps = GetAllMinTaps(availableTaps);
|
||||
List<Tap> minTaps = GetAllMinNotes(availableTaps);
|
||||
if (minTaps.Count == 1)
|
||||
{
|
||||
minTaps[0].ExecuteStartJudge();
|
||||
}
|
||||
else
|
||||
{
|
||||
GetNearestTap(minTaps, inputUnitTap.inputPosition).ExecuteStartJudge();
|
||||
GetNearestNote(minTaps, inputUnitTap.inputPosition).ExecuteStartJudge();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
foreach (InputUnitSwipe inputUnitSwipe in inputUnitSwipeList)
|
||||
foreach (InputUnitSwipe tapSwipe in tapSwipeList)
|
||||
{
|
||||
List<Flick> availableFlicks = new List<Flick>();
|
||||
|
||||
foreach (Flick flick in checkingFlickList)
|
||||
{
|
||||
if (flick.CheckJudgeAvailability(tapSwipe))
|
||||
{
|
||||
availableFlicks.Add(flick);
|
||||
}
|
||||
}
|
||||
|
||||
List<Flick> minFlicks = GetAllMinNotes(availableFlicks);
|
||||
|
||||
if (minFlicks.Count == 1)
|
||||
{
|
||||
minFlicks[0].ExecuteStartJudge();
|
||||
}
|
||||
else if (minFlicks.Count > 1)
|
||||
{
|
||||
GetNearestNote(minFlicks, tapSwipe.inputPosition).ExecuteTapJudge();
|
||||
}
|
||||
}
|
||||
|
||||
foreach (InputUnitSwipe inputUnitSwipe in holdSwipeList)
|
||||
{
|
||||
List<Flick> availableFlicks = new List<Flick>();
|
||||
|
||||
foreach (Flick flick in checkingFlickList)
|
||||
{
|
||||
if (flick.CheckJudgeAvailability(inputUnitSwipe))
|
||||
@@ -200,69 +227,31 @@ namespace Ichni
|
||||
|
||||
public partial class NoteJudgeManager
|
||||
{
|
||||
private List<Tap> GetAllMinTaps(List<Tap> availableTaps)
|
||||
private List<T> GetAllMinNotes<T>(List<T> availableFlicks) where T : NoteBase
|
||||
{
|
||||
List<Tap> minTaps = new List<Tap>();
|
||||
List<T> minFlicks = new List<T>();
|
||||
float minTime = float.MaxValue;
|
||||
foreach (Tap tap in availableTaps)
|
||||
foreach (T flick in availableFlicks)
|
||||
{
|
||||
if (tap.exactJudgeTime < minTime)
|
||||
if (flick.exactJudgeTime < minTime)
|
||||
{
|
||||
minTime = tap.exactJudgeTime;
|
||||
minTaps.Clear();
|
||||
minTaps.Add(tap);
|
||||
minTime = flick.exactJudgeTime;
|
||||
minFlicks.Clear();
|
||||
minFlicks.Add(flick);
|
||||
}
|
||||
else if (Mathf.Approximately(tap.exactJudgeTime, minTime))
|
||||
else if (Mathf.Approximately(flick.exactJudgeTime, minTime))
|
||||
{
|
||||
minTaps.Add(tap);
|
||||
minFlicks.Add(flick);
|
||||
}
|
||||
}
|
||||
|
||||
return minTaps;
|
||||
return minFlicks;
|
||||
}
|
||||
|
||||
private List<Hold> GetAllMinHolds(List<Hold> availableHolds)
|
||||
{
|
||||
List<Hold> minHolds = new List<Hold>();
|
||||
float minTime = float.MaxValue;
|
||||
foreach (Hold hold in availableHolds)
|
||||
{
|
||||
if (hold.exactJudgeTime < minTime)
|
||||
{
|
||||
minTime = hold.exactJudgeTime;
|
||||
minHolds.Clear();
|
||||
minHolds.Add(hold);
|
||||
}
|
||||
else if (Mathf.Approximately(hold.exactJudgeTime, minTime))
|
||||
{
|
||||
minHolds.Add(hold);
|
||||
}
|
||||
}
|
||||
return minHolds;
|
||||
}
|
||||
|
||||
private Tap GetNearestTap(List<Tap> notes, Vector2 inputPosition)
|
||||
private T GetNearestNote<T>(List<T> notes, Vector2 inputPosition) where T : NoteBase
|
||||
{
|
||||
float minDistance = float.MaxValue;
|
||||
Tap closestNote = null;
|
||||
foreach (Tap note in notes)
|
||||
{
|
||||
float distance = Vector2.Distance(inputPosition, note.noteScreenPosition);
|
||||
if (distance < minDistance)
|
||||
{
|
||||
minDistance = distance;
|
||||
closestNote = note;
|
||||
}
|
||||
}
|
||||
|
||||
return closestNote;
|
||||
}
|
||||
|
||||
private Hold GetNearestHold(List<Hold> notes, Vector2 inputPosition)
|
||||
{
|
||||
float minDistance = float.MaxValue;
|
||||
Hold closestNote = null;
|
||||
foreach (Hold note in notes)
|
||||
T closestNote = null;
|
||||
foreach (T note in notes)
|
||||
{
|
||||
float distance = Vector2.Distance(inputPosition, note.noteScreenPosition);
|
||||
if (distance < minDistance)
|
||||
|
||||
@@ -12,6 +12,7 @@ namespace Ichni
|
||||
public static InformationTransistor instance;
|
||||
|
||||
public bool isReturnedFromGame;
|
||||
public bool isReturnedFromTutorial;
|
||||
|
||||
public ChapterSelectionUnit chapter;
|
||||
public SongItemData song;
|
||||
@@ -30,6 +31,7 @@ namespace Ichni
|
||||
instance = this;
|
||||
DontDestroyOnLoad(gameObject);
|
||||
isReturnedFromGame = false;
|
||||
isReturnedFromTutorial = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -54,6 +54,13 @@ namespace Ichni
|
||||
new SongSelectionRecord(InformationTransistor.instance.song, InformationTransistor.instance.difficulty));
|
||||
songSelectionUIPage.FadeIn();
|
||||
}
|
||||
else if (InformationTransistor.instance.isReturnedFromTutorial)
|
||||
{
|
||||
startUIPage.mainCanvasGroup.gameObject.SetActive(false);
|
||||
ChapterSelectionManager.instance.currentChapter = InformationTransistor.instance.chapter;
|
||||
MenuAudioManager.instance.audioContainer.SetSwitch(ChapterSelectionManager.instance.currentChapter.chapterSwitch);
|
||||
storyUIPage.FadeIn();
|
||||
}
|
||||
|
||||
Application.targetFrameRate = SettingsManager.instance.gameSettings.targetFrame;
|
||||
asyncOperation = SceneManager.LoadSceneAsync("GameScene");
|
||||
@@ -63,7 +70,14 @@ namespace Ichni
|
||||
|
||||
public partial class MenuManager
|
||||
{
|
||||
public void TestEnterGame()
|
||||
public void EnterGame()
|
||||
{
|
||||
InformationTransistor.instance.isReturnedFromTutorial = false;
|
||||
InformationTransistor.instance.isReturnedFromGame = true;
|
||||
EnterGameScene();
|
||||
}
|
||||
|
||||
public void EnterGameScene()
|
||||
{
|
||||
MenuInputManager.instance.gameInput.Menu.Disable();
|
||||
asyncOperation.allowSceneActivation = true;
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using DG.Tweening;
|
||||
using Ichni.Menu;
|
||||
using TMPro;
|
||||
using UniRx;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
@@ -36,13 +38,14 @@ namespace Ichni.Story.UI
|
||||
SongItemData song = ChapterSelectionManager.instance.tutorialCollection.songs[chapter.chapterIndex];
|
||||
DifficultyData difficulty = song.difficultyDataList[0];
|
||||
InformationTransistor.instance.SetInformation(chapter, song, difficulty);
|
||||
InformationTransistor.instance.isReturnedFromTutorial = true;
|
||||
InformationTransistor.instance.isReturnedFromGame = false;
|
||||
|
||||
MenuAudioManager.instance.audioContainer.PlaySoundFX("EnterToGame");
|
||||
MenuAudioManager.instance.audioContainer.StopEvent("PlayPreview");
|
||||
|
||||
DOTween.KillAll();
|
||||
|
||||
MenuManager.instance.TestEnterGame();
|
||||
Observable.Timer(TimeSpan.FromSeconds(0.6f)).Subscribe(_ => { MenuManager.instance.EnterGameScene(); });
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -53,7 +53,7 @@ namespace Ichni.Menu
|
||||
MenuManager.instance.transitionUIPage.FadeIn();
|
||||
Observable.Timer(TimeSpan.FromSeconds(0.6f)).Subscribe(_ =>
|
||||
{
|
||||
MenuManager.instance.TestEnterGame();
|
||||
MenuManager.instance.EnterGame();
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -62,7 +62,7 @@ namespace Ichni.Menu
|
||||
|
||||
Observable.Timer(TimeSpan.FromSeconds(0.6f)).Subscribe(_ =>
|
||||
{
|
||||
MenuManager.instance.TestEnterGame();
|
||||
MenuManager.instance.EnterGame();
|
||||
});
|
||||
}
|
||||
else
|
||||
|
||||
Reference in New Issue
Block a user