基础内容-6
技术性调整; Note效果;
This commit is contained in:
@@ -3,6 +3,7 @@ using System.Collections.Generic;
|
||||
using Dreamteck.Splines;
|
||||
using Ichni;
|
||||
using Lean.Pool;
|
||||
using Sirenix.OdinInspector;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Ichni.RhythmGame
|
||||
@@ -12,34 +13,30 @@ namespace Ichni.RhythmGame
|
||||
public ColorSubmodule colorSubmodule;
|
||||
|
||||
public Track track;
|
||||
public int index;
|
||||
|
||||
public int index => track.trackPathSubmodule.pathNodeList.IndexOf(this);
|
||||
|
||||
public SplinePoint node;
|
||||
|
||||
public static PathNode GeneratePathNode(string elementName, Track track, int index, Vector3 nodePosition,
|
||||
public static PathNode GenerateElement(string elementName, Track track, int index, Vector3 nodePosition,
|
||||
Vector3 nodeNormal, float nodeSize, Color nodeColor)
|
||||
{
|
||||
PathNode pathNode = LeanPool.Spawn(EditorManager.instance.basePrefabs.pathNode, track.transform).GetComponent<PathNode>();
|
||||
PathNode pathNode = Instantiate(EditorManager.instance.basePrefabs.pathNode, track.transform).GetComponent<PathNode>();
|
||||
|
||||
pathNode.NewInitialize(elementName, track, index, nodePosition, nodeNormal, nodeSize, nodeColor);
|
||||
pathNode.Initialize(elementName);
|
||||
pathNode.track = track;
|
||||
//pathNode.index = index;
|
||||
|
||||
pathNode.transformSubmodule = new TransformSubmodule(pathNode, nodePosition, Quaternion.LookRotation(nodeNormal, Vector3.up).eulerAngles, Vector3.one * nodeSize);
|
||||
pathNode.timeDurationSubmodule = new TimeDurationSubmodule(pathNode);
|
||||
pathNode.colorSubmodule = new ColorSubmodule(pathNode, nodeColor);
|
||||
|
||||
track.trackPathSubmodule.pathNodeList.Add(pathNode);
|
||||
pathNode.SetParent(track);
|
||||
|
||||
return pathNode;
|
||||
}
|
||||
|
||||
public void NewInitialize(string elementName, Track track, int index, Vector3 nodePosition,
|
||||
Vector3 nodeNormal, float nodeSize, Color nodeColor)
|
||||
{
|
||||
base.NewInitialize(elementName);
|
||||
this.track = track;
|
||||
this.index = index;
|
||||
|
||||
this.transformSubmodule = new TransformSubmodule(nodePosition, Quaternion.LookRotation(nodeNormal, Vector3.up).eulerAngles, Vector3.one * nodeSize);
|
||||
this.colorSubmodule = new ColorSubmodule(nodeColor);
|
||||
|
||||
Refresh();
|
||||
}
|
||||
|
||||
public override void AfterInitialize()
|
||||
{
|
||||
Refresh();
|
||||
|
||||
@@ -14,30 +14,23 @@ namespace Ichni.RhythmGame
|
||||
|
||||
public static Track GenerateElement(string elementName, BaseElement parent, Vector3 position)
|
||||
{
|
||||
if (parent == null)
|
||||
{
|
||||
throw new System.Exception("Parent is null");
|
||||
}
|
||||
Track track = Instantiate(EditorManager.instance.basePrefabs.track, parent.transform).GetComponent<Track>();
|
||||
|
||||
Track track = LeanPool.Spawn(EditorManager.instance.basePrefabs.track, parent.transform).GetComponent<Track>();
|
||||
|
||||
track.NewInitialize(elementName, position);
|
||||
track.Initialize(elementName);
|
||||
track.SetParent(parent);
|
||||
|
||||
track.transformSubmodule = new TransformSubmodule(track, position, Vector3.zero, Vector3.one);
|
||||
track.timeDurationSubmodule = new TimeDurationSubmodule(track);
|
||||
|
||||
track.trackPathSubmodule = null;
|
||||
track.trackTimeSubmodule = null;
|
||||
track.trackRendererSubmodule = null;
|
||||
|
||||
track.SetTransformObserver();
|
||||
|
||||
return track;
|
||||
}
|
||||
|
||||
private void NewInitialize(string elementName, Vector3 position)
|
||||
{
|
||||
base.NewInitialize(elementName);
|
||||
timeDurationSubmodule = new TimeDurationSubmodule();
|
||||
transformSubmodule = new TransformSubmodule(position, Vector3.zero, Vector3.one);
|
||||
trackPathSubmodule = null;
|
||||
trackTimeSubmodule = null;
|
||||
trackRendererSubmodule = null;
|
||||
Refresh();
|
||||
}
|
||||
|
||||
public override void AfterInitialize()
|
||||
{
|
||||
|
||||
@@ -56,7 +49,7 @@ namespace Ichni.RhythmGame
|
||||
{
|
||||
public override void Refresh()
|
||||
{
|
||||
transform.localPosition = transformSubmodule.currentPosition;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@ namespace Ichni.RhythmGame
|
||||
|
||||
public static TrackHeadPoint GenerateElement(string elementName, Track track)
|
||||
{
|
||||
TrackHeadPoint head = LeanPool.Spawn(EditorManager.instance.basePrefabs.emptyObject, track.transform).AddComponent<TrackHeadPoint>();
|
||||
TrackHeadPoint head = Instantiate(EditorManager.instance.basePrefabs.emptyObject, track.transform).AddComponent<TrackHeadPoint>();
|
||||
|
||||
head.NewInitialize(elementName, track);
|
||||
head.SetParent(track);
|
||||
@@ -23,7 +23,7 @@ namespace Ichni.RhythmGame
|
||||
|
||||
private void NewInitialize(string elementName, Track track)
|
||||
{
|
||||
base.NewInitialize(elementName);
|
||||
base.Initialize(elementName);
|
||||
this.track = track;
|
||||
this.trackPositioner = gameObject.AddComponent<SplinePositioner>();
|
||||
this.trackPositioner.spline = track.trackPathSubmodule.path;
|
||||
|
||||
@@ -21,7 +21,7 @@ namespace Ichni.RhythmGame
|
||||
|
||||
public static TrackPercentPoint GenerateElement(string elementName, Track track, FlexibleFloat trackPercent)
|
||||
{
|
||||
TrackPercentPoint point = LeanPool.Spawn(EditorManager.instance.basePrefabs.emptyObject, track.transform).AddComponent<TrackPercentPoint>();
|
||||
TrackPercentPoint point = Instantiate(EditorManager.instance.basePrefabs.emptyObject, track.transform).AddComponent<TrackPercentPoint>();
|
||||
|
||||
point.NewInitialize(elementName, track, trackPercent);
|
||||
point.SetParent(track);
|
||||
@@ -33,7 +33,7 @@ namespace Ichni.RhythmGame
|
||||
|
||||
private void NewInitialize(string elementName, Track track, FlexibleFloat trackPercent)
|
||||
{
|
||||
base.NewInitialize(elementName);
|
||||
base.Initialize(elementName);
|
||||
this.track = track;
|
||||
this.trackPositioner = gameObject.AddComponent<SplinePositioner>();
|
||||
this.trackPositioner.spline = track.trackPathSubmodule.path;
|
||||
|
||||
@@ -15,10 +15,8 @@ namespace Ichni.RhythmGame
|
||||
public Track.TrackSamplingType trackSamplingType;
|
||||
public bool isClosed;
|
||||
|
||||
public void NewInitialize(Track track, bool isClosed, Track.TrackSpaceType trackSpaceType,
|
||||
Track.TrackSamplingType trackSamplingType)
|
||||
public TrackPathSubmodule(Track track, Track.TrackSpaceType trackSpaceType, Track.TrackSamplingType trackSamplingType, bool isClosed) : base(track)
|
||||
{
|
||||
this.track = track;
|
||||
this.path = track.AddComponent<SplineComputer>();
|
||||
track.trackPathSubmodule = this;
|
||||
this.pathNodeList = new List<PathNode>();
|
||||
@@ -26,7 +24,8 @@ namespace Ichni.RhythmGame
|
||||
this.trackSamplingType = trackSamplingType;
|
||||
this.isClosed = isClosed;
|
||||
|
||||
SetUpSplineComputer(trackSpaceType, trackSamplingType);
|
||||
SetUpSplineComputer(this.trackSpaceType, this.trackSamplingType);
|
||||
//闭合路径在PathNode生成时执行,在初始化的情况下,PathNode数量为0,不会执行闭合操作
|
||||
}
|
||||
}
|
||||
|
||||
@@ -59,13 +58,6 @@ namespace Ichni.RhythmGame
|
||||
path.type = (Spline.Type)spaceType;
|
||||
}
|
||||
|
||||
public void AddPathNode(PathNode point)
|
||||
{
|
||||
path.SetPoint(pathNodeList.Count, point.node, SplineComputer.Space.Local);
|
||||
|
||||
pathNodeList.Add(point);
|
||||
}
|
||||
|
||||
public void SetPathNode(PathNode point)
|
||||
{
|
||||
path.SetPoint(point.index, point.node, SplineComputer.Space.Local);
|
||||
|
||||
@@ -11,16 +11,20 @@ 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 class TrackRendererSubmoduleAutoOrient : TrackRendererSubmodule
|
||||
{
|
||||
public SplineRenderer splineRenderer;
|
||||
|
||||
public void NewInitialize(Track track, Material material = null)
|
||||
public TrackRendererSubmoduleAutoOrient(Track track, Material material = null) : base(track)
|
||||
{
|
||||
this.track = track;
|
||||
this.track.trackRendererSubmodule = this;
|
||||
this.splineRenderer = track.AddComponent<SplineRenderer>();
|
||||
this.meshRenderer = splineRenderer.GetComponent<MeshRenderer>();
|
||||
this.meshGenerator = splineRenderer;
|
||||
|
||||
@@ -8,5 +8,11 @@ namespace Ichni.RhythmGame
|
||||
{
|
||||
public Track track;
|
||||
public bool isUpdating;
|
||||
|
||||
public TrackSubmodule(Track track) : base(track)
|
||||
{
|
||||
this.track = track;
|
||||
isUpdating = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -7,6 +7,12 @@ 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 class TrackTimeSubmoduleMovable : TrackTimeSubmodule
|
||||
@@ -16,17 +22,17 @@ namespace Ichni.RhythmGame
|
||||
public float trackTotalTime;
|
||||
public float visibleTrackTimeLength;
|
||||
public AnimationCurveType animationCurveType;
|
||||
|
||||
public void NewInitialize(Track track, float trackStartTime, float trackEndTime,
|
||||
float visibleTrackTimeLength, AnimationCurveType animationCurveType)
|
||||
|
||||
public TrackTimeSubmoduleMovable(Track track, float trackStartTime, float trackEndTime,
|
||||
float visibleTrackTimeLength, AnimationCurveType animationCurveType) : base(track)
|
||||
{
|
||||
this.track = track;
|
||||
this.track.trackTimeSubmodule = this;
|
||||
this.trackStartTime = trackStartTime;
|
||||
this.trackEndTime = trackEndTime;
|
||||
this.trackTotalTime = trackEndTime - trackStartTime;
|
||||
this.visibleTrackTimeLength = visibleTrackTimeLength;
|
||||
this.animationCurveType = animationCurveType;
|
||||
|
||||
track.timeDurationSubmodule.startTime = trackStartTime;
|
||||
track.timeDurationSubmodule.endTime = trackEndTime + visibleTrackTimeLength;
|
||||
}
|
||||
@@ -57,16 +63,15 @@ namespace Ichni.RhythmGame
|
||||
public float trackTotalTime;
|
||||
public AnimationCurveType animationCurveType;
|
||||
|
||||
public void NewInitialize(Track track, float trackTotalTime, AnimationCurveType animationCurveType)
|
||||
public TrackTimeSubmoduleStatic(Track track, float trackTotalTime, AnimationCurveType animationCurveType) : base(track)
|
||||
{
|
||||
this.track = track;
|
||||
this.track.trackTimeSubmodule = this;
|
||||
this.trackTotalTime = trackTotalTime;
|
||||
this.animationCurveType = animationCurveType;
|
||||
this.headPercent = 0;
|
||||
this.tailPercent = 1;
|
||||
track.timeDurationSubmodule.startTime = 0;
|
||||
track.timeDurationSubmodule.endTime = 0;
|
||||
|
||||
track.timeDurationSubmodule.startTime = -999;
|
||||
track.timeDurationSubmodule.endTime = 999;
|
||||
//timeDurationSubmodule 根据下辖Note的时间来设置
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user