Note判定自定义模块
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using Ichni.RhythmGame.Beatmap;
|
||||
using UnityEngine;
|
||||
|
||||
|
||||
@@ -7,6 +8,18 @@ namespace Ichni.RhythmGame
|
||||
{
|
||||
public class FullScreenBalancedJudgeUnit : NoteJudgeUnit
|
||||
{
|
||||
|
||||
protected override GameObject GetHintImagePrefab()
|
||||
{
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
|
||||
public FullScreenBalancedJudgeUnit(NoteBase note) : base(note)
|
||||
{
|
||||
}
|
||||
|
||||
public override NoteJudgeUnit_BM ConvertToBM()
|
||||
{
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,12 +1,68 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using Ichni.Editor;
|
||||
using Ichni.RhythmGame.Beatmap;
|
||||
using UnityEngine;
|
||||
|
||||
|
||||
namespace Ichni.RhythmGame
|
||||
{
|
||||
public class FullScreenNearTimeJudgeUnit : NoteJudgeUnit
|
||||
{
|
||||
protected override GameObject GetHintImagePrefab() => EditorManager.instance.basePrefabs.fullscreenNearTimeHint;
|
||||
|
||||
public FullScreenNearTimeJudgeUnit(NoteBase note) : base(note)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public override void UpdateJudge()
|
||||
{
|
||||
if(note.isJudged) 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("Full Screen Near Time Judge Unit");
|
||||
|
||||
var isShowingJudgeField = inspector.GenerateToggle(this, container, "Is Showing Judge", nameof(isShowingJudge));
|
||||
isShowingJudgeField.AddListenerFunction((isOn) => SetShowingJudge(isShowingJudge));
|
||||
|
||||
var removeButton = inspector.GenerateButton(this, container, "Remove", () =>
|
||||
{
|
||||
SetShowingJudge(false);
|
||||
note.noteJudgeSubmodule.judgeUnitList.Remove(this);
|
||||
inspectorMain.SetInspector(note);
|
||||
});
|
||||
}
|
||||
|
||||
public override NoteJudgeUnit_BM ConvertToBM()
|
||||
{
|
||||
return new FullScreenNearTimeJudgeUnit_BM();
|
||||
}
|
||||
}
|
||||
|
||||
namespace Beatmap
|
||||
{
|
||||
public class FullScreenNearTimeJudgeUnit_BM : NoteJudgeUnit_BM
|
||||
{
|
||||
public FullScreenNearTimeJudgeUnit_BM()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public override NoteJudgeUnit ConvertToGameType(NoteBase attachedNote)
|
||||
{
|
||||
return new FullScreenNearTimeJudgeUnit(attachedNote);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,57 +1,119 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using Ichni.Editor;
|
||||
using Ichni.RhythmGame.Beatmap;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Ichni.RhythmGame
|
||||
{
|
||||
public class NoteJudgeSubmodule : SubmoduleBase
|
||||
public partial class NoteJudgeSubmodule : SubmoduleBase
|
||||
{
|
||||
public List<NoteJudgeUnit> judgeUnitList;
|
||||
private NoteBase note => attachedGameElement as NoteBase;
|
||||
|
||||
public NoteJudgeSubmodule(NoteBase attachedGameElement) : base(attachedGameElement)
|
||||
{
|
||||
judgeUnitList = new List<NoteJudgeUnit>();
|
||||
|
||||
this.note.noteJudgeSubmodule = this;
|
||||
}
|
||||
|
||||
public override void SaveBM()
|
||||
public NoteJudgeSubmodule(NoteBase attachedGameElement, List<NoteJudgeUnit_BM> judgeUnitList_BM) : base(attachedGameElement)
|
||||
{
|
||||
matchedBM = new NoteJudgeSubmodule_BM(attachedGameElement);
|
||||
judgeUnitList = new List<NoteJudgeUnit>();
|
||||
|
||||
foreach (NoteJudgeUnit_BM judgeUnitBM in judgeUnitList_BM)
|
||||
{
|
||||
judgeUnitList.Add(judgeUnitBM.ConvertToGameType(attachedGameElement));
|
||||
}
|
||||
|
||||
this.note.noteJudgeSubmodule = this;
|
||||
}
|
||||
}
|
||||
|
||||
public partial class NoteJudgeSubmodule
|
||||
{
|
||||
public override void SaveBM()
|
||||
{
|
||||
matchedBM = new NoteJudgeSubmodule_BM(attachedGameElement, this);
|
||||
}
|
||||
|
||||
public override void SetUpInspector()
|
||||
{
|
||||
IHaveInspection inspector = EditorManager.instance.uiManager.inspector;
|
||||
Inspector inspectorMain = EditorManager.instance.uiManager.inspector;
|
||||
var container = inspector.GenerateContainer("Judge Submodule");
|
||||
|
||||
foreach (var judgeUnit in judgeUnitList)
|
||||
{
|
||||
judgeUnit.SetUpInspector();
|
||||
}
|
||||
|
||||
var effectNameInputField = inspector.GenerateInputField(container, "Judge Unit Name");
|
||||
var addJudgeUnitButton = inspector.GenerateButton(this, container, "Add Judge Unit",
|
||||
() =>
|
||||
{
|
||||
AddJudgeUnit(effectNameInputField.GetValue<string>());
|
||||
inspectorMain.SetInspector(note);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
public partial class NoteJudgeSubmodule
|
||||
{
|
||||
private static Dictionary<string, NoteJudgeUnit> JudgeUnitCollection(NoteBase note) =>
|
||||
new Dictionary<string, NoteJudgeUnit>()
|
||||
{
|
||||
{ "TouchArea", new TouchAreaJudgeUnit(note, 1000) },
|
||||
{ "FullScreenNearTime", new FullScreenNearTimeJudgeUnit(note) },
|
||||
};
|
||||
|
||||
public NoteJudgeUnit AddJudgeUnit(string judgeUnitName)
|
||||
{
|
||||
if (JudgeUnitCollection(note).TryGetValue(judgeUnitName, out var newJudgeUnit))
|
||||
{
|
||||
judgeUnitList.Add(newJudgeUnit);
|
||||
return newJudgeUnit;
|
||||
}
|
||||
else
|
||||
{
|
||||
LogWindow.Log("Judge Unit Type not found.", Color.red);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
namespace Beatmap
|
||||
{
|
||||
public class NoteJudgeSubmodule_BM : Submodule_BM
|
||||
{
|
||||
public List<NoteJudgeUnit> judgeUnitList;
|
||||
public List<NoteJudgeUnit_BM> judgeUnitList;
|
||||
|
||||
public NoteJudgeSubmodule_BM()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public NoteJudgeSubmodule_BM(GameElement attachedElement) : base(attachedElement)
|
||||
public NoteJudgeSubmodule_BM(GameElement attachedElement, NoteJudgeSubmodule noteJudgeSubmodule) : base(attachedElement)
|
||||
{
|
||||
judgeUnitList = new List<NoteJudgeUnit>();
|
||||
judgeUnitList = new List<NoteJudgeUnit_BM>();
|
||||
|
||||
foreach (var judgeUnit in noteJudgeSubmodule.judgeUnitList)
|
||||
{
|
||||
judgeUnitList.Add(judgeUnit.ConvertToBM());
|
||||
}
|
||||
}
|
||||
|
||||
public override void ExecuteBM()
|
||||
{
|
||||
attachedElement = GameElement_BM.GetElement(attachedElementGuid);
|
||||
(attachedElement as NoteBase).noteJudgeSubmodule = new NoteJudgeSubmodule(attachedElement as NoteBase);
|
||||
(attachedElement as NoteBase).noteJudgeSubmodule = new NoteJudgeSubmodule(attachedElement as NoteBase, judgeUnitList);
|
||||
}
|
||||
|
||||
public override void DuplicateBM(GameElement attached)
|
||||
{
|
||||
(attached as NoteBase).noteJudgeSubmodule = new NoteJudgeSubmodule(attached as NoteBase);
|
||||
(attached as NoteBase).noteJudgeSubmodule = new NoteJudgeSubmodule(attached as NoteBase, judgeUnitList);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public class NoteJudgeUnit
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,69 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using Ichni.RhythmGame.Beatmap;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Ichni.RhythmGame
|
||||
{
|
||||
public abstract class NoteJudgeUnit : IBaseElement
|
||||
{
|
||||
public NoteBase note;
|
||||
public bool isShowingJudge;
|
||||
|
||||
public RectTransform judgeHintImage;
|
||||
protected abstract GameObject GetHintImagePrefab();
|
||||
|
||||
public BaseElement_BM matchedBM { get; set; }
|
||||
|
||||
protected NoteJudgeUnit(NoteBase note)
|
||||
{
|
||||
this.note = note;
|
||||
}
|
||||
|
||||
protected void SetShowingJudge(bool isShowing)
|
||||
{
|
||||
if (isShowing)
|
||||
{
|
||||
judgeHintImage = Object.Instantiate(GetHintImagePrefab(),
|
||||
EditorManager.instance.judgeHintCanvas.transform).GetComponent<RectTransform>();
|
||||
}
|
||||
else if (judgeHintImage != null)
|
||||
{
|
||||
Object.Destroy(judgeHintImage.gameObject);
|
||||
}
|
||||
}
|
||||
|
||||
public virtual void UpdateJudge()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public virtual void SetUpInspector()
|
||||
{
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 转换为存档类
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public abstract NoteJudgeUnit_BM ConvertToBM();
|
||||
}
|
||||
|
||||
namespace Beatmap
|
||||
{
|
||||
public abstract class NoteJudgeUnit_BM
|
||||
{
|
||||
public NoteJudgeUnit_BM()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 转换为游戏类
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public abstract NoteJudgeUnit ConvertToGameType(NoteBase attachedGameElement);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: dcf3d31716c4a4dcb8328530303a381f
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,11 +1,82 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using Ichni.Editor;
|
||||
using Ichni.RhythmGame.Beatmap;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace Ichni.RhythmGame
|
||||
{
|
||||
public class TouchAreaJudgeUnit : NoteJudgeUnit
|
||||
{
|
||||
public float areaRadius;
|
||||
protected override GameObject GetHintImagePrefab() => EditorManager.instance.basePrefabs.areaHint;
|
||||
|
||||
private float CurrentScreenRatio() => Screen.width / 1920f;
|
||||
|
||||
public TouchAreaJudgeUnit(NoteBase note, float areaRadius) : base(note)
|
||||
{
|
||||
this.areaRadius = areaRadius;
|
||||
}
|
||||
|
||||
public override void UpdateJudge()
|
||||
{
|
||||
if(note.isJudged) return;
|
||||
Vector2 noteScreenPosition = note.noteScreenPosition;
|
||||
RectTransform canvasRect = EditorManager.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 void SetUpInspector()
|
||||
{
|
||||
IHaveInspection inspector = EditorManager.instance.uiManager.inspector;
|
||||
Inspector inspectorMain = EditorManager.instance.uiManager.inspector;
|
||||
|
||||
var container = inspector.GenerateContainer("Touch Area Judge Unit");
|
||||
|
||||
var isShowingJudgeField = inspector.GenerateToggle(this, container, "Is Showing Judge", nameof(isShowingJudge));
|
||||
isShowingJudgeField.AddListenerFunction((isOn) => SetShowingJudge(isShowingJudge));
|
||||
|
||||
var effectTimeField = inspector.GenerateInputField(this, container, "Area Radius", nameof(areaRadius));
|
||||
|
||||
var removeButton = inspector.GenerateButton(this, container, "Remove", () =>
|
||||
{
|
||||
SetShowingJudge(false);
|
||||
note.noteJudgeSubmodule.judgeUnitList.Remove(this);
|
||||
inspectorMain.SetInspector(note);
|
||||
});
|
||||
}
|
||||
|
||||
public override NoteJudgeUnit_BM ConvertToBM()
|
||||
{
|
||||
return new TouchAreaJudgeUnit_BM(areaRadius);
|
||||
}
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
return new TouchAreaJudgeUnit(attachedNote, areaRadius);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using Ichni.RhythmGame.Beatmap;
|
||||
using UnityEngine;
|
||||
|
||||
|
||||
@@ -7,6 +8,19 @@ namespace Ichni.RhythmGame
|
||||
{
|
||||
public class TriggerConnectJudgeUnit : NoteJudgeUnit
|
||||
{
|
||||
|
||||
protected override GameObject GetHintImagePrefab()
|
||||
{
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
|
||||
public TriggerConnectJudgeUnit(NoteBase note) : base(note)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public override NoteJudgeUnit_BM ConvertToBM()
|
||||
{
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Dreamteck.Splines;
|
||||
using Ichni.Editor;
|
||||
using Sirenix.OdinInspector;
|
||||
@@ -86,6 +87,14 @@ namespace Ichni.RhythmGame
|
||||
}
|
||||
}
|
||||
|
||||
if (noteJudgeSubmodule != null && !EditorManager.instance.cameraManager.isSceneCameraActive)
|
||||
{
|
||||
foreach (NoteJudgeUnit unit in noteJudgeSubmodule.judgeUnitList.Where(unit => unit.isShowingJudge))
|
||||
{
|
||||
unit.UpdateJudge();
|
||||
}
|
||||
}
|
||||
|
||||
if (noteVisual != null)
|
||||
{
|
||||
noteVisual.effectSubmodule.effectCollection["Generate"].ForEach(e => e.UpdateEffect(exactJudgeTime));
|
||||
|
||||
Reference in New Issue
Block a user