基础内容
必要插件安装 缓动曲线和动画基础 ElementFolder,Track与其次级模块,PathNode重构
This commit is contained in:
79
Assets/Scripts/GameElements/Track/Track.cs
Normal file
79
Assets/Scripts/GameElements/Track/Track.cs
Normal file
@@ -0,0 +1,79 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using Lean.Pool;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Ichni.RhythmGame
|
||||
{
|
||||
public partial class Track : BaseElement
|
||||
{
|
||||
public TrackPathSubmodule trackPathSubmodule;
|
||||
public TrackTimeSubmodule trackTimeSubmodule;
|
||||
public TrackRendererSubmodule trackRendererSubmodule;
|
||||
|
||||
public static Track GenerateElement(string elementName, BaseElement parent, Vector3 position)
|
||||
{
|
||||
if (parent == null)
|
||||
{
|
||||
throw new System.Exception("Parent is null");
|
||||
}
|
||||
|
||||
Track track = LeanPool.Spawn(EditorManager.instance.basePrefabs.track, parent.transform).GetComponent<Track>();
|
||||
|
||||
track.NewInitialize(elementName, position);
|
||||
track.SetParent(parent);
|
||||
|
||||
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()
|
||||
{
|
||||
trackPathSubmodule.path.RebuildImmediate();
|
||||
//Refresh();
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
if (timeDurationSubmodule.CheckTimeInDuration(EditorManager.instance.songModule.songTime))
|
||||
{
|
||||
(trackTimeSubmodule as TrackTimeSubmoduleMovable)?.UpdateTrackPart();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public partial class Track
|
||||
{
|
||||
public override void Refresh()
|
||||
{
|
||||
transform.localPosition = transformSubmodule.currentPosition;
|
||||
}
|
||||
}
|
||||
|
||||
public partial class Track
|
||||
{
|
||||
public enum TrackSpaceType
|
||||
{
|
||||
CatmullRom = 0,
|
||||
BSpline = 1,
|
||||
Linear = 3
|
||||
}
|
||||
|
||||
public enum TrackSamplingType
|
||||
{
|
||||
TimeDistributed = 0,
|
||||
DistanceDistributed = 1
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user