79 lines
2.2 KiB
C#
79 lines
2.2 KiB
C#
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
|
|
}
|
|
}
|
|
} |