调bug
添加了track的一些refresh(static没做) TrackPercentPoint 在有Movable的前提下添加默认动画
This commit is contained in:
@@ -18,6 +18,7 @@ namespace Ichni.RhythmGame
|
||||
public override void SetDefaultSubmodules()
|
||||
{
|
||||
timeDurationSubmodule = new TimeDurationSubmodule(this);
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -12,34 +12,31 @@ namespace Ichni.RhythmGame
|
||||
{
|
||||
private TransformSubmodule targetTransformSubmodule;
|
||||
public FlexibleFloat eulerAngleX, eulerAngleY, eulerAngleZ;
|
||||
|
||||
public static Swirl GenerateElement(string elementName, Guid id,
|
||||
|
||||
public static Swirl GenerateElement(string elementName, Guid id,
|
||||
List<string> tags, bool isFirstGenerated, GameElement animatedObject,
|
||||
FlexibleFloat eulerAngleX, FlexibleFloat eulerAngleY, FlexibleFloat eulerAngleZ)
|
||||
{
|
||||
Swirl swirl = Instantiate(EditorManager.instance.basePrefabs.emptyObject).AddComponent<Swirl>();
|
||||
|
||||
swirl.Initialize(elementName, id, tags, isFirstGenerated, animatedObject);
|
||||
|
||||
|
||||
swirl.animatedObject = animatedObject;
|
||||
|
||||
|
||||
swirl.eulerAngleX = eulerAngleX;
|
||||
swirl.eulerAngleY = eulerAngleY;
|
||||
swirl.eulerAngleZ = eulerAngleZ;
|
||||
swirl.animationReturnType = FlexibleReturnType.Before;
|
||||
|
||||
|
||||
swirl.targetTransformSubmodule = (animatedObject as IHaveTransformSubmodule).transformSubmodule;
|
||||
|
||||
|
||||
|
||||
|
||||
//swirl.timeDurationSubmodule.SetDuration(eulerAngleX, eulerAngleY, eulerAngleZ);
|
||||
|
||||
|
||||
return swirl;
|
||||
}
|
||||
|
||||
public override void SetDefaultSubmodules()
|
||||
{
|
||||
timeDurationSubmodule = new TimeDurationSubmodule(this);
|
||||
}
|
||||
|
||||
|
||||
protected override void UpdateAnimation(float songTime)
|
||||
{
|
||||
@@ -61,7 +58,7 @@ namespace Ichni.RhythmGame
|
||||
animationReturnType = FlexibleReturnType.MiddleInterval;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public override void ApplyTimeOffset(float offset)
|
||||
{
|
||||
base.ApplyTimeOffset(offset);
|
||||
@@ -70,7 +67,7 @@ namespace Ichni.RhythmGame
|
||||
eulerAngleZ.animations.ForEach(anim => anim.ApplyTimeOffset(offset));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public partial class Swirl
|
||||
{
|
||||
public override void SaveBM()
|
||||
@@ -82,10 +79,10 @@ namespace Ichni.RhythmGame
|
||||
public override void SetUpInspector()
|
||||
{
|
||||
base.SetUpInspector();
|
||||
|
||||
|
||||
IHaveInspection inspector = EditorManager.instance.uiManager.inspector;
|
||||
var container = inspector.GenerateContainer("Swirl");
|
||||
|
||||
|
||||
var eulerAngleXButton = inspector.GenerateButton(this, container, "Euler Angle X",
|
||||
() =>
|
||||
{
|
||||
@@ -101,19 +98,19 @@ namespace Ichni.RhythmGame
|
||||
{
|
||||
inspector.GenerateCompositeParameterWindow(this, "Euler Angle Z", nameof(eulerAngleZ)).SetAsFlexibleFloat();
|
||||
});
|
||||
|
||||
|
||||
var graphicEditor = inspector.GenerateButton(this, container, "GraphicEditor",
|
||||
() =>
|
||||
{
|
||||
inspector.GenerateGraphicalFlexibleFloatWindow(this, "Displacement",
|
||||
new FlexibleFloat[] { eulerAngleX, eulerAngleY, eulerAngleZ },
|
||||
new FlexibleFloat[] { eulerAngleX, eulerAngleY, eulerAngleZ },
|
||||
new string[] { "EulerX", "EulerY", "EulerZ" });
|
||||
});
|
||||
|
||||
|
||||
container.SetDeviver(1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
namespace Beatmap
|
||||
{
|
||||
public class Swirl_BM : AnimationBase_BM
|
||||
@@ -121,10 +118,10 @@ namespace Ichni.RhythmGame
|
||||
public FlexibleFloat_BM eulerAngleX, eulerAngleY, eulerAngleZ;
|
||||
public Swirl_BM()
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
|
||||
public Swirl_BM(string elementName, Guid elementGuid, List<string> tags, GameElement_BM attachedElement,
|
||||
public Swirl_BM(string elementName, Guid elementGuid, List<string> tags, GameElement_BM attachedElement,
|
||||
FlexibleFloat_BM eulerAngleX, FlexibleFloat_BM eulerAngleY, FlexibleFloat_BM eulerAngleZ)
|
||||
: base(elementName, elementGuid, tags, attachedElement)
|
||||
{
|
||||
@@ -135,7 +132,7 @@ namespace Ichni.RhythmGame
|
||||
|
||||
public override void ExecuteBM()
|
||||
{
|
||||
matchedElement = Swirl.GenerateElement(elementName, elementGuid, tags, false, GetElement(attachedElementGuid),
|
||||
matchedElement = Swirl.GenerateElement(elementName, elementGuid, tags, false, GetElement(attachedElementGuid),
|
||||
eulerAngleX.ConvertToGameType(), eulerAngleY.ConvertToGameType(), eulerAngleZ.ConvertToGameType());
|
||||
}
|
||||
|
||||
|
||||
@@ -57,8 +57,12 @@ namespace Ichni.RhythmGame
|
||||
startTimes.Add(flexibleFloat.animations[0].startTime);
|
||||
endTimes.Add(flexibleFloat.animations[^1].endTime);
|
||||
}
|
||||
else continue;
|
||||
}
|
||||
if (startTimes.Count == 0 || endTimes.Count == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
startTime = startTimes.Min();
|
||||
endTime = endTimes.Max();
|
||||
}
|
||||
@@ -94,7 +98,7 @@ namespace Ichni.RhythmGame
|
||||
IHaveInspection inspector = EditorManager.instance.uiManager.inspector;
|
||||
var container = inspector.GenerateContainer("Time Duration");
|
||||
var overrideToggle = inspector.GenerateToggle(this, container, "Override Duration", nameof(isOverridingDuration));
|
||||
|
||||
|
||||
var startTimeInputField = inspector.GenerateInputField(this, container, "Start Time", nameof(startTime));
|
||||
var endTimeInputField = inspector.GenerateInputField(this, container, "End Time", nameof(endTime));
|
||||
|
||||
|
||||
@@ -39,6 +39,17 @@ namespace Ichni.RhythmGame
|
||||
|
||||
point.isBeyond1 = trackPercent.animations.Any(animation => animation.endValue > 1); //判断是否有超过1的动画,超过1将会循环
|
||||
|
||||
|
||||
//添加默认动画
|
||||
if (point.parentElement is Track track1 && track1.submoduleList.Where(submodule => submodule is TrackTimeSubmoduleMovable).Count() == 1)
|
||||
{
|
||||
TrackTimeSubmoduleMovable trackTimeSubmoduleMovable = track1.submoduleList.Where(submodule => submodule is TrackTimeSubmoduleMovable).FirstOrDefault() as TrackTimeSubmoduleMovable;
|
||||
point.trackPercent.Add(
|
||||
new AnimatedFloat(trackTimeSubmoduleMovable.trackStartTime, trackTimeSubmoduleMovable.trackEndTime, 0, 1, AnimationCurveType.Linear)); //添加一个默认的动画
|
||||
|
||||
}
|
||||
|
||||
|
||||
return point;
|
||||
}
|
||||
|
||||
@@ -86,12 +97,12 @@ namespace Ichni.RhythmGame
|
||||
{
|
||||
inspector.GenerateCompositeParameterWindow(this, "Track Percent", nameof(trackPercent)).SetAsFlexibleFloat();
|
||||
});
|
||||
|
||||
|
||||
var generateTrailButton = inspector.GenerateButton(this, container, "Generate Trail", () =>
|
||||
{
|
||||
Trail.GenerateElement("New Trail", Guid.NewGuid(), new List<string>(),
|
||||
true, this, 1, true,
|
||||
1, AnimationCurve.Constant(0,1, 1));
|
||||
Trail.GenerateElement("New Trail", Guid.NewGuid(), new List<string>(),
|
||||
true, this, 1, true,
|
||||
1, AnimationCurve.Constant(0, 1, 1));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,14 +18,14 @@ namespace Ichni.RhythmGame
|
||||
public Track.TrackSpaceType trackSpaceType;
|
||||
public Track.TrackSamplingType trackSamplingType;
|
||||
public bool isClosed;
|
||||
|
||||
|
||||
public bool isShowingDisplay;
|
||||
|
||||
public TrackPathSubmodule(Track track, Track.TrackSpaceType trackSpaceType,
|
||||
public TrackPathSubmodule(Track track, Track.TrackSpaceType trackSpaceType,
|
||||
Track.TrackSamplingType trackSamplingType, bool isClosed, bool isShowingDisplay) : base(track)
|
||||
{
|
||||
this.path = track.AddComponent<SplineComputer>();
|
||||
|
||||
|
||||
this.track.trackPathSubmodule = this;
|
||||
this.pathNodeList = new List<PathNode>();
|
||||
this.trackSpaceType = trackSpaceType;
|
||||
@@ -33,15 +33,15 @@ namespace Ichni.RhythmGame
|
||||
this.isClosed = isClosed;
|
||||
|
||||
this.path.sampleRate = 16;
|
||||
|
||||
|
||||
SetUpSplineComputer(this.trackSpaceType, this.trackSamplingType);
|
||||
//闭合路径在PathNode生成时执行,在初始化的情况下,PathNode数量为0,不会执行闭合操作
|
||||
|
||||
|
||||
this.isShowingDisplay = isShowingDisplay;
|
||||
this.trackDisplay = UnityEngine.Object.Instantiate(EditorManager.instance.basePrefabs.trackDisplay, track.transform).GetComponent<SplineRenderer>();
|
||||
this.trackDisplay.spline = path;
|
||||
this.trackDisplay.size = 0.1f;
|
||||
|
||||
|
||||
this.SetDisplay(isShowingDisplay);
|
||||
}
|
||||
}
|
||||
@@ -77,13 +77,33 @@ namespace Ichni.RhythmGame
|
||||
{
|
||||
path.SetPoint(point.index, point.node, SplineComputer.Space.Local);
|
||||
}
|
||||
|
||||
|
||||
|
||||
public void SetDisplay(bool isShowing)
|
||||
{
|
||||
this.isShowingDisplay = isShowing;
|
||||
trackDisplay.gameObject.SetActive(isShowing);
|
||||
}
|
||||
|
||||
public override void Refresh()
|
||||
{
|
||||
if (trackSpaceType == Track.TrackSpaceType.Linear)
|
||||
{
|
||||
SetTrackSpaceType((int)Spline.Type.Linear);
|
||||
path.type = Spline.Type.Linear;
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
SetTrackSpaceType((int)trackSpaceType);
|
||||
SetUpSplineComputer(trackSpaceType, trackSamplingType);
|
||||
}
|
||||
|
||||
foreach (var pathNode in pathNodeList)
|
||||
{
|
||||
SetPathNode(pathNode);
|
||||
}
|
||||
ClosePath();
|
||||
}
|
||||
}
|
||||
|
||||
public partial class TrackPathSubmodule
|
||||
@@ -97,22 +117,22 @@ namespace Ichni.RhythmGame
|
||||
{
|
||||
IHaveInspection inspector = EditorManager.instance.uiManager.inspector;
|
||||
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));
|
||||
|
||||
var isClosedToggle =
|
||||
|
||||
var isClosedToggle =
|
||||
inspector.GenerateToggle(this, container, "Is Closed", nameof(isClosed));
|
||||
isClosedToggle.AddListenerFunction(ClosePath);
|
||||
|
||||
|
||||
var generatePathNodeButton = inspector.GenerateButton(this, container, "Generate Path Node", () =>
|
||||
{
|
||||
PathNode.GenerateElement("New Path Node", Guid.NewGuid(), new List<string>(), true, track, true);
|
||||
});
|
||||
|
||||
|
||||
var showDisplayToggle = inspector.GenerateToggle(this, container, "Show Display", nameof(isShowingDisplay));
|
||||
showDisplayToggle.AddListenerFunction(() => SetDisplay(isShowingDisplay));
|
||||
}
|
||||
@@ -126,10 +146,10 @@ namespace Ichni.RhythmGame
|
||||
public Track.TrackSamplingType trackSamplingType;
|
||||
public bool isClosed;
|
||||
public bool isShowingDisplay;
|
||||
|
||||
|
||||
public TrackPathSubmodule_BM()
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -155,6 +175,6 @@ namespace Ichni.RhythmGame
|
||||
track.trackPathSubmodule = new TrackPathSubmodule(track, trackSpaceType, trackSamplingType, isClosed, isShowingDisplay);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -61,7 +61,20 @@ namespace Ichni.RhythmGame
|
||||
float per = AnimationCurveEvaluator.Evaluate(animationCurveType, (songTimeInTime - trackStartTime) / trackTotalTime);
|
||||
return Mathf.Clamp01(per);
|
||||
}
|
||||
public override void Refresh()
|
||||
|
||||
{
|
||||
trackTotalTime = trackEndTime - trackStartTime;
|
||||
UpdateTrackPart();
|
||||
|
||||
track.childElementList.ForEach(child =>
|
||||
{
|
||||
if (child is NoteBase note)
|
||||
{
|
||||
note.UpdateNoteInTrack();
|
||||
}
|
||||
});
|
||||
}
|
||||
public override void SaveBM()
|
||||
{
|
||||
matchedBM = new Beatmap.TrackTimeSubmoduleMovable_BM(attachedGameElement, this);
|
||||
@@ -71,22 +84,22 @@ namespace Ichni.RhythmGame
|
||||
{
|
||||
IHaveInspection inspector = EditorManager.instance.uiManager.inspector;
|
||||
Inspector inspectorMain = EditorManager.instance.uiManager.inspector;
|
||||
|
||||
|
||||
var container = inspector.GenerateContainer("Track Time Movable");
|
||||
var startTimeInputField =
|
||||
inspector.GenerateInputField(this, container, "Start Time", nameof(trackStartTime));
|
||||
startTimeInputField.AddListenerFunction(RefreshChildren);
|
||||
|
||||
|
||||
var endTimeInputField = inspector.GenerateInputField(this, container, "End Time", nameof(trackEndTime));
|
||||
endTimeInputField.AddListenerFunction(RefreshChildren);
|
||||
|
||||
|
||||
var visibleTimeInputField =
|
||||
inspector.GenerateInputField(this, container, "Visible Time Length", nameof(visibleTrackTimeLength));
|
||||
|
||||
|
||||
var animationCurveDropdown = inspector.GenerateDropdown(this, container, "Animation Curve",
|
||||
typeof(AnimationCurveType), nameof(animationCurveType));
|
||||
animationCurveDropdown.AddListenerFunction(RefreshChildren);
|
||||
|
||||
|
||||
var deleteButton = inspector.GenerateButton(this, container, "Delete",
|
||||
() =>
|
||||
{
|
||||
@@ -117,12 +130,12 @@ namespace Ichni.RhythmGame
|
||||
public float trackEndTime;
|
||||
public float visibleTrackTimeLength;
|
||||
public AnimationCurveType animationCurveType;
|
||||
|
||||
|
||||
public TrackTimeSubmoduleMovable_BM()
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
public TrackTimeSubmoduleMovable_BM(GameElement attachedElement, TrackTimeSubmoduleMovable trackTimeSubmoduleMovable) : base(attachedElement)
|
||||
{
|
||||
trackStartTime = trackTimeSubmoduleMovable.trackStartTime;
|
||||
@@ -130,14 +143,14 @@ namespace Ichni.RhythmGame
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
public override void DuplicateBM(GameElement attached)
|
||||
{
|
||||
Track track = attached as Track;
|
||||
@@ -163,17 +176,31 @@ namespace Ichni.RhythmGame
|
||||
this.tailPercent = 1;
|
||||
//timeDurationSubmodule 根据下辖Note的时间来设置
|
||||
}
|
||||
|
||||
public override void Refresh()
|
||||
{
|
||||
if (track.trackRendererSubmodule != null)
|
||||
{
|
||||
track.trackRendererSubmodule.meshGenerator.clipFrom = tailPercent;
|
||||
track.trackRendererSubmodule.meshGenerator.clipTo = headPercent;
|
||||
}
|
||||
track.childElementList.ForEach(child =>
|
||||
{
|
||||
if (child is NoteBase note)
|
||||
{
|
||||
note.UpdateNoteInTrack();
|
||||
}
|
||||
});
|
||||
}
|
||||
public override void SaveBM()
|
||||
{
|
||||
matchedBM = new Beatmap.TrackTimeSubmoduleStatic_BM(attachedGameElement, this);
|
||||
}
|
||||
|
||||
|
||||
public override void SetUpInspector()
|
||||
{
|
||||
IHaveInspection inspector = EditorManager.instance.uiManager.inspector;
|
||||
Inspector inspectorMain = EditorManager.instance.uiManager.inspector;
|
||||
|
||||
|
||||
var container = inspector.GenerateContainer("Track Time Static");
|
||||
var totalTimeInputField =
|
||||
inspector.GenerateInputField(this, container, "Total Time", nameof(trackTotalTime));
|
||||
@@ -196,25 +223,25 @@ namespace Ichni.RhythmGame
|
||||
{
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
public override void DuplicateBM(GameElement attached)
|
||||
{
|
||||
Track track = attached as Track;
|
||||
|
||||
Reference in New Issue
Block a user