This commit is contained in:
SoulliesOfficial
2025-07-21 05:42:20 -04:00
parent e483cfe502
commit bae0bfbc20
533 changed files with 172709 additions and 125965 deletions

View File

@@ -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;
}
}