2025-06-03 02:42:28 -04:00
|
|
|
using System.Collections;
|
|
|
|
|
using Ichni.RhythmGame.Beatmap;
|
|
|
|
|
using UnityEngine;
|
|
|
|
|
|
|
|
|
|
namespace Ichni.RhythmGame
|
|
|
|
|
{
|
|
|
|
|
public class TouchAreaJudgeUnit : NoteJudgeUnit
|
|
|
|
|
{
|
|
|
|
|
public float areaRadius;
|
2025-07-26 04:20:25 -04:00
|
|
|
|
|
|
|
|
protected override GameObject GetHintImagePrefab()
|
|
|
|
|
{
|
|
|
|
|
return GameManager.instance.basePrefabs.areaHint;
|
|
|
|
|
}
|
2025-06-03 02:42:28 -04:00
|
|
|
|
|
|
|
|
private float CurrentScreenRatio() => Screen.width / 1920f;
|
2025-07-26 04:20:25 -04:00
|
|
|
|
2025-06-03 02:42:28 -04:00
|
|
|
public TouchAreaJudgeUnit(NoteBase note, float areaRadius) : base(note)
|
|
|
|
|
{
|
|
|
|
|
this.areaRadius = areaRadius;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override void UpdateJudge()
|
|
|
|
|
{
|
2025-07-26 04:20:25 -04:00
|
|
|
if (note.isFirstJudged) return;
|
2025-06-03 02:42:28 -04:00
|
|
|
Vector2 noteScreenPosition = note.noteScreenPosition;
|
|
|
|
|
RectTransform canvasRect = GameManager.instance.judgeHintCanvas.GetComponent<RectTransform>();
|
|
|
|
|
if (RectTransformUtility.ScreenPointToLocalPointInRectangle(canvasRect, noteScreenPosition, null, out Vector2 uiPosition))
|
|
|
|
|
{
|
|
|
|
|
judgeHintImage.anchoredPosition = uiPosition;
|
|
|
|
|
judgeHintImage.sizeDelta = new Vector2(areaRadius * 2, areaRadius * 2) * CurrentScreenRatio();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override NoteJudgeUnit_BM ConvertToBM()
|
|
|
|
|
{
|
|
|
|
|
return new TouchAreaJudgeUnit_BM(areaRadius);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override bool CheckJudgeAvailability(InputUnit inputUnit)
|
|
|
|
|
{
|
|
|
|
|
Vector2 inputScreenPosition = inputUnit.inputPosition;
|
|
|
|
|
Vector2 noteScreenPosition = note.noteScreenPosition;
|
2025-07-26 04:20:25 -04:00
|
|
|
|
2025-06-03 02:42:28 -04:00
|
|
|
float distance = Vector2.Distance(inputScreenPosition, noteScreenPosition);
|
2025-07-26 04:20:25 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
if (distance <= areaRadius)
|
2025-06-03 02:42:28 -04:00
|
|
|
{
|
2025-07-21 05:42:20 -04:00
|
|
|
if (inputUnit is InputUnitSwipe swipe && note is Flick flick)
|
|
|
|
|
{
|
2025-07-26 04:20:25 -04:00
|
|
|
return flick.CheckSwipeDirection(swipe);
|
2025-07-21 05:42:20 -04:00
|
|
|
}
|
2025-07-26 04:20:25 -04:00
|
|
|
|
|
|
|
|
Debug.Log("Input Position: " + inputScreenPosition +
|
|
|
|
|
", Note Position: " + noteScreenPosition +
|
|
|
|
|
", Distance: " + distance +
|
|
|
|
|
", Area Radius: " + areaRadius +
|
|
|
|
|
", Current Screen Ratio: " + CurrentScreenRatio());
|
|
|
|
|
|
2025-06-03 02:42:28 -04:00
|
|
|
return true;
|
|
|
|
|
}
|
2025-07-26 04:20:25 -04:00
|
|
|
|
2025-06-03 02:42:28 -04:00
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
namespace Beatmap
|
|
|
|
|
{
|
|
|
|
|
public class TouchAreaJudgeUnit_BM : NoteJudgeUnit_BM
|
|
|
|
|
{
|
|
|
|
|
public float areaRadius;
|
|
|
|
|
|
|
|
|
|
public TouchAreaJudgeUnit_BM()
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public TouchAreaJudgeUnit_BM(float areaRadius)
|
|
|
|
|
{
|
|
|
|
|
this.areaRadius = areaRadius;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override NoteJudgeUnit ConvertToGameType(NoteBase attachedNote)
|
|
|
|
|
{
|
2025-07-26 04:20:25 -04:00
|
|
|
#if UNITY_EDITOR || UNITY_STANDALONE
|
|
|
|
|
return new FullScreenNearTimeJudgeUnit(attachedNote);
|
|
|
|
|
#elif UNITY_ANDROID || UNITY_IOS
|
|
|
|
|
return new TouchAreaJudgeUnit(attachedNote, areaRadius);//TODO:改这里
|
|
|
|
|
#endif
|
2025-06-03 02:42:28 -04:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|