基础内容-9
为次级模块增加存档类,仍在思考框架中
This commit is contained in:
BIN
Assets/.DS_Store
vendored
BIN
Assets/.DS_Store
vendored
Binary file not shown.
BIN
Assets/Prefabs/.DS_Store
vendored
Normal file
BIN
Assets/Prefabs/.DS_Store
vendored
Normal file
Binary file not shown.
BIN
Assets/Scripts/.DS_Store
vendored
BIN
Assets/Scripts/.DS_Store
vendored
Binary file not shown.
@@ -67,5 +67,49 @@ namespace Ichni.RhythmGame
|
||||
this.baseColorDirtyMark = false;
|
||||
this.emissionColorDirtyMark = false;
|
||||
}
|
||||
|
||||
public override void SaveBM()
|
||||
{
|
||||
matchedBM = new Beatmap.ColorSubmodule_BM(attachedElement, originalBaseColor, emissionEnabled,
|
||||
originalEmissionColor, originalEmissionIntensity);
|
||||
}
|
||||
}
|
||||
|
||||
namespace Beatmap
|
||||
{
|
||||
public class ColorSubmodule_BM : Submodule_BM
|
||||
{
|
||||
public Color originalBaseColor;
|
||||
public bool emissionEnabled;
|
||||
public Color originalEmissionColor;
|
||||
public float originalEmissionIntensity;
|
||||
|
||||
public ColorSubmodule_BM()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public ColorSubmodule_BM(BaseElement attachedElement, Color originalBaseColor, bool emissionEnabled,
|
||||
Color originalEmissionColor, float originalEmissionIntensity) : base(attachedElement)
|
||||
{
|
||||
this.originalBaseColor = originalBaseColor;
|
||||
this.emissionEnabled = emissionEnabled;
|
||||
this.originalEmissionColor = originalEmissionColor;
|
||||
this.originalEmissionIntensity = originalEmissionIntensity;
|
||||
}
|
||||
|
||||
public override void ExecuteBM()
|
||||
{
|
||||
attachedElement = GetElement(attachedElementGuid);
|
||||
attachedElement.colorSubmodule = new ColorSubmodule(attachedElement, originalBaseColor, emissionEnabled,
|
||||
originalEmissionColor, originalEmissionIntensity);
|
||||
}
|
||||
|
||||
public override void DuplicateBM(BaseElement attached)
|
||||
{
|
||||
attached.colorSubmodule = new ColorSubmodule(attached, originalBaseColor, emissionEnabled,
|
||||
originalEmissionColor, originalEmissionIntensity);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -12,6 +12,45 @@ namespace Ichni.RhythmGame
|
||||
{
|
||||
effectList = new List<EffectBase>();
|
||||
}
|
||||
|
||||
public override void SaveBM()
|
||||
{
|
||||
matchedBM = new Beatmap.EffectSubmodule_BM(attachedElement);
|
||||
}
|
||||
}
|
||||
|
||||
public interface IHaveEffect
|
||||
{
|
||||
public EffectSubmodule effectSubmodule { get; set; }
|
||||
}
|
||||
|
||||
namespace Beatmap
|
||||
{
|
||||
public class EffectSubmodule_BM : Submodule_BM
|
||||
{
|
||||
public List<EffectBase> effectList;
|
||||
|
||||
public EffectSubmodule_BM()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public EffectSubmodule_BM(BaseElement attachedElement) : base(attachedElement)
|
||||
{
|
||||
effectList = new List<EffectBase>();
|
||||
}
|
||||
|
||||
public override void ExecuteBM()
|
||||
{
|
||||
attachedElement = GetElement(attachedElementGuid);
|
||||
(attachedElement as IHaveEffect).effectSubmodule = new EffectSubmodule(attachedElement);
|
||||
}
|
||||
|
||||
public override void DuplicateBM(BaseElement attached)
|
||||
{
|
||||
(attached as IHaveEffect).effectSubmodule = new EffectSubmodule(attached);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public abstract class EffectBase
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using Ichni.RhythmGame.Beatmap;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Ichni.RhythmGame
|
||||
@@ -7,15 +9,58 @@ namespace Ichni.RhythmGame
|
||||
public abstract class SubmoduleBase
|
||||
{
|
||||
public BaseElement attachedElement;
|
||||
|
||||
|
||||
public Submodule_BM matchedBM;
|
||||
|
||||
public SubmoduleBase(BaseElement attachedElement)
|
||||
{
|
||||
this.attachedElement = attachedElement;
|
||||
}
|
||||
|
||||
|
||||
public virtual void InitialRefresh()
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
|
||||
public abstract void SaveBM();
|
||||
}
|
||||
|
||||
namespace Beatmap
|
||||
{
|
||||
public abstract class Submodule_BM
|
||||
{
|
||||
[System.NonSerialized] public BaseElement attachedElement; //存档类对应的游戏物体
|
||||
public Guid attachedElementGuid;
|
||||
|
||||
public Submodule_BM()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public Submodule_BM(BaseElement attachedElement)
|
||||
{
|
||||
this.attachedElement = attachedElement;
|
||||
attachedElementGuid = attachedElement.elementGuid;
|
||||
}
|
||||
|
||||
public static BaseElement_BM GetElementBM(Guid id)
|
||||
{
|
||||
if (BaseElement_BM.identifier.TryGetValue(id, out BaseElement_BM element_BM))
|
||||
{
|
||||
return element_BM;
|
||||
}
|
||||
|
||||
Debug.LogAssertion("Element not found or do not have id");
|
||||
return null;
|
||||
}
|
||||
|
||||
public static BaseElement GetElement(Guid id)
|
||||
{
|
||||
return GetElementBM(id)?.matchedElement;
|
||||
}
|
||||
|
||||
public abstract void ExecuteBM();
|
||||
public abstract void DuplicateBM(BaseElement attached);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -18,9 +18,9 @@ namespace Ichni.RhythmGame
|
||||
endTime = 999;//TODO: 换为songLength
|
||||
}
|
||||
|
||||
public TimeDurationSubmodule(BaseElement attachedElement, float startTime, float endTime) : base(attachedElement)
|
||||
public TimeDurationSubmodule(BaseElement attachedElement, bool isOverridingDuration, float startTime, float endTime) : base(attachedElement)
|
||||
{
|
||||
this.isOverridingDuration = false;
|
||||
this.isOverridingDuration = isOverridingDuration;
|
||||
this.startTime = startTime;
|
||||
this.endTime = endTime;
|
||||
}
|
||||
@@ -73,5 +73,42 @@ namespace Ichni.RhythmGame
|
||||
startTime = durations.Min(duration => duration.x);
|
||||
endTime = durations.Max(duration => duration.y);
|
||||
}
|
||||
|
||||
public override void SaveBM()
|
||||
{
|
||||
matchedBM = new Beatmap.TimeDurationSubmodule_BM(attachedElement, this);
|
||||
}
|
||||
}
|
||||
|
||||
namespace Beatmap
|
||||
{
|
||||
public class TimeDurationSubmodule_BM : Submodule_BM
|
||||
{
|
||||
public bool isOverridingDuration;
|
||||
public float startTime, endTime;
|
||||
|
||||
public TimeDurationSubmodule_BM()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public TimeDurationSubmodule_BM(BaseElement attachedElement, TimeDurationSubmodule timeDurationSubmodule) : base(attachedElement)
|
||||
{
|
||||
isOverridingDuration = timeDurationSubmodule.isOverridingDuration;
|
||||
startTime = timeDurationSubmodule.startTime;
|
||||
endTime = timeDurationSubmodule.endTime;
|
||||
}
|
||||
|
||||
public override void ExecuteBM()
|
||||
{
|
||||
attachedElement = GetElement(attachedElementGuid);
|
||||
attachedElement.timeDurationSubmodule = new TimeDurationSubmodule(attachedElement, isOverridingDuration, startTime, endTime);
|
||||
}
|
||||
|
||||
public override void DuplicateBM(BaseElement attached)
|
||||
{
|
||||
attached.timeDurationSubmodule = new TimeDurationSubmodule(attached, isOverridingDuration, startTime, endTime);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -28,10 +28,7 @@ namespace Ichni.RhythmGame
|
||||
public bool scaleDirtyMark;
|
||||
|
||||
public bool eulerAnglesOffsetLock;
|
||||
|
||||
public UnityAction OnPositionChanged;
|
||||
public UnityAction OnEulerAnglesChanged;
|
||||
public UnityAction OnScaleChanged;
|
||||
|
||||
|
||||
public TransformSubmodule(BaseElement attachedElement) : base(attachedElement)
|
||||
{
|
||||
@@ -79,5 +76,45 @@ namespace Ichni.RhythmGame
|
||||
|
||||
attachedElement.SetTransformObserver();
|
||||
}
|
||||
|
||||
public override void SaveBM()
|
||||
{
|
||||
matchedBM = new Beatmap.TransformSubmodule_BM(attachedElement, originalPosition, originalEulerAngles, originalScale);
|
||||
}
|
||||
}
|
||||
|
||||
namespace Beatmap
|
||||
{
|
||||
public class TransformSubmodule_BM : Submodule_BM
|
||||
{
|
||||
public Vector3 originalPosition;
|
||||
public Vector3 originalEulerAngles;
|
||||
public Vector3 originalScale;
|
||||
|
||||
public TransformSubmodule_BM()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public TransformSubmodule_BM(BaseElement attachedElement, Vector3 originalPosition,
|
||||
Vector3 originalEulerAngles, Vector3 originalScale) :
|
||||
base(attachedElement)
|
||||
{
|
||||
this.originalPosition = originalPosition;
|
||||
this.originalEulerAngles = originalEulerAngles;
|
||||
this.originalScale = originalScale;
|
||||
}
|
||||
|
||||
public override void ExecuteBM()
|
||||
{
|
||||
attachedElement = GetElement(attachedElementGuid);
|
||||
attachedElement.transformSubmodule = new TransformSubmodule(attachedElement, originalPosition, originalEulerAngles, originalScale);
|
||||
}
|
||||
|
||||
public override void DuplicateBM(BaseElement attached)
|
||||
{
|
||||
attached.transformSubmodule = new TransformSubmodule(attached, originalPosition, originalEulerAngles, originalScale);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -6,10 +6,47 @@ namespace Ichni.RhythmGame
|
||||
{
|
||||
public class NoteJudgeSubmodule : SubmoduleBase
|
||||
{
|
||||
public List<NoteJudgeUnit> judgeUnitList;
|
||||
|
||||
public NoteJudgeSubmodule(BaseElement attachedElement) : base(attachedElement)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public override void SaveBM()
|
||||
{
|
||||
matchedBM = new Beatmap.NoteJudgeSubmodule_BM(attachedElement);
|
||||
}
|
||||
}
|
||||
|
||||
namespace Beatmap
|
||||
{
|
||||
public class NoteJudgeSubmodule_BM : Submodule_BM
|
||||
{
|
||||
public List<NoteJudgeUnit> judgeUnitList;
|
||||
|
||||
public NoteJudgeSubmodule_BM()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public NoteJudgeSubmodule_BM(BaseElement attachedElement) : base(attachedElement)
|
||||
{
|
||||
judgeUnitList = new List<NoteJudgeUnit>();
|
||||
}
|
||||
|
||||
public override void ExecuteBM()
|
||||
{
|
||||
attachedElement = GetElement(attachedElementGuid);
|
||||
//(attachedElement as NoteElement).noteJudgeSubmodule = new NoteJudgeSubmodule(attachedElement);
|
||||
}
|
||||
|
||||
public override void DuplicateBM(BaseElement attached)
|
||||
{
|
||||
//(attached as NoteElement).noteJudgeSubmodule = new NoteJudgeSubmodule(attached);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public class NoteJudgeUnit
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using Dreamteck.Splines;
|
||||
using Ichni.RhythmGame.Beatmap;
|
||||
using Unity.VisualScripting;
|
||||
using UnityEngine;
|
||||
|
||||
@@ -63,4 +64,48 @@ namespace Ichni.RhythmGame
|
||||
path.SetPoint(point.index, point.node, SplineComputer.Space.Local);
|
||||
}
|
||||
}
|
||||
|
||||
public partial class TrackPathSubmodule
|
||||
{
|
||||
override public void SaveBM()
|
||||
{
|
||||
matchedBM = new TrackPathSubmodule_BM(attachedElement, this);
|
||||
}
|
||||
}
|
||||
|
||||
namespace Beatmap
|
||||
{
|
||||
public class TrackPathSubmodule_BM : Submodule_BM
|
||||
{
|
||||
public Track.TrackSpaceType trackSpaceType;
|
||||
public Track.TrackSamplingType trackSamplingType;
|
||||
public bool isClosed;
|
||||
|
||||
public TrackPathSubmodule_BM()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
public TrackPathSubmodule_BM(BaseElement attachedElement, TrackPathSubmodule trackPathSubmodule) : base(
|
||||
attachedElement)
|
||||
{
|
||||
this.trackSpaceType = trackPathSubmodule.trackSpaceType;
|
||||
this.trackSamplingType = trackPathSubmodule.trackSamplingType;
|
||||
this.isClosed = trackPathSubmodule.isClosed;
|
||||
}
|
||||
|
||||
public override void ExecuteBM()
|
||||
{
|
||||
attachedElement = GetElement(attachedElementGuid);
|
||||
(attachedElement as Track).trackPathSubmodule = new TrackPathSubmodule(attachedElement as Track, trackSpaceType, trackSamplingType, isClosed);
|
||||
}
|
||||
|
||||
public override void DuplicateBM(BaseElement attached)
|
||||
{
|
||||
(attached as Track).trackPathSubmodule = new TrackPathSubmodule(attached as Track, trackSpaceType, trackSamplingType, isClosed);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -11,12 +11,17 @@ namespace Ichni.RhythmGame
|
||||
public MeshGenerator meshGenerator;
|
||||
public MeshRenderer meshRenderer;
|
||||
public Material renderMaterial;
|
||||
|
||||
|
||||
public TrackRendererSubmodule(Track track) : base(track)
|
||||
{
|
||||
this.track = track;
|
||||
this.track.trackRendererSubmodule = this;
|
||||
}
|
||||
|
||||
public override void SaveBM()
|
||||
{
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
}
|
||||
|
||||
public class TrackRendererSubmoduleAutoOrient : TrackRendererSubmodule
|
||||
@@ -44,5 +49,41 @@ namespace Ichni.RhythmGame
|
||||
splineRenderer.clipTo = 0;
|
||||
}
|
||||
}
|
||||
|
||||
public override void SaveBM()
|
||||
{
|
||||
matchedBM = new Beatmap.TrackRendererSubmoduleAutoOrient_BM(attachedElement, this);
|
||||
}
|
||||
}
|
||||
|
||||
namespace Beatmap
|
||||
{
|
||||
public class TrackRendererSubmoduleAutoOrient_BM : Submodule_BM
|
||||
{
|
||||
public string renderMaterialName;
|
||||
|
||||
public TrackRendererSubmoduleAutoOrient_BM()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public TrackRendererSubmoduleAutoOrient_BM(BaseElement attachedElement,
|
||||
TrackRendererSubmodule trackRendererSubmodule) : base(attachedElement)
|
||||
{
|
||||
renderMaterialName = trackRendererSubmodule.renderMaterial.name;
|
||||
}
|
||||
|
||||
public override void ExecuteBM()
|
||||
{
|
||||
attachedElement = GetElement(attachedElementGuid);
|
||||
(attachedElement as Track).trackRendererSubmodule =
|
||||
new TrackRendererSubmodule(attachedElement as Track);
|
||||
}
|
||||
|
||||
public override void DuplicateBM(BaseElement attached)
|
||||
{
|
||||
(attached as Track).trackRendererSubmodule = new TrackRendererSubmodule(attached as Track);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -7,14 +7,21 @@ namespace Ichni.RhythmGame
|
||||
public class TrackTimeSubmodule : TrackSubmodule
|
||||
{
|
||||
public float headPercent, tailPercent;
|
||||
|
||||
|
||||
public TrackTimeSubmodule(Track track) : base(track)
|
||||
{
|
||||
this.track = track;
|
||||
this.track.trackTimeSubmodule = this;
|
||||
}
|
||||
|
||||
public override void SaveBM()
|
||||
{
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#region Movable
|
||||
|
||||
public class TrackTimeSubmoduleMovable : TrackTimeSubmodule
|
||||
{
|
||||
public float trackStartTime;
|
||||
@@ -40,40 +47,125 @@ namespace Ichni.RhythmGame
|
||||
public void UpdateTrackPart()
|
||||
{
|
||||
float songTime = EditorManager.instance.songModule.songTime;
|
||||
|
||||
|
||||
headPercent = GetTrackPercent(songTime);
|
||||
tailPercent = GetTrackPercent(songTime - visibleTrackTimeLength);
|
||||
|
||||
|
||||
if (track.trackRendererSubmodule != null)
|
||||
{
|
||||
track.trackRendererSubmodule.meshGenerator.clipFrom = tailPercent;
|
||||
track.trackRendererSubmodule.meshGenerator.clipTo = headPercent;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public float GetTrackPercent(float songTimeInTime)
|
||||
{
|
||||
float per = AnimationCurveEvaluator.Evaluate(animationCurveType, (songTimeInTime - trackStartTime) / trackTotalTime);
|
||||
float per = AnimationCurveEvaluator.Evaluate(animationCurveType,
|
||||
(songTimeInTime - trackStartTime) / trackTotalTime);
|
||||
return Mathf.Clamp01(per);
|
||||
}
|
||||
|
||||
public override void SaveBM()
|
||||
{
|
||||
matchedBM = new Beatmap.TrackTimeSubmoduleMovable_BM(attachedElement, this);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
namespace Beatmap
|
||||
{
|
||||
public class TrackTimeSubmoduleMovable_BM : Submodule_BM
|
||||
{
|
||||
public float trackStartTime;
|
||||
public float trackEndTime;
|
||||
public float visibleTrackTimeLength;
|
||||
public AnimationCurveType animationCurveType;
|
||||
|
||||
public TrackTimeSubmoduleMovable_BM()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public TrackTimeSubmoduleMovable_BM(BaseElement attachedElement, TrackTimeSubmoduleMovable trackTimeSubmoduleMovable) : base(attachedElement)
|
||||
{
|
||||
trackStartTime = trackTimeSubmoduleMovable.trackStartTime;
|
||||
trackEndTime = trackTimeSubmoduleMovable.trackEndTime;
|
||||
visibleTrackTimeLength = trackTimeSubmoduleMovable.visibleTrackTimeLength;
|
||||
animationCurveType = trackTimeSubmoduleMovable.animationCurveType;
|
||||
}
|
||||
|
||||
public override void ExecuteBM()
|
||||
{
|
||||
attachedElement = GetElement(attachedElementGuid);
|
||||
Track track = attachedElement as Track;
|
||||
track.trackTimeSubmodule = new TrackTimeSubmoduleMovable(track, trackStartTime, trackEndTime, visibleTrackTimeLength, animationCurveType);
|
||||
}
|
||||
|
||||
public override void DuplicateBM(BaseElement attached)
|
||||
{
|
||||
Track track = attached as Track;
|
||||
track.trackTimeSubmodule = new TrackTimeSubmoduleMovable(track, trackStartTime, trackEndTime, visibleTrackTimeLength, animationCurveType);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Static
|
||||
public class TrackTimeSubmoduleStatic : TrackTimeSubmodule
|
||||
{
|
||||
public float trackTotalTime;
|
||||
public AnimationCurveType animationCurveType;
|
||||
|
||||
public TrackTimeSubmoduleStatic(Track track, float trackTotalTime, AnimationCurveType animationCurveType) : base(track)
|
||||
public TrackTimeSubmoduleStatic(Track track, float trackTotalTime, AnimationCurveType animationCurveType) :
|
||||
base(track)
|
||||
{
|
||||
this.trackTotalTime = trackTotalTime;
|
||||
this.animationCurveType = animationCurveType;
|
||||
this.headPercent = 0;
|
||||
this.tailPercent = 1;
|
||||
|
||||
|
||||
track.timeDurationSubmodule.startTime = -999;
|
||||
track.timeDurationSubmodule.endTime = 999;
|
||||
//timeDurationSubmodule 根据下辖Note的时间来设置
|
||||
}
|
||||
|
||||
public override void SaveBM()
|
||||
{
|
||||
matchedBM = new Beatmap.TrackTimeSubmoduleStatic_BM(attachedElement, this);
|
||||
}
|
||||
}
|
||||
|
||||
namespace Beatmap
|
||||
{
|
||||
public class TrackTimeSubmoduleStatic_BM : Submodule_BM
|
||||
{
|
||||
public float trackTotalTime;
|
||||
public AnimationCurveType animationCurveType;
|
||||
|
||||
public TrackTimeSubmoduleStatic_BM()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public TrackTimeSubmoduleStatic_BM(BaseElement attachedElement, TrackTimeSubmoduleStatic trackTimeSubmoduleStatic) : base(attachedElement)
|
||||
{
|
||||
trackTotalTime = trackTimeSubmoduleStatic.trackTotalTime;
|
||||
animationCurveType = trackTimeSubmoduleStatic.animationCurveType;
|
||||
}
|
||||
|
||||
public override void ExecuteBM()
|
||||
{
|
||||
attachedElement = GetElement(attachedElementGuid);
|
||||
Track track = attachedElement as Track;
|
||||
track.trackTimeSubmodule = new TrackTimeSubmoduleStatic(track, trackTotalTime, animationCurveType);
|
||||
}
|
||||
|
||||
public override void DuplicateBM(BaseElement attached)
|
||||
{
|
||||
Track track = attached as Track;
|
||||
track.trackTimeSubmodule = new TrackTimeSubmoduleStatic(track, trackTotalTime, animationCurveType);
|
||||
}
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
BIN
Assets/StreamingAssets/.DS_Store
vendored
BIN
Assets/StreamingAssets/.DS_Store
vendored
Binary file not shown.
Reference in New Issue
Block a user