using System.Collections; using System.Collections.Generic; using UnityEngine; 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; public float trackEndTime; public float trackTotalTime; public float visibleTrackTimeLength; public AnimationCurveType animationCurveType; public TrackTimeSubmoduleMovable(Track track, float trackStartTime, float trackEndTime, float visibleTrackTimeLength, AnimationCurveType animationCurveType) : base(track) { this.track.trackTimeSubmodule = this; this.trackStartTime = trackStartTime; this.trackEndTime = trackEndTime; this.trackTotalTime = trackEndTime - trackStartTime; this.visibleTrackTimeLength = visibleTrackTimeLength; this.animationCurveType = animationCurveType; //timeDurationSubmodule 根据下辖Note的时间来设置 } public void UpdateTrackPart() { float songTime = EditorManager.instance.songInformation.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); return Mathf.Clamp01(per); } public override void SaveBM() { matchedBM = new Beatmap.TrackTimeSubmoduleMovable_BM(attachedGameElement, 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(GameElement attachedElement, TrackTimeSubmoduleMovable trackTimeSubmoduleMovable) : base(attachedElement) { trackStartTime = trackTimeSubmoduleMovable.trackStartTime; trackEndTime = trackTimeSubmoduleMovable.trackEndTime; visibleTrackTimeLength = trackTimeSubmoduleMovable.visibleTrackTimeLength; animationCurveType = trackTimeSubmoduleMovable.animationCurveType; } public override void ExecuteBM() { attachedElement = GameElement_BM.GetElement(attachedElementGuid); Track track = attachedElement as Track; track.trackTimeSubmodule = new TrackTimeSubmoduleMovable(track, trackStartTime, trackEndTime, visibleTrackTimeLength, animationCurveType); track.submoduleList.Add(track.trackTimeSubmodule); } public override void DuplicateBM(GameElement attached) { Track track = attached as Track; track.trackTimeSubmodule = new TrackTimeSubmoduleMovable(track, trackStartTime, trackEndTime, visibleTrackTimeLength, animationCurveType); track.submoduleList.Add(track.trackTimeSubmodule); } } } #endregion #region Static public class TrackTimeSubmoduleStatic : TrackTimeSubmodule { public float trackTotalTime; public AnimationCurveType animationCurveType; public TrackTimeSubmoduleStatic(Track track, float trackTotalTime, AnimationCurveType animationCurveType) : base(track) { this.trackTotalTime = trackTotalTime; this.animationCurveType = animationCurveType; this.headPercent = 0; this.tailPercent = 1; //timeDurationSubmodule 根据下辖Note的时间来设置 } public override void SaveBM() { matchedBM = new Beatmap.TrackTimeSubmoduleStatic_BM(attachedGameElement, this); } } namespace Beatmap { public class TrackTimeSubmoduleStatic_BM : Submodule_BM { public float trackTotalTime; public AnimationCurveType animationCurveType; public TrackTimeSubmoduleStatic_BM() { } public TrackTimeSubmoduleStatic_BM(GameElement attachedElement, TrackTimeSubmoduleStatic trackTimeSubmoduleStatic) : base(attachedElement) { trackTotalTime = trackTimeSubmoduleStatic.trackTotalTime; animationCurveType = trackTimeSubmoduleStatic.animationCurveType; } public override void ExecuteBM() { attachedElement = GameElement_BM.GetElement(attachedElementGuid); Track track = attachedElement as Track; track.trackTimeSubmodule = new TrackTimeSubmoduleStatic(track, trackTotalTime, animationCurveType); track.submoduleList.Add(track.trackTimeSubmodule); } public override void DuplicateBM(GameElement attached) { Track track = attached as Track; track.trackTimeSubmodule = new TrackTimeSubmoduleStatic(track, trackTotalTime, animationCurveType); track.submoduleList.Add(track.trackTimeSubmodule); } } } #endregion }