50 lines
1.6 KiB
C#
50 lines
1.6 KiB
C#
using System;
|
|
using Ichni.RhythmGame.Beatmap;
|
|
using TMPro;
|
|
using UnityEngine;
|
|
|
|
namespace Ichni.RhythmGame
|
|
{
|
|
public class TriggerConnectJudgeUnit : NoteJudgeUnit
|
|
{
|
|
#region [暴露属性字段] Properties
|
|
public GameElement connectedJudgeTrigger;
|
|
#endregion
|
|
|
|
#region [初始化] Initialization
|
|
public TriggerConnectJudgeUnit(NoteBase note, GameElement judgeTrigger) : base(note)
|
|
{
|
|
this.connectedJudgeTrigger = judgeTrigger;
|
|
}
|
|
#endregion
|
|
|
|
#region [判定逻辑覆盖] Judge Overrides
|
|
protected override GameObject GetHintImagePrefab() => GameManager.Instance.basePrefabs.triggerHint;
|
|
|
|
public override void SetShowingJudge(bool isShowing)
|
|
{
|
|
if(connectedJudgeTrigger == null) return;
|
|
|
|
base.SetShowingJudge(isShowing);
|
|
|
|
if (judgeHintImage != null)
|
|
{
|
|
judgeHintImage.GetComponent<TMP_Text>().text = connectedJudgeTrigger.elementName;
|
|
}
|
|
}
|
|
|
|
public override void UpdateJudge()
|
|
{
|
|
if(note.isFirstJudged || connectedJudgeTrigger == null) return;
|
|
Vector2 noteScreenPosition = note.noteScreenPosition;
|
|
RectTransform canvasRect = GameManager.Instance.judgeHintCanvas.GetComponent<RectTransform>();
|
|
if (RectTransformUtility.ScreenPointToLocalPointInRectangle(canvasRect, noteScreenPosition, null, out Vector2 uiPosition))
|
|
{
|
|
judgeHintImage.anchoredPosition = uiPosition;
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
}
|
|
|
|
} |