架构重新设计

基本重做了所有物体和次级模块代码
This commit is contained in:
SoulliesOfficial
2025-02-08 02:31:39 -05:00
parent 752c9b73e3
commit 7ab738cb68
44 changed files with 1320 additions and 847 deletions

View File

@@ -2,6 +2,7 @@ using System;
using System.Collections;
using System.Collections.Generic;
using Dreamteck.Splines;
using Ichni.RhythmGame.Beatmap;
using Lean.Pool;
using Unity.VisualScripting;
using UnityEngine;
@@ -11,18 +12,20 @@ namespace Ichni.RhythmGame
public partial class Flick : NoteBase
{
public List<Vector2> availableFlickDirections;
public static Flick GenerateElement(string elementName, Guid id, List<string> tags,
float exactJudgeTime, BaseElement attach, List<Vector2> directions)
public static Flick GenerateElement(string elementName, Guid id, List<string> tags, bool isFirstGenerated,
GameElement parentElement, float exactJudgeTime, List<Vector2> directions)
{
Flick flick = Instantiate(EditorManager.instance.basePrefabs.tapNote, attach.transform).GetComponent<Flick>();
flick.Initialize(elementName, id, tags);
Flick flick = Instantiate(EditorManager.instance.basePrefabs.tapNote, parentElement.transform)
.GetComponent<Flick>();
flick.Initialize(elementName, id, tags, isFirstGenerated);
flick.exactJudgeTime = exactJudgeTime;
flick.availableFlickDirections = directions;
flick.transformSubmodule = new TransformSubmodule(flick);
flick.timeDurationSubmodule = new TimeDurationSubmodule(flick);
flick.SetParent(attach);
if (attach.TryGetComponent(out Track track))
flick.SetParent(parentElement);
if (parentElement.TryGetComponent(out Track track))
{
if (track.trackTimeSubmodule != null)
{
@@ -46,41 +49,44 @@ namespace Ichni.RhythmGame
return flick;
}
}
public partial class Flick
{
public override void SaveBM()
{
matchedBM = new Beatmap.Flick_BM(elementName, elementGuid, tags, parentElement.matchedBM, exactJudgeTime, availableFlickDirections);
matchedBM = new Flick_BM(elementName, elementGuid, tags, parentElement.matchedBM as GameElement_BM,
exactJudgeTime, availableFlickDirections);
}
}
namespace Beatmap
{
public class Flick_BM : BaseElement_BM
public class Flick_BM : NoteBase_BM
{
public float exactJudgeTime;
public List<Vector2> availableFlickDirections;
public Flick_BM()
{
}
public Flick_BM(string elementName, Guid elementGuid, List<string> tags, BaseElement_BM attachedElement, float exactJudgeTime, List<Vector2> directions)
: base(elementName, elementGuid, tags, attachedElement)
public Flick_BM(string elementName, Guid elementGuid, List<string> tags, GameElement_BM attachedElement,
float exactJudgeTime,
List<Vector2> directions) : base(elementName, elementGuid, tags, attachedElement, exactJudgeTime)
{
this.exactJudgeTime = exactJudgeTime;
availableFlickDirections = directions;
}
public override void ExecuteBM()
{
matchedElement = Flick.GenerateElement(elementName, elementGuid, tags, exactJudgeTime, GetElement(attachedElementGuid), availableFlickDirections);
matchedElement = Flick.GenerateElement(elementName, elementGuid, tags, false,
GetElement(attachedElementGuid), exactJudgeTime, availableFlickDirections);
}
public override BaseElement DuplicateBM(BaseElement parent)
public override GameElement DuplicateBM(GameElement parent)
{
return Flick.GenerateElement(elementName, elementGuid, tags, exactJudgeTime, parent, availableFlickDirections);
return Flick.GenerateElement(elementName, elementGuid, tags, false, parent,
exactJudgeTime, availableFlickDirections);
}
}
}

View File

@@ -1,5 +1,6 @@
using System.Collections;
using System.Collections.Generic;
using Ichni.RhythmGame.Beatmap;
using UnityEngine;
namespace Ichni.RhythmGame
@@ -8,14 +9,14 @@ namespace Ichni.RhythmGame
{
public List<NoteJudgeUnit> judgeUnitList;
public NoteJudgeSubmodule(BaseElement attachedElement) : base(attachedElement)
public NoteJudgeSubmodule(NoteBase attachedGameElement) : base(attachedGameElement)
{
}
public override void SaveBM()
{
matchedBM = new Beatmap.NoteJudgeSubmodule_BM(attachedElement);
matchedBM = new NoteJudgeSubmodule_BM(attachedGameElement);
}
}
@@ -30,18 +31,18 @@ namespace Ichni.RhythmGame
}
public NoteJudgeSubmodule_BM(BaseElement attachedElement) : base(attachedElement)
public NoteJudgeSubmodule_BM(GameElement attachedElement) : base(attachedElement)
{
judgeUnitList = new List<NoteJudgeUnit>();
}
public override void ExecuteBM()
{
attachedElement = GetElement(attachedElementGuid);
attachedElement = GameElement_BM.GetElement(attachedElementGuid);
//(attachedElement as NoteElement).noteJudgeSubmodule = new NoteJudgeSubmodule(attachedElement);
}
public override void DuplicateBM(BaseElement attached)
public override void DuplicateBM(GameElement attached)
{
//(attached as NoteElement).noteJudgeSubmodule = new NoteJudgeSubmodule(attached);
}

View File

@@ -7,7 +7,7 @@ using UnityEngine;
namespace Ichni.RhythmGame
{
public abstract partial class NoteBase : BaseElement
public abstract partial class NoteBase : GameElement, IHaveTransformSubmodule, IHaveTimeDurationSubmodule, IHaveEffectSubmodule
{
[Title("Basic Info")]
public float exactJudgeTime;
@@ -20,39 +20,16 @@ namespace Ichni.RhythmGame
[Title("NoteVisual")]
public NoteVisualBase noteVisual;
[Title("NoteEffect")]
[Tooltip("生成Note时的特效")]
public EffectSubmodule generateEffects;
[Tooltip("Note被判定时的特效不包括Miss")]
public EffectSubmodule generalJudgeEffects;
[Tooltip("Note被Perfect判定时的特效")]
public EffectSubmodule perfectJudgeEffects;
[Tooltip("Note被Good判定时的特效")]
public EffectSubmodule goodJudgeEffects;
[Tooltip("Note被Bad判定时的特效")]
public EffectSubmodule badJudgeEffects;
[Tooltip("Note未被判定时的特效即Miss")]
public EffectSubmodule missJudgeEffects;
[Title("Judge Info")]
public NoteJudgeSubmodule noteJudgeSubmodule;
[Title("Submodules")]
public TransformSubmodule transformSubmodule { get; set; }
public TimeDurationSubmodule timeDurationSubmodule { get; set; }
public EffectSubmodule effectSubmodule { get; set; }
public NoteJudgeSubmodule noteJudgeSubmodule { get; set; }
[Title("In-Game Info")]
public Vector2 noteScreenPosition;
public bool isJudged;
public override void Initialize(string name, Guid id, List<string> tags)
{
base.Initialize(name, id, tags);
generateEffects = new EffectSubmodule(this);
generalJudgeEffects = new EffectSubmodule(this);
perfectJudgeEffects = new EffectSubmodule(this);
goodJudgeEffects = new EffectSubmodule(this);
badJudgeEffects = new EffectSubmodule(this);
missJudgeEffects = new EffectSubmodule(this);
noteJudgeSubmodule = new NoteJudgeSubmodule(this);
}
/// <summary>
/// 在MovableTrack上更新Note的位置注意HoldNote需要重写这个方法
/// </summary>
@@ -78,24 +55,19 @@ namespace Ichni.RhythmGame
trackPositioner.SetPercent(1 - percent);
}
public override void AfterInitialize()
protected override void SetDefaultSubmodules()
{
base.AfterInitialize();
submoduleList.Add(generateEffects);
submoduleList.Add(generalJudgeEffects);
submoduleList.Add(perfectJudgeEffects);
submoduleList.Add(goodJudgeEffects);
submoduleList.Add(badJudgeEffects);
submoduleList.Add(missJudgeEffects);
transformSubmodule = new TransformSubmodule(this);
timeDurationSubmodule = new TimeDurationSubmodule(this);
effectSubmodule = new EffectSubmodule(this, EffectSubmodule.EffectSubmodulePreset.Note);
noteJudgeSubmodule = new NoteJudgeSubmodule(this);
generateEffects.effectList.ForEach(e => e.Recover());
generalJudgeEffects.effectList.ForEach(e => e.Recover());
perfectJudgeEffects.effectList.ForEach(e => e.Recover());
goodJudgeEffects.effectList.ForEach(e => e.Recover());
badJudgeEffects.effectList.ForEach(e => e.Recover());
missJudgeEffects.effectList.ForEach(e => e.Recover());
submoduleList.Add(transformSubmodule);
submoduleList.Add(timeDurationSubmodule);
submoduleList.Add(effectSubmodule);
submoduleList.Add(noteJudgeSubmodule);
}
private void Update()
{
if (isOnTrack)
@@ -122,21 +94,22 @@ namespace Ichni.RhythmGame
}
}
generateEffects.effectList.ForEach(e => e.UpdateEffect());
effectSubmodule.effectCollection["Generate"].ForEach(e => e.UpdateEffect());
effectSubmodule.effectCollection["GeneralJudge"].ForEach(e => e.UpdateEffect());
switch (EditorManager.instance.currentJudgeType)
{
case NoteJudgeType.Perfect:
perfectJudgeEffects.effectList.ForEach(e => e.UpdateEffect());
effectSubmodule.effectCollection["Perfect"].ForEach(e => e.UpdateEffect());
break;
case NoteJudgeType.Good:
goodJudgeEffects.effectList.ForEach(e => e.UpdateEffect());
effectSubmodule.effectCollection["Good"].ForEach(e => e.UpdateEffect());
break;
case NoteJudgeType.Bad:
badJudgeEffects.effectList.ForEach(e => e.UpdateEffect());
effectSubmodule.effectCollection["Bad"].ForEach(e => e.UpdateEffect());
break;
case NoteJudgeType.Miss:
missJudgeEffects.effectList.ForEach(e => e.UpdateEffect());
effectSubmodule.effectCollection["Miss"].ForEach(e => e.UpdateEffect());
break;
}
}
@@ -172,4 +145,33 @@ namespace Ichni.RhythmGame
Miss
}
}
namespace Beatmap
{
public abstract class NoteBase_BM : GameElement_BM
{
public float exactJudgeTime;
public NoteBase_BM()
{
}
public NoteBase_BM(string elementName, Guid elementGuid, List<string> tags, GameElement_BM attachedElement, float exactJudgeTime)
: base(elementName, elementGuid, tags, attachedElement)
{
this.exactJudgeTime = exactJudgeTime;
}
public override void ExecuteBM()
{
throw new NotImplementedException();
}
public override GameElement DuplicateBM(GameElement parent)
{
throw new NotImplementedException();
}
}
}
}

View File

@@ -1,12 +1,32 @@
using System;
using System.Collections;
using System.Collections.Generic;
using Ichni.RhythmGame.Beatmap;
using UnityEngine;
namespace Ichni.RhythmGame
{
public class NoteEffectBase : EffectBase
public abstract class NoteEffectBase : EffectBase
{
public NoteBase note;
public NoteVisualBase noteVisual;
}
namespace Beatmap
{
public abstract class NoteEffectBase_BM : EffectBase_BM
{
public Guid attachedNoteID;
public NoteEffectBase_BM()
{
}
public NoteEffectBase_BM(float effectTime, Guid attachedNoteID) : base(effectTime)
{
this.attachedNoteID = attachedNoteID;
}
}
}
}

View File

@@ -2,6 +2,7 @@ using System;
using System.Collections;
using System.Collections.Generic;
using Dreamteck.Splines;
using Ichni.RhythmGame.Beatmap;
using Lean.Pool;
using Unity.VisualScripting;
using UnityEngine;
@@ -10,17 +11,17 @@ namespace Ichni.RhythmGame
{
public partial class Stay : NoteBase
{
public static Stay GenerateElement(string elementName, Guid id, List<string> tags,
float exactJudgeTime, BaseElement attach)
public static Stay GenerateElement(string elementName, Guid id, List<string> tags, bool isFirstGenerated,
GameElement parentElement, float exactJudgeTime)
{
Stay stay = Instantiate(EditorManager.instance.basePrefabs.tapNote, attach.transform).GetComponent<Stay>();
stay.Initialize(elementName, id, tags);
Stay stay = Instantiate(EditorManager.instance.basePrefabs.tapNote, parentElement.transform).GetComponent<Stay>();
stay.Initialize(elementName, id, tags, isFirstGenerated);
stay.exactJudgeTime = exactJudgeTime;
stay.transformSubmodule = new TransformSubmodule(stay);
stay.timeDurationSubmodule = new TimeDurationSubmodule(stay);
stay.SetParent(attach);
stay.SetParent(parentElement);
if (attach.TryGetComponent(out Track track))
if (parentElement.TryGetComponent(out Track track))
{
if (track.trackTimeSubmodule != null)
{
@@ -49,35 +50,33 @@ namespace Ichni.RhythmGame
{
public override void SaveBM()
{
matchedBM = new Beatmap.Stay_BM(elementName, elementGuid, tags, parentElement.matchedBM, exactJudgeTime);
matchedBM = new Stay_BM(elementName, elementGuid, tags, parentElement.matchedBM as GameElement_BM, exactJudgeTime);
}
}
namespace Beatmap
{
public class Stay_BM : BaseElement_BM
public class Stay_BM : NoteBase_BM
{
public float exactJudgeTime;
public Stay_BM()
{
}
public Stay_BM(string elementName, Guid elementGuid, List<string> tags, BaseElement_BM attachedElement, float exactJudgeTime)
: base(elementName, elementGuid, tags, attachedElement)
public Stay_BM(string elementName, Guid elementGuid, List<string> tags, GameElement_BM attachedElement, float exactJudgeTime)
: base(elementName, elementGuid, tags, attachedElement, exactJudgeTime)
{
this.exactJudgeTime = exactJudgeTime;
}
public override void ExecuteBM()
{
matchedElement = Stay.GenerateElement(elementName, elementGuid, tags, exactJudgeTime, GetElement(attachedElementGuid));
matchedElement = Stay.GenerateElement(elementName, elementGuid, tags, false, GetElement(attachedElementGuid), exactJudgeTime);
}
public override BaseElement DuplicateBM(BaseElement parent)
public override GameElement DuplicateBM(GameElement parent)
{
return Stay.GenerateElement(elementName, elementGuid, tags, exactJudgeTime, parent);
return Stay.GenerateElement(elementName, elementGuid, tags, false, parent, exactJudgeTime);
}
}
}

View File

@@ -2,6 +2,7 @@ using System;
using System.Collections;
using System.Collections.Generic;
using Dreamteck.Splines;
using Ichni.RhythmGame.Beatmap;
using Lean.Pool;
using Unity.VisualScripting;
using UnityEngine;
@@ -10,17 +11,18 @@ namespace Ichni.RhythmGame
{
public partial class Tap : NoteBase
{
public static Tap GenerateElement(string elementName, Guid id, List<string> tags,
float exactJudgeTime, BaseElement attach)
public static Tap GenerateElement(string elementName, Guid id, List<string> tags, bool isFirstGenerated,
GameElement parentElement, float exactJudgeTime)
{
Tap tap = Instantiate(EditorManager.instance.basePrefabs.tapNote, attach.transform).GetComponent<Tap>();
tap.Initialize(elementName, id, tags);
Tap tap = Instantiate(EditorManager.instance.basePrefabs.tapNote, parentElement.transform)
.GetComponent<Tap>();
tap.Initialize(elementName, id, tags, isFirstGenerated);
tap.exactJudgeTime = exactJudgeTime;
tap.transformSubmodule = new TransformSubmodule(tap);
tap.timeDurationSubmodule = new TimeDurationSubmodule(tap);
tap.SetParent(attach);
if (attach.TryGetComponent(out Track track))
tap.SetParent(parentElement);
if (parentElement.TryGetComponent(out Track track))
{
if (track.trackTimeSubmodule != null)
{
@@ -44,40 +46,40 @@ namespace Ichni.RhythmGame
return tap;
}
}
public partial class Tap
{
public override void SaveBM()
{
matchedBM = new Beatmap.Tap_BM(elementName, elementGuid, tags, parentElement.matchedBM, exactJudgeTime);
matchedBM = new Tap_BM(elementName, elementGuid, tags, parentElement.matchedBM as GameElement_BM, exactJudgeTime);
}
}
namespace Beatmap
{
public class Tap_BM : BaseElement_BM
public class Tap_BM : NoteBase_BM
{
public float exactJudgeTime;
public Tap_BM()
{
}
public Tap_BM(string elementName, Guid elementGuid, List<string> tags, BaseElement_BM attachedElement, float exactJudgeTime)
: base(elementName, elementGuid, tags, attachedElement)
public Tap_BM(string elementName, Guid elementGuid, List<string> tags,
GameElement_BM attachedElement, float exactJudgeTime)
: base(elementName, elementGuid, tags, attachedElement, exactJudgeTime)
{
this.exactJudgeTime = exactJudgeTime;
}
public override void ExecuteBM()
{
matchedElement = Tap.GenerateElement(elementName, elementGuid, tags, exactJudgeTime, GetElement(attachedElementGuid));
matchedElement = Tap.GenerateElement(elementName, elementGuid, tags, false,
GetElement(attachedElementGuid), exactJudgeTime);
}
public override BaseElement DuplicateBM(BaseElement parent)
public override GameElement DuplicateBM(GameElement parent)
{
return Tap.GenerateElement(elementName, elementGuid, tags, exactJudgeTime, parent);
return Tap.GenerateElement(elementName, elementGuid, tags, false, parent, exactJudgeTime);
}
}
}