效果模块,以及代码位置整理

This commit is contained in:
SoulliesOfficial
2025-02-16 11:15:42 -05:00
parent 934d1b5aba
commit d77e1a0f70
204 changed files with 1107 additions and 347 deletions

View File

@@ -0,0 +1,117 @@
using System;
using System.Collections;
using System.Collections.Generic;
using Dreamteck.Splines;
using Ichni;
using Ichni.RhythmGame.Beatmap;
using Lean.Pool;
using Sirenix.OdinInspector;
using UnityEngine;
namespace Ichni.RhythmGame
{
public partial class PathNode : GameElement, IHaveTransformSubmodule, IHaveTimeDurationSubmodule, IHaveColorSubmodule
{
public Track track;
public int index => track.trackPathSubmodule.pathNodeList.IndexOf(this);
public SplinePoint node;
public TransformSubmodule transformSubmodule { get; set; }
public TimeDurationSubmodule timeDurationSubmodule { get; set; }
public ColorSubmodule colorSubmodule { get; set; }
public bool haveEmission => false;
public static PathNode GenerateElement(string elementName, Guid id, List<string> tags, bool isFirstGenerated,
Track track)
{
PathNode pathNode = Instantiate(EditorManager.instance.basePrefabs.pathNode, track.transform)
.GetComponent<PathNode>();
pathNode.Initialize(elementName, id, tags, isFirstGenerated, track);
pathNode.track = track;
track.trackPathSubmodule.pathNodeList.Add(pathNode);
return pathNode;
}
protected override void SetDefaultSubmodules()
{
transformSubmodule = new TransformSubmodule(this);
timeDurationSubmodule = new TimeDurationSubmodule(this);
colorSubmodule = new ColorSubmodule(this);
submoduleList.Add(transformSubmodule);
submoduleList.Add(timeDurationSubmodule);
submoduleList.Add(colorSubmodule);
}
public override void AfterInitialize()
{
base.AfterInitialize();
Refresh();
if (track.trackPathSubmodule.pathNodeList.Count > 3)
{
track.trackPathSubmodule.ClosePath(track.trackPathSubmodule.isClosed);
}
}
}
public partial class PathNode
{
public override void Refresh()
{
Vector3 position = transformSubmodule.currentPosition;
Vector3 normal = Quaternion.Euler(transformSubmodule.currentEulerAngles) * Vector3.up;
float size = transformSubmodule.currentScale.x;
Color color = colorSubmodule.currentBaseColor;
transform.position = position;
transform.rotation = Quaternion.LookRotation(normal);
transform.localScale = Vector3.one * size;
node = new SplinePoint(position, Vector3.up, normal, size, color);
track.trackPathSubmodule.SetPathNode(this);
}
}
public partial class PathNode
{
public override void SaveBM()
{
matchedBM = new Beatmap.PathNode_BM(elementName, elementGuid, tags, parentElement.matchedBM as GameElement_BM);
}
}
namespace Beatmap
{
public class PathNode_BM : GameElement_BM
{
public PathNode_BM()
{
}
public PathNode_BM(string elementName, Guid elementGuid, List<string> tags, GameElement_BM attachedElement)
: base(elementName, elementGuid, tags, attachedElement)
{
}
public override void ExecuteBM()
{
matchedElement = PathNode.GenerateElement(elementName, elementGuid, tags, false,
GetElement(attachedElementGuid) as Track);
}
public override GameElement DuplicateBM(GameElement parent)
{
return PathNode.GenerateElement(elementName, elementGuid, tags, false, parent as Track);
}
}
}
}

View File

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

View File

@@ -0,0 +1,98 @@
using System;
using System.Collections;
using System.Collections.Generic;
using Ichni.RhythmGame.Beatmap;
using Lean.Pool;
using UnityEngine;
namespace Ichni.RhythmGame
{
public partial class Track : GameElement, IHaveTransformSubmodule, IHaveTimeDurationSubmodule
{
public TransformSubmodule transformSubmodule { get; set; }
public TimeDurationSubmodule timeDurationSubmodule { get; set; }
public TrackPathSubmodule trackPathSubmodule { get; set; }
public TrackTimeSubmodule trackTimeSubmodule { get; set; }
public TrackRendererSubmodule trackRendererSubmodule { get; set; }
public static Track GenerateElement(string elementName, Guid id, List<string> tags, bool isFirstGenerated, GameElement parentElement)
{
Track track = Instantiate(EditorManager.instance.basePrefabs.track, parentElement.transform).GetComponent<Track>();
track.Initialize(elementName, id, tags, isFirstGenerated, parentElement);
return track;
}
protected override void SetDefaultSubmodules()
{
transformSubmodule = new TransformSubmodule(this);
timeDurationSubmodule = new TimeDurationSubmodule(this);
trackPathSubmodule = null;
trackTimeSubmodule = null;
trackRendererSubmodule = null;
submoduleList.Add(transformSubmodule);
submoduleList.Add(timeDurationSubmodule);
}
private void Update()
{
if (timeDurationSubmodule.CheckTimeInDuration(EditorManager.instance.songInformation.songTime))
{
(trackTimeSubmodule as TrackTimeSubmoduleMovable)?.UpdateTrackPart();
}
}
}
public partial class Track
{
public override void SaveBM()
{
matchedBM = new Beatmap.Track_BM(elementName, elementGuid, tags, parentElement.matchedBM as GameElement_BM);
}
}
public partial class Track
{
public enum TrackSpaceType
{
CatmullRom = 0,
BSpline = 1,
Linear = 3
}
public enum TrackSamplingType
{
TimeDistributed = 0,
DistanceDistributed = 1
}
}
namespace Beatmap
{
public class Track_BM : GameElement_BM
{
public Track_BM()
{
}
public Track_BM(string elementName, Guid elementGuid, List<string> tags, GameElement_BM attachedElement)
: base(elementName, elementGuid, tags, attachedElement)
{
}
public override void ExecuteBM()
{
matchedElement = Track.GenerateElement(elementName, elementGuid, tags, false, GetElement(attachedElementGuid));
}
public override GameElement DuplicateBM(GameElement parent)
{
return Track.GenerateElement(elementName, elementGuid, tags, false, parent);
}
}
}
}

View File

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

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 50c407d9db7cf4ed096db0106bdc3c0c
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,110 @@
using System;
using System.Collections;
using System.Collections.Generic;
using Dreamteck.Splines;
using Ichni.RhythmGame;
using Ichni.RhythmGame.Beatmap;
using UnityEngine;
namespace Ichni.RhythmGame
{
public partial class CrossTrackPoint : GameElement, IHaveTimeDurationSubmodule
{
public ElementFolder trackListFolder;
public Track nowAttachedTrack;
private int nowAttachedTrackIndex;
public SplinePositioner trackPositioner;
public FlexibleInt trackSwitch;
public FlexibleFloat trackPercent;
public TimeDurationSubmodule timeDurationSubmodule { get; set; }
public static CrossTrackPoint GenerateElement(string elementName, Guid id, List<string> tags,
bool isFirstGenerated, ElementFolder elementFolder, FlexibleInt trackSwitch, FlexibleFloat trackPercent)
{
CrossTrackPoint point = Instantiate(EditorManager.instance.basePrefabs.emptyObject, elementFolder.transform)
.AddComponent<CrossTrackPoint>();
point.Initialize(elementName, id, tags, isFirstGenerated, elementFolder);
point.trackPositioner = point.gameObject.AddComponent<SplinePositioner>();
point.nowAttachedTrackIndex = -1;
point.trackListFolder = elementFolder;
point.trackSwitch = trackSwitch;
point.trackPercent = trackPercent;
return point;
}
protected override void SetDefaultSubmodules()
{
timeDurationSubmodule = new TimeDurationSubmodule(this);
submoduleList.Add(timeDurationSubmodule);
}
private void Update()
{
if (trackPercent.animations.Count > 0)
{
trackSwitch.UpdateFlexibleInt(EditorManager.instance.songInformation.songTime);
trackPercent.UpdateFlexibleFloat(EditorManager.instance.songInformation.songTime);
SetPoint();
}
}
private void SetPoint()
{
if (nowAttachedTrackIndex != trackSwitch.value && trackSwitch.value >= 0 &&
trackSwitch.value < trackListFolder.trackList.Count)
{
nowAttachedTrack = trackListFolder.trackList[trackSwitch.value];
nowAttachedTrackIndex = trackSwitch.value;
trackPositioner.spline = trackListFolder.trackList[trackSwitch.value].trackPathSubmodule.path;
}
trackPositioner.SetPercent(trackPercent.value);
}
}
public partial class CrossTrackPoint
{
public override void SaveBM()
{
matchedBM = new CrossTrackPoint_BM(elementName, elementGuid, tags,
parentElement.matchedBM as GameElement_BM, trackSwitch, trackPercent);
}
}
namespace Beatmap
{
public class CrossTrackPoint_BM : GameElement_BM
{
public FlexibleInt trackSwitch;
public FlexibleFloat trackPercent;
public CrossTrackPoint_BM()
{
}
public CrossTrackPoint_BM(string elementName, Guid elementGuid, List<string> tags,
GameElement_BM attachedElement, FlexibleInt trackSwitch, FlexibleFloat trackPercent)
: base(elementName, elementGuid, tags, attachedElement)
{
this.trackSwitch = trackSwitch;
this.trackPercent = trackPercent;
}
public override void ExecuteBM()
{
matchedElement = CrossTrackPoint.GenerateElement(elementName, elementGuid, tags, false,
GetElement(attachedElementGuid) as ElementFolder, trackSwitch, trackPercent);
}
public override GameElement DuplicateBM(GameElement parent)
{
return CrossTrackPoint.GenerateElement(elementName, elementGuid, tags, false,
parent as ElementFolder, trackSwitch, trackPercent);
}
}
}
}

View File

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

View File

@@ -0,0 +1,83 @@
using System;
using System.Collections;
using System.Collections.Generic;
using Dreamteck.Splines;
using Ichni.RhythmGame.Beatmap;
using Lean.Pool;
using UnityEngine;
namespace Ichni.RhythmGame
{
public partial class TrackHeadPoint : GameElement, IHaveTimeDurationSubmodule
{
public Track track;
public TrackTimeSubmoduleMovable trackTimeSubmoduleMovable;
public SplinePositioner trackPositioner;
public TimeDurationSubmodule timeDurationSubmodule { get; set; }
public static TrackHeadPoint GenerateElement(string elementName, Guid id, List<string> tags,
bool isFirstGenerated, Track track)
{
TrackHeadPoint head = Instantiate(EditorManager.instance.basePrefabs.emptyObject, track.transform)
.AddComponent<TrackHeadPoint>();
head.Initialize(elementName, id, tags, isFirstGenerated, track);
head.track = track;
head.trackPositioner = head.gameObject.AddComponent<SplinePositioner>();
head.trackPositioner.spline = track.trackPathSubmodule.path;
head.trackTimeSubmoduleMovable = track.trackTimeSubmodule as TrackTimeSubmoduleMovable;
return head;
}
protected override void SetDefaultSubmodules()
{
timeDurationSubmodule = new TimeDurationSubmodule(this);
submoduleList.Add(timeDurationSubmodule);
}
public void Update()
{
if (track.timeDurationSubmodule.CheckTimeInDuration(EditorManager.instance.songInformation.songTime))
{
trackPositioner.SetPercent(trackTimeSubmoduleMovable.headPercent);
}
}
}
public partial class TrackHeadPoint
{
public override void SaveBM()
{
matchedBM = new TrackHeadPoint_BM(elementName, elementGuid, tags, parentElement.matchedBM as GameElement_BM);
}
}
namespace Beatmap
{
public class TrackHeadPoint_BM : GameElement_BM
{
public TrackHeadPoint_BM()
{
}
public TrackHeadPoint_BM(string elementName, Guid elementGuid, List<string> tags,
GameElement_BM attachedElement)
: base(elementName, elementGuid, tags, attachedElement)
{
}
public override void ExecuteBM()
{
matchedElement = TrackHeadPoint.GenerateElement(elementName, elementGuid, tags, false,
GetElement(attachedElementGuid) as Track);
}
public override GameElement DuplicateBM(GameElement parent)
{
return TrackHeadPoint.GenerateElement(elementName, elementGuid, tags, false, parent as Track);
}
}
}
}

View File

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

View File

@@ -0,0 +1,111 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using Dreamteck.Splines;
using Ichni.RhythmGame.Beatmap;
using Lean.Pool;
using UniRx;
using UnityEngine;
namespace Ichni.RhythmGame
{
/// <summary>
/// 在轨道上根据百分比进行运动的点
/// </summary>
public partial class TrackPercentPoint : GameElement, IHaveTimeDurationSubmodule
{
public Track track;
public SplinePositioner trackPositioner;
public FlexibleFloat trackPercent;
public TimeDurationSubmodule timeDurationSubmodule { get; set; }
private bool isBeyond1 = false;
public static TrackPercentPoint GenerateElement(string elementName, Guid id, List<string> tags,
bool isFirstGenerated,
Track track, FlexibleFloat trackPercent)
{
TrackPercentPoint point = Instantiate(EditorManager.instance.basePrefabs.emptyObject, track.transform)
.AddComponent<TrackPercentPoint>();
point.Initialize(elementName, id, tags, isFirstGenerated, track);
point.track = track;
point.trackPositioner = point.gameObject.AddComponent<SplinePositioner>();
point.trackPositioner.spline = track.trackPathSubmodule.path;
point.trackPercent = trackPercent;
point.isBeyond1 = trackPercent.animations.Any(animation => animation.endValue > 1); //判断是否有超过1的动画超过1将会循环
return point;
}
protected override void SetDefaultSubmodules()
{
timeDurationSubmodule = new TimeDurationSubmodule(this);
submoduleList.Add(timeDurationSubmodule);
}
public void Update()
{
if (trackPercent.animations.Count > 0)
{
trackPercent.UpdateFlexibleFloat(EditorManager.instance.songInformation.songTime);
if (trackPercent.returnType == FlexibleReturnType.MiddleExecuting)
{
float finalValue = trackPercent.value;
if (isBeyond1)
{
finalValue -= Mathf.Floor(finalValue);
}
trackPositioner.SetPercent(finalValue);
}
}
}
}
public partial class TrackPercentPoint
{
public override void SaveBM()
{
matchedBM = new TrackPercentPoint_BM(elementName, elementGuid, tags,
parentElement.matchedBM as GameElement_BM,
trackPercent.ConvertToBM());
}
}
namespace Beatmap
{
public class TrackPercentPoint_BM : GameElement_BM
{
public FlexibleFloat_BM trackPercent;
public TrackPercentPoint_BM()
{
}
public TrackPercentPoint_BM(string elementName, Guid elementGuid, List<string> tags,
GameElement_BM attachedElement, FlexibleFloat_BM trackPercent)
: base(elementName, elementGuid, tags, attachedElement)
{
this.trackPercent = trackPercent;
}
public override void ExecuteBM()
{
matchedElement = TrackPercentPoint.GenerateElement(elementName, elementGuid, tags, false,
GetElement(attachedElementGuid) as Track, trackPercent.ConvertToGameType());
}
public override GameElement DuplicateBM(GameElement parent)
{
return TrackPercentPoint.GenerateElement(elementName, elementGuid, tags, false, parent as Track,
trackPercent.ConvertToGameType());
}
}
}
}

View File

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

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: c8348db51d6bc4d48b37e45339d1aaab
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,124 @@
using System.Collections;
using System.Collections.Generic;
using Dreamteck.Splines;
using Ichni.RhythmGame.Beatmap;
using Unity.VisualScripting;
using UnityEngine;
namespace Ichni.RhythmGame
{
public partial class TrackPathSubmodule : TrackSubmodule
{
public SplineComputer path;
public List<PathNode> pathNodeList;
public Track.TrackSpaceType trackSpaceType;
public Track.TrackSamplingType trackSamplingType;
public bool isClosed;
public TrackPathSubmodule(Track track, Track.TrackSpaceType trackSpaceType, Track.TrackSamplingType trackSamplingType, bool isClosed) : base(track)
{
this.path = track.AddComponent<SplineComputer>();
this.track.trackPathSubmodule = this;
this.pathNodeList = new List<PathNode>();
this.trackSpaceType = trackSpaceType;
this.trackSamplingType = trackSamplingType;
this.isClosed = isClosed;
SetUpSplineComputer(this.trackSpaceType, this.trackSamplingType);
//闭合路径在PathNode生成时执行在初始化的情况下PathNode数量为0不会执行闭合操作
}
}
public partial class TrackPathSubmodule
{
private void SetUpSplineComputer(Track.TrackSpaceType trackSpaceType, Track.TrackSamplingType trackSamplingType)
{
path.type = (Spline.Type)(int)trackSpaceType;
path.sampleMode = (SplineComputer.SampleMode)(int)trackSamplingType;
path.space = SplineComputer.Space.Local;
}
public void ClosePath(bool close)
{
if (close)
{
path.Close();
}
else
{
path.Break();
}
isClosed = close;
}
public void SetTrackSpaceType(int spaceType)
{
trackSpaceType = (Track.TrackSpaceType)spaceType;
path.type = (Spline.Type)spaceType;
}
public void SetPathNode(PathNode point)
{
path.SetPoint(point.index, point.node, SplineComputer.Space.Local);
}
}
public partial class TrackPathSubmodule
{
public override void SaveBM()
{
matchedBM = new TrackPathSubmodule_BM(attachedGameElement, this);
}
public override void SetUpInspector()
{
var container = inspector.GenerateContainer("Track Path");
var trackSpaceDropdown =
inspector.GenerateDropdown(this, container, "Space Type", typeof(Track.TrackSpaceType), nameof(trackSpaceType));
var trackSamplingDropdown =
inspector.GenerateDropdown(this, container, "Sampling Type", typeof(Track.TrackSamplingType), nameof(trackSamplingType));
}
}
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(GameElement attachedElement, TrackPathSubmodule trackPathSubmodule) : base(
attachedElement)
{
this.trackSpaceType = trackPathSubmodule.trackSpaceType;
this.trackSamplingType = trackPathSubmodule.trackSamplingType;
this.isClosed = trackPathSubmodule.isClosed;
}
public override void ExecuteBM()
{
attachedElement = GameElement_BM.GetElement(attachedElementGuid);
Track track = attachedElement as Track;
track.trackPathSubmodule = new TrackPathSubmodule(track, trackSpaceType, trackSamplingType, isClosed);
track.submoduleList.Add(track.trackPathSubmodule);
}
public override void DuplicateBM(GameElement attached)
{
Track track = attachedElement as Track;
track.trackPathSubmodule = new TrackPathSubmodule(track, trackSpaceType, trackSamplingType, isClosed);
track.submoduleList.Add(track.trackPathSubmodule);
}
}
}
}

View File

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

View File

@@ -0,0 +1,96 @@
using System.Collections;
using System.Collections.Generic;
using Dreamteck.Splines;
using Unity.VisualScripting;
using UnityEngine;
namespace Ichni.RhythmGame
{
public class TrackRendererSubmodule : TrackSubmodule
{
public MeshGenerator meshGenerator;
public MeshRenderer meshRenderer;
public Material renderMaterial;
public TrackRendererSubmodule(Track track) : base(track)
{
this.track.trackRendererSubmodule = this;
}
public override void SaveBM()
{
throw new System.NotImplementedException();
}
}
public class TrackRendererSubmoduleAutoOrient : TrackRendererSubmodule
{
public SplineRenderer splineRenderer;
public TrackRendererSubmoduleAutoOrient(Track track, Material material = null) : base(track)
{
this.splineRenderer = track.AddComponent<SplineRenderer>();
this.meshRenderer = splineRenderer.GetComponent<MeshRenderer>();
this.meshGenerator = splineRenderer;
this.renderMaterial = material == null ? EditorManager.instance.basePrefabs.defaultTrackMaterial : material;
this.splineRenderer.spline = track.trackPathSubmodule.path;
this.splineRenderer.clipFrom = 0;
this.splineRenderer.clipTo = 1;
this.meshRenderer.material = renderMaterial;
this.splineRenderer.color = Color.white;
}
public override void InitialRefresh()
{
if (track.trackTimeSubmodule is TrackTimeSubmoduleMovable)
{
splineRenderer.clipFrom = 0;
splineRenderer.clipTo = 0;
}
}
public override void SaveBM()
{
matchedBM = new Beatmap.TrackRendererSubmoduleAutoOrient_BM(attachedGameElement, this);
}
public override void SetUpInspector()
{
}
}
namespace Beatmap
{
public class TrackRendererSubmoduleAutoOrient_BM : Submodule_BM
{
public string renderMaterialName;
public TrackRendererSubmoduleAutoOrient_BM()
{
}
public TrackRendererSubmoduleAutoOrient_BM(GameElement attachedElement,
TrackRendererSubmodule trackRendererSubmodule) : base(attachedElement)
{
renderMaterialName = trackRendererSubmodule.renderMaterial.name;
}
public override void ExecuteBM()
{
attachedElement = GameElement_BM.GetElement(attachedElementGuid);
Track track = attachedElement as Track;
track.trackRendererSubmodule = new TrackRendererSubmodule(track);//TODO: Implement Material
track.submoduleList.Add(track.trackRendererSubmodule);
}
public override void DuplicateBM(GameElement attached)
{
Track track = attached as Track;
track.trackRendererSubmodule = new TrackRendererSubmodule(track);//TODO: Implement Material
track.submoduleList.Add(track.trackRendererSubmodule);
}
}
}
}

View File

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

View File

@@ -0,0 +1,16 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
namespace Ichni.RhythmGame
{
public abstract class TrackSubmodule : SubmoduleBase
{
public Track track;
public TrackSubmodule(Track track) : base(track)
{
this.track = track;
}
}
}

View File

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

View File

@@ -0,0 +1,170 @@
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
}

View File

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

View File

@@ -0,0 +1,98 @@
using System;
using System.Collections;
using System.Collections.Generic;
using Ichni.RhythmGame.Beatmap;
using UnityEngine;
namespace Ichni.RhythmGame
{
public partial class Trail : GameElement, IHaveTransformSubmodule
{
public TrailRenderer trailRenderer;
public Material renderMaterial;
public float visibleTimeLength;
public TransformSubmodule transformSubmodule { get; set; }
public static Trail GenerateElement(string name, Guid id, List<string> tags, bool isFirstGenerated,
GameElement parentElement, float visibleTimeLength, Material material = null)
{
Trail trail = Instantiate(EditorManager.instance.basePrefabs.trail).GetComponent<Trail>();
trail.trailRenderer = trail.GetComponent<TrailRenderer>();
trail.Initialize(name, id, tags, isFirstGenerated, parentElement);
trail.renderMaterial =
material == null ? EditorManager.instance.basePrefabs.defaultTrailMaterial : material;
trail.trailRenderer.material = trail.renderMaterial;
trail.visibleTimeLength = visibleTimeLength;
return trail;
}
protected override void SetDefaultSubmodules()
{
transformSubmodule = new TransformSubmodule(this);
submoduleList.Add(transformSubmodule);
}
}
public partial class Trail
{
public override void SaveBM()
{
matchedBM = new Trail_BM(elementName, elementGuid, tags, parentElement.matchedBM as GameElement_BM,
visibleTimeLength, renderMaterial);
}
}
public partial class Trail
{
public static void SetAllTrails(bool emitting, bool willClear)
{
foreach (GameElement x in EditorManager.instance.beatmapContainer.gameElementList)
{
if (x is Trail t)
{
t.trailRenderer.emitting = emitting;
if(willClear) t.trailRenderer.Clear();
}
}
}
}
namespace Beatmap
{
public class Trail_BM : GameElement_BM
{
public float visibleTimeLength;
public string renderMaterialName;
public Trail_BM()
{
}
public Trail_BM(string elementName, Guid elementGuid, List<string> tags, GameElement_BM attachedElement,
float visibleTimeLength, Material renderMaterial) : base(elementName, elementGuid, tags,
attachedElement)
{
this.visibleTimeLength = visibleTimeLength;
this.renderMaterialName = renderMaterial.name;
}
public override void ExecuteBM()
{
matchedElement = Trail.GenerateElement(elementName, elementGuid, tags,
false, GetElement(attachedElementGuid),
visibleTimeLength); //TODO: Implement Material
}
public override GameElement DuplicateBM(GameElement parent)
{
return Trail.GenerateElement(elementName, elementGuid, tags,
false, parent, visibleTimeLength); //TODO: Implement Material
}
}
}
}

View File

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