JudgeTrigger

外部区域判定区
This commit is contained in:
SoulliesOfficial
2025-04-02 18:18:25 -04:00
parent e528cdea9c
commit 5c0e9c5a76
39 changed files with 818 additions and 51 deletions

View File

@@ -4,6 +4,7 @@ using Ichni.RhythmGame;
using Michsky.MUIP;
using TMPro;
using UnityEngine;
using UnityEngine.InputSystem;
using UnityEngine.Serialization;
using UnityEngine.UI;
@@ -94,7 +95,23 @@ namespace Ichni.Editor
public void SelectGameElement()
{
EditorManager.instance.operationManager.SelectElement(connectedGameElement);
if (Keyboard.current.leftCtrlKey.isPressed)
{
if (!isSelected)
{
EditorManager.instance.operationManager.AddSelectElement(connectedGameElement);
}
else
{
EditorManager.instance.operationManager.RemoveSelectElement(connectedGameElement);
}
}
else
{
EditorManager.instance.operationManager.ClearSelectedElements();
EditorManager.instance.operationManager.AddSelectElement(connectedGameElement);
}
EditorManager.instance.uiManager.inspector.SetInspector(connectedGameElement);
EditorManager.instance.timeline.SetTimeLine(connectedGameElement); // TODO: Error
}

View File

@@ -39,7 +39,7 @@ namespace Ichni.Editor
{
private void GenerateSaveClipWindow()
{
GameElement currentElement = EditorManager.instance.operationManager.currentSelectedElement;
GameElement currentElement = EditorManager.instance.operationManager.currentSelectedElements[0];
if (currentElement == null)
{
@@ -69,7 +69,7 @@ namespace Ichni.Editor
private void GenerateLoadClipWindow()
{
GameElement currentElement = EditorManager.instance.operationManager.currentSelectedElement;
GameElement currentElement = EditorManager.instance.operationManager.currentSelectedElements[0];
if (currentElement == null)
{

View File

@@ -0,0 +1,56 @@
using System.Collections;
using System.Collections.Generic;
using Ichni.RhythmGame.Beatmap;
using UnityEngine;
namespace Ichni.RhythmGame
{
public partial class NoteJudgeTriggerSubmodule : SubmoduleBase
{
public List<NoteBase> connectedNotes;
public NoteJudgeTriggerSubmodule(GameElement attachedGameElement) : base(attachedGameElement)
{
connectedNotes = new List<NoteBase>();
(attachedGameElement as IHaveNoteJudgeTriggerSubmodule).noteJudgeTriggerSubmodule = this;
}
public override void SaveBM()
{
matchedBM = new NoteJudgeTriggerSubmodule_BM(attachedGameElement);
}
}
public interface IHaveNoteJudgeTriggerSubmodule
{
public NoteJudgeTriggerSubmodule noteJudgeTriggerSubmodule { get; set; }
}
namespace Beatmap
{
public class NoteJudgeTriggerSubmodule_BM : Submodule_BM
{
public NoteJudgeTriggerSubmodule_BM()
{
}
public NoteJudgeTriggerSubmodule_BM(GameElement attachedElement) : base(attachedElement)
{
}
public override void ExecuteBM()
{
attachedElement = GameElement_BM.GetElement(attachedElementGuid);
(attachedElement as IHaveNoteJudgeTriggerSubmodule).noteJudgeTriggerSubmodule = new NoteJudgeTriggerSubmodule(attachedElement);
}
public override void DuplicateBM(GameElement attached)
{
(attached as IHaveNoteJudgeTriggerSubmodule).noteJudgeTriggerSubmodule = new NoteJudgeTriggerSubmodule(attached);
}
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: fff7882e84c5b461bb7cd0a3c3657d9d
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -91,7 +91,6 @@ namespace Ichni.RhythmGame
{
public override void SetUpInspector()
{
IHaveInspection inspector = EditorManager.instance.uiManager.inspector;
var container = inspector.GenerateContainer("Time Duration");
var overrideToggle = inspector.GenerateToggle(this, container, "Override Duration", nameof(isOverridingDuration));
@@ -108,8 +107,6 @@ namespace Ichni.RhythmGame
SetInputFieldInteractable(isOverridingDuration);
overrideToggle.AddListenerFunction(() => SetInputFieldInteractable(isOverridingDuration));
}
}
public interface IHaveTimeDurationSubmodule

View File

@@ -1,3 +1,4 @@
using System;
using System.Collections;
using System.Collections.Generic;
using Ichni.RhythmGame.Beatmap;
@@ -33,7 +34,7 @@ namespace Ichni.RhythmGame
namespace Beatmap
{
public class BeatmapContainer_BM : BaseElement_BM
public partial class BeatmapContainer_BM : BaseElement_BM
{
public List<BaseElement_BM> elementList;
@@ -66,6 +67,11 @@ namespace Ichni.RhythmGame
elementList.ForEach(element =>
{
if (LowLoadPriorityTypes.Contains(element.GetType()))
{
return;
}
if (element is GameElement_BM gameElement)
{
#if UNITY_EDITOR
@@ -76,7 +82,23 @@ namespace Ichni.RhythmGame
element.ExecuteBM();
});
elementList.ForEach(element =>
{
if (LowLoadPriorityTypes.Contains(element.GetType()))
{
element.ExecuteBM();
}
});
}
}
public partial class BeatmapContainer_BM : BaseElement_BM
{
private static readonly List<Type> LowLoadPriorityTypes = new()
{
typeof(NoteJudgeSubmodule_BM),
};
}
}
}

View File

@@ -73,7 +73,7 @@ namespace Ichni.RhythmGame
LogWindow.Log("Game Element not found.", Color.red);
}
inspectorMain.SetInspector(EditorManager.instance.operationManager.currentSelectedElement);
inspectorMain.SetInspector(connectedGameElement);
});
string ShowConnection() => connectedGameElement == null ? "No Game Element Connected" : "Connected With: " + connectedGameElement.elementName;

View File

@@ -66,6 +66,7 @@ namespace Ichni.RhythmGame
{
{ "TouchArea", new TouchAreaJudgeUnit(note, 1000) },
{ "FullScreenNearTime", new FullScreenNearTimeJudgeUnit(note) },
{ "TriggerConnect", new TriggerConnectJudgeUnit(note, null) }
};
public NoteJudgeUnit AddJudgeUnit(string judgeUnitName)

View File

@@ -20,7 +20,7 @@ namespace Ichni.RhythmGame
this.note = note;
}
protected void SetShowingJudge(bool isShowing)
protected virtual void SetShowingJudge(bool isShowing)
{
if (isShowing)
{

View File

@@ -41,7 +41,7 @@ namespace Ichni.RhythmGame
var isShowingJudgeField = inspector.GenerateToggle(this, container, "Is Showing Judge", nameof(isShowingJudge));
isShowingJudgeField.AddListenerFunction(() => SetShowingJudge(isShowingJudge));
var effectTimeField = inspector.GenerateInputField(this, container, "Area Radius", nameof(areaRadius));
var areaRadiusField = inspector.GenerateInputField(this, container, "Area Radius", nameof(areaRadius));
var removeButton = inspector.GenerateButton(this, container, "Remove", () =>
{

View File

@@ -1,26 +1,107 @@
using System;
using System.Collections;
using System.Collections.Generic;
using Ichni.Editor;
using Ichni.RhythmGame.Beatmap;
using TMPro;
using UnityEngine;
namespace Ichni.RhythmGame
{
public class TriggerConnectJudgeUnit : NoteJudgeUnit
{
protected override GameObject GetHintImagePrefab()
public GameElement connectedJudgeTrigger;
protected override GameObject GetHintImagePrefab() => EditorManager.instance.basePrefabs.triggerHint;
public TriggerConnectJudgeUnit(NoteBase note, GameElement judgeTrigger) : base(note)
{
throw new System.NotImplementedException();
this.connectedJudgeTrigger = judgeTrigger;
}
public TriggerConnectJudgeUnit(NoteBase note) : base(note)
protected 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 = EditorManager.instance.judgeHintCanvas.GetComponent<RectTransform>();
if (RectTransformUtility.ScreenPointToLocalPointInRectangle(canvasRect, noteScreenPosition, null, out Vector2 uiPosition))
{
judgeHintImage.anchoredPosition = uiPosition;
}
}
public override void SetUpInspector()
{
IHaveInspection inspector = EditorManager.instance.uiManager.inspector;
Inspector inspectorMain = EditorManager.instance.uiManager.inspector;
var container = inspector.GenerateContainer("Trigger Connect Judge Unit");
var isShowingJudgeField = inspector.GenerateToggle(this, container, "Is Showing Judge", nameof(isShowingJudge));
isShowingJudgeField.AddListenerFunction(() => SetShowingJudge(isShowingJudge));
var triggerNameField = inspector.GenerateInputField(container, "Trigger Name");
var connectTriggerButton = inspector.GenerateButton(this, container, "Connect Trigger", () =>
{
GameElement trigger = EditorManager.instance.operationManager.FindingModule.FindGameElementByName(triggerNameField.GetValue<string>());
if (trigger is not IHaveNoteJudgeTriggerSubmodule)
{
LogWindow.Log("The element you are trying to connect is not a Note Judge Trigger.");
return;
}
connectedJudgeTrigger = trigger;
(trigger as IHaveNoteJudgeTriggerSubmodule).noteJudgeTriggerSubmodule.connectedNotes.Add(note);
});
var removeButton = inspector.GenerateButton(this, container, "Remove", () =>
{
SetShowingJudge(false);
note.noteJudgeSubmodule.judgeUnitList.Remove(this);
inspectorMain.SetInspector(note);
});
}
public override NoteJudgeUnit_BM ConvertToBM()
{
throw new System.NotImplementedException();
return new TriggerConnectJudgeUnit_BM(connectedJudgeTrigger.elementGuid);
}
}
namespace Beatmap
{
public class TriggerConnectJudgeUnit_BM : NoteJudgeUnit_BM
{
public Guid connectedTriggerID;
public TriggerConnectJudgeUnit_BM()
{
}
public TriggerConnectJudgeUnit_BM(Guid connectedTriggerID)
{
this.connectedTriggerID = connectedTriggerID;
}
public override NoteJudgeUnit ConvertToGameType(NoteBase attachedNote)
{
Debug.Log(GameElement_BM.GetElement(connectedTriggerID));
return new TriggerConnectJudgeUnit(attachedNote, GameElement_BM.GetElement(connectedTriggerID));
}
}
}
}

View File

@@ -19,7 +19,6 @@ namespace Ichni.RhythmGame
string themeBundleName, string objectName, GameElement parentElement)
{
GameObject themeBundleObject = ThemeBundleManager.instance.GetObject<GameObject>(themeBundleName, objectName);
Debug.Log(parentElement.elementName);
SubstantialObject substantialObject = Instantiate(themeBundleObject, parentElement.transform).GetComponent<SubstantialObject>();
substantialObject.Initialize(elementName, id, tags, isFirstGenerated, parentElement);
substantialObject.themeBundleName = themeBundleName;

View File

@@ -29,9 +29,10 @@ public class BasePrefabsCollection : SerializedScriptableObject
public AudioClip holdNoteLoopSound;
public AudioClip holdNoteEndSound;
public AudioClip flickNoteSound;
[Title("Note 判定UI")] public GameObject fullscreenNearTimeHint;
[Title("Note 判定UI")]
public GameObject fullscreenNearTimeHint;
public GameObject areaHint;
public GameObject triggerHint;
[Title("Effect相关")]
public GameObject bloomEffect;

View File

@@ -157,19 +157,37 @@ namespace Ichni.Editor
private void CopyPasteDeleteOperation()
{
if (Keyboard.current.leftCtrlKey.isPressed)
if (Keyboard.current.leftCtrlKey.isPressed) // TODO: 后续适应多选
{
if (Keyboard.current.cKey.wasPressedThisFrame) // Ctrl + C 复制
{
EditorManager.instance.operationManager.CopyPasteDeleteModule.CopyElement(EditorManager.instance.operationManager.currentSelectedElement);
if (EditorManager.instance.operationManager.currentSelectedElements.Count != 1) // TODO: 后续适应多选
{
LogWindow.Log("Please select only one Game Element to copy.", Color.red);
return;
}
EditorManager.instance.operationManager.CopyPasteDeleteModule.CopyElement(EditorManager.instance.operationManager.currentSelectedElements[0]);
}
else if (Keyboard.current.vKey.wasPressedThisFrame) // Ctrl + V 粘贴
{
EditorManager.instance.operationManager.CopyPasteDeleteModule.PasteElement(EditorManager.instance.operationManager.currentSelectedElement);
if (EditorManager.instance.operationManager.currentSelectedElements.Count != 1)
{
LogWindow.Log("Please select only one Game Element to paste.", Color.red);
return;
}
EditorManager.instance.operationManager.CopyPasteDeleteModule.PasteElement(EditorManager.instance.operationManager.currentSelectedElements[0]);
}
else if (Keyboard.current.dKey.wasPressedThisFrame) // Ctrl + D 删除
{
EditorManager.instance.operationManager.CopyPasteDeleteModule.DeleteElement(EditorManager.instance.operationManager.currentSelectedElement);
if (EditorManager.instance.operationManager.currentSelectedElements.Count != 1) // TODO: 后续适应多选,为同时选中了父物体和子物体做防呆设计
{
LogWindow.Log("Please select only one Game Element to copy.", Color.red);
return;
}
EditorManager.instance.operationManager.CopyPasteDeleteModule.DeleteElement(EditorManager.instance.operationManager.currentSelectedElements[0]);
}
}
}

View File

@@ -8,29 +8,61 @@ namespace Ichni.Editor
{
public class OperationManager
{
public GameElement currentSelectedElement { get; private set; }
public List<GameElement> currentSelectedElements { get; private set; }
public CopyPasteDeleteModule CopyPasteDeleteModule;
public FindingModule FindingModule;
public OperationManager()
{
currentSelectedElements = new List<GameElement>();
CopyPasteDeleteModule = new CopyPasteDeleteModule();
FindingModule = new FindingModule();
}
public void SelectElement(GameElement gameElement)
public void AddSelectElement(GameElement gameElement)
{
if (currentSelectedElement != null)
currentSelectedElements.Add(gameElement);
gameElement.connectedTab.isSelected = true;
gameElement.connectedTab.BgImage.color = new Color(0.5f, 0.5f, 0.5f, 0.2f);
}
public void RemoveSelectElement(GameElement gameElement)
{
currentSelectedElements.Remove(gameElement);
gameElement.connectedTab.isSelected = false;
gameElement.connectedTab.BgImage.color = new Color(0.5f, 0.5f, 0.5f, 0);
}
public void ClearSelectedElements()
{
currentSelectedElements.ForEach(gameElement =>
{
currentSelectedElement.connectedTab.isSelected = false;
if (currentSelectedElement.connectedTab.BgImage != null)
gameElement.connectedTab.isSelected = false;
gameElement.connectedTab.BgImage.color = new Color(0.5f, 0.5f, 0.5f, 0);
});
currentSelectedElements.Clear();
}
}
public class FindingModule
{
public GameElement FindGameElementByName(string elementName)
{
foreach (GameElement element in EditorManager.instance.beatmapContainer.gameElementList)
{
if (element.elementName == elementName)
{
currentSelectedElement.connectedTab.BgImage.color = new Color(0.5f, 0.5f, 0.5f, 0);
return element;
}
}
currentSelectedElement = gameElement;
currentSelectedElement.connectedTab.isSelected = true;
currentSelectedElement.connectedTab.BgImage.color = new Color(0.5f, 0.5f, 0.5f, 0.2f);
LogWindow.Log("Element not found: " + elementName, Color.red);
return null;
}
}

View File

@@ -189,7 +189,13 @@ namespace Ichni
{
LogWindow.Log("Start Saving Clip...");
GameElement selectedElement = EditorManager.instance.operationManager.currentSelectedElement;
if (EditorManager.instance.operationManager.currentSelectedElements.Count != 1) // TODO: 后续适应多选
{
LogWindow.Log("Please select only one Game Element to save the beatmap clip.", Color.red);
return;
}
GameElement selectedElement = EditorManager.instance.operationManager.currentSelectedElements[0];
if (selectedElement is null)
{
@@ -211,8 +217,14 @@ namespace Ichni
LogWindow.Log("Clip not found", Color.red);
return;
}
if (EditorManager.instance.operationManager.currentSelectedElements.Count != 1) // TODO: 后续适应多选
{
LogWindow.Log("Please select only one Game Element to load the beatmap clip.", Color.red);
return;
}
GameElement selectedElement = EditorManager.instance.operationManager.currentSelectedElement;
GameElement selectedElement = EditorManager.instance.operationManager.currentSelectedElements[0];
if (selectedElement is null)
{