基础内容-7
Trail 完整Note
This commit is contained in:
@@ -2,6 +2,7 @@ using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Ichni.RhythmGame.Beatmap;
|
||||
using Sirenix.OdinInspector;
|
||||
using UniRx;
|
||||
using UnityEngine;
|
||||
@@ -13,9 +14,6 @@ namespace Ichni.RhythmGame
|
||||
{
|
||||
//物体名
|
||||
public string elementName;
|
||||
|
||||
//序列号
|
||||
public int serialNumber;
|
||||
|
||||
//标识 GUID
|
||||
public Guid elementGuid;
|
||||
@@ -24,14 +22,14 @@ namespace Ichni.RhythmGame
|
||||
public List<string> tags;
|
||||
|
||||
//存档
|
||||
//public BaseElement_BM matchedBM;
|
||||
public BaseElement_BM matchedBM;
|
||||
|
||||
//父游戏物体
|
||||
public BaseElement parentElement;
|
||||
|
||||
//子物体列表
|
||||
public List<BaseElement> childElementList = new List<BaseElement>();
|
||||
|
||||
|
||||
//次级模块
|
||||
public TimeDurationSubmodule timeDurationSubmodule;
|
||||
public TransformSubmodule transformSubmodule;
|
||||
@@ -41,10 +39,11 @@ namespace Ichni.RhythmGame
|
||||
/// 首次初始化
|
||||
/// </summary>
|
||||
/// <param name="name">物体名</param>
|
||||
public virtual void Initialize(string name)
|
||||
public virtual void Initialize(string name, Guid elementGuid, List<string> tags)
|
||||
{
|
||||
this.elementName = name;
|
||||
this.elementGuid = Guid.NewGuid();
|
||||
this.elementGuid = elementGuid;
|
||||
this.tags = tags;
|
||||
EditorManager.instance.elementList.Add(this);
|
||||
//GameManager.beatMapContainer.beatMapElementList.Add(this);
|
||||
//serialNumber = totalSerialNumber++;
|
||||
@@ -56,7 +55,7 @@ namespace Ichni.RhythmGame
|
||||
/// </summary>
|
||||
public virtual void AfterInitialize()
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -64,15 +63,7 @@ namespace Ichni.RhythmGame
|
||||
/// </summary>
|
||||
public virtual void Refresh()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 当物体被删除时执行的方法
|
||||
/// </summary>
|
||||
public virtual void OnDelete()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -88,25 +79,8 @@ namespace Ichni.RhythmGame
|
||||
transform.SetParent(parentElement.transform);
|
||||
}
|
||||
}
|
||||
|
||||
public virtual void Delete()
|
||||
{
|
||||
if (this.childElementList != null)
|
||||
{
|
||||
for (int i = 0; i < childElementList.Count; i++)
|
||||
{
|
||||
childElementList[i].Delete(); //删除子GameElement、
|
||||
}
|
||||
}
|
||||
|
||||
OnDelete();
|
||||
|
||||
EditorManager.instance.elementList.Remove(this); //从保存列表中剔除
|
||||
this.parentElement.childElementList.Remove(this);
|
||||
Destroy(gameObject); //销毁
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public abstract partial class BaseElement
|
||||
{
|
||||
private void Start()
|
||||
@@ -116,15 +90,14 @@ namespace Ichni.RhythmGame
|
||||
|
||||
public virtual void SetTimeDuration()
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
|
||||
[Button("Apply Time Duration From Child")]
|
||||
|
||||
public void ApplyTimeDuration()
|
||||
{
|
||||
childElementList.ForEach(x => x.ApplyTimeDuration());
|
||||
|
||||
timeDurationSubmodule?.SetDurationFromChildren(childElementList.Select(x=>x.timeDurationSubmodule).ToList());
|
||||
timeDurationSubmodule?.SetDurationFromChildren(childElementList.Select(x => x.timeDurationSubmodule)
|
||||
.ToList());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -147,11 +120,12 @@ namespace Ichni.RhythmGame
|
||||
{
|
||||
offset += scaleOffset;
|
||||
}
|
||||
|
||||
transformSubmodule.currentScale = transformSubmodule.originalScale + offset;
|
||||
transform.localScale = transformSubmodule.currentScale;
|
||||
transformSubmodule.scaleDirtyMark = false;
|
||||
}
|
||||
|
||||
|
||||
if (transformSubmodule.eulerAnglesDirtyMark)
|
||||
{
|
||||
Vector3 offset = Vector3.zero;
|
||||
@@ -159,11 +133,12 @@ namespace Ichni.RhythmGame
|
||||
{
|
||||
offset += eulerOffset;
|
||||
}
|
||||
|
||||
transformSubmodule.currentEulerAngles = transformSubmodule.originalEulerAngles + offset;
|
||||
transform.localEulerAngles = transformSubmodule.currentEulerAngles;
|
||||
transformSubmodule.eulerAnglesDirtyMark = false;
|
||||
}
|
||||
|
||||
|
||||
if (transformSubmodule.positionDirtyMark)
|
||||
{
|
||||
Vector3 offset = Vector3.zero;
|
||||
@@ -171,15 +146,116 @@ namespace Ichni.RhythmGame
|
||||
{
|
||||
offset += posOffset;
|
||||
}
|
||||
|
||||
transformSubmodule.currentPosition = transformSubmodule.originalPosition + offset;
|
||||
transform.localPosition = transformSubmodule.currentPosition;
|
||||
transformSubmodule.positionDirtyMark = false;
|
||||
}
|
||||
|
||||
|
||||
transformSubmodule.scaleOffset.Clear();
|
||||
transformSubmodule.eulerAnglesOffset.Clear();
|
||||
transformSubmodule.positionOffset.Clear();
|
||||
}).AddTo(gameObject);
|
||||
}
|
||||
}
|
||||
|
||||
public abstract partial class BaseElement //存档,删除,复制,粘贴
|
||||
{
|
||||
/// <summary>
|
||||
/// 用于生成存档
|
||||
/// </summary>
|
||||
public abstract void SaveBM();
|
||||
|
||||
/// <summary>
|
||||
/// 当物体被删除时执行的方法
|
||||
/// </summary>
|
||||
public virtual void OnDelete()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 删除物体,包括所有子物体
|
||||
/// </summary>
|
||||
[Button("Delete")]
|
||||
public virtual void Delete()
|
||||
{
|
||||
if (this.childElementList != null)
|
||||
{
|
||||
for (int i = 0; i < childElementList.Count; i++)
|
||||
{
|
||||
childElementList[i].Delete(); //删除子GameElement、
|
||||
}
|
||||
}
|
||||
|
||||
OnDelete();
|
||||
|
||||
#if UNITY_EDITOR
|
||||
Debug.Log("Delete " + elementName + "(" + elementGuid + ")");
|
||||
#endif
|
||||
|
||||
EditorManager.instance.elementList.Remove(this); //从保存列表中剔除
|
||||
this.parentElement.childElementList.Remove(this);
|
||||
Destroy(gameObject); //销毁
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
namespace Beatmap
|
||||
{
|
||||
[System.Serializable]
|
||||
public abstract class BaseElement_BM
|
||||
{
|
||||
[System.NonSerialized] public static Dictionary<Guid, BaseElement_BM> identifier; //存档类的标识符
|
||||
|
||||
[System.NonSerialized] public BaseElement matchedElement; //存档类对应的游戏物体
|
||||
public string elementName;
|
||||
public List<string> tags;
|
||||
public Guid elementGuid;
|
||||
public Guid attachedElementGuid;
|
||||
|
||||
public BaseElement_BM()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public BaseElement_BM(string elementName, Guid elementGuid, List<string> tags, BaseElement_BM attachedElement)
|
||||
{
|
||||
this.elementName = elementName;
|
||||
this.elementGuid = elementGuid;
|
||||
this.tags = tags;
|
||||
|
||||
this.attachedElementGuid = attachedElement?.elementGuid ?? Guid.Empty;
|
||||
|
||||
identifier.TryAdd(this.elementGuid, this);
|
||||
}
|
||||
|
||||
public static BaseElement_BM GetElementBM(Guid id)
|
||||
{
|
||||
if (identifier.TryGetValue(id, out BaseElement_BM element_BM))
|
||||
{
|
||||
return element_BM;
|
||||
}
|
||||
|
||||
Debug.LogAssertion("Element not found or do not have id");
|
||||
return null;
|
||||
}
|
||||
|
||||
public static BaseElement GetElement(Guid id)
|
||||
{
|
||||
return GetElementBM(id)?.matchedElement;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 用于从存档中生成物体
|
||||
/// </summary>
|
||||
public abstract void ExecuteBM();
|
||||
|
||||
/// <summary>
|
||||
/// 用于复制物体
|
||||
/// </summary>
|
||||
public abstract BaseElement DuplicateBM(BaseElement parent);
|
||||
}
|
||||
}
|
||||
}
|
||||
81
Assets/Scripts/Base/FlexibleTypes/FlexibleInt.cs
Normal file
81
Assets/Scripts/Base/FlexibleTypes/FlexibleInt.cs
Normal file
@@ -0,0 +1,81 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Ichni
|
||||
{
|
||||
[System.Serializable]
|
||||
public class AnimatedInt
|
||||
{
|
||||
public int value; //值
|
||||
public float time;
|
||||
|
||||
public AnimatedInt()
|
||||
{
|
||||
}
|
||||
|
||||
public AnimatedInt(int value, float time)
|
||||
{
|
||||
this.value = value;
|
||||
this.time = time;
|
||||
}
|
||||
}
|
||||
|
||||
[System.Serializable]
|
||||
public class FlexibleInt
|
||||
{
|
||||
public int value;
|
||||
public List<AnimatedInt> animations;
|
||||
|
||||
public FlexibleInt()
|
||||
{
|
||||
animations = new List<AnimatedInt>();
|
||||
}
|
||||
|
||||
public FlexibleInt(List<AnimatedInt> anim)
|
||||
{
|
||||
this.animations = anim;
|
||||
}
|
||||
|
||||
public void Add(AnimatedInt animatedInt)
|
||||
{
|
||||
animations.Add(animatedInt);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 在动画脚本的Update中更新Int Value
|
||||
/// </summary>
|
||||
/// <param name="歌曲时间"></param>
|
||||
public FlexibleReturnType UpdateFlexibleInt(float nowTime)
|
||||
{
|
||||
AnimatedInt nowAnimatedInt = GetAnimatedInt(nowTime); //获取当前时间点对应的AnimatedInt
|
||||
value = nowAnimatedInt.value; //更新value
|
||||
return FlexibleReturnType.MiddleExecuting;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取songTime对应的AnimatedInt的时间段
|
||||
/// </summary>
|
||||
/// <param name="歌曲时间"></param>
|
||||
/// <returns>返回距离当前时间最近的前一个AnimatedInt</returns>
|
||||
AnimatedInt GetAnimatedInt(float nowTime)
|
||||
{
|
||||
for (int i = 0; i < animations.Count; i++)
|
||||
{
|
||||
if (nowTime < animations[i].time)
|
||||
{
|
||||
if (i == 0)
|
||||
{
|
||||
return animations[i];
|
||||
}
|
||||
else
|
||||
{
|
||||
return animations[i - 1];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return new AnimatedInt(0, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Assets/Scripts/Base/FlexibleTypes/FlexibleInt.cs.meta
Normal file
11
Assets/Scripts/Base/FlexibleTypes/FlexibleInt.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 824c05113512f41048fc8189760bd7cc
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -29,6 +29,32 @@ namespace Ichni.RhythmGame
|
||||
{
|
||||
return time >= startTime - offset && time <= endTime + offset;
|
||||
}
|
||||
|
||||
public void SetDuration(float startTime, float endTime)
|
||||
{
|
||||
this.startTime = startTime;
|
||||
this.endTime = endTime;
|
||||
}
|
||||
|
||||
public void SetDuration(params FlexibleFloat[] flexibleFloats)
|
||||
{
|
||||
List<float> startTimes = new List<float>();
|
||||
List<float> endTimes = new List<float>();
|
||||
|
||||
foreach (FlexibleFloat flexibleFloat in flexibleFloats)
|
||||
{
|
||||
flexibleFloat.Sort();
|
||||
|
||||
if (flexibleFloat.animations.Count > 0)
|
||||
{
|
||||
startTimes.Add(flexibleFloat.animations[0].startTime);
|
||||
endTimes.Add(flexibleFloat.animations[^1].endTime);
|
||||
}
|
||||
}
|
||||
|
||||
startTime = startTimes.Min();
|
||||
endTime = endTimes.Max();
|
||||
}
|
||||
|
||||
public void SetDurationFromChildren(List<TimeDurationSubmodule> children)
|
||||
{
|
||||
|
||||
@@ -15,6 +15,10 @@ public class BasePrefabsCollection : SerializedScriptableObject
|
||||
public GameObject track;
|
||||
public GameObject pathNode;
|
||||
public Material defaultTrackMaterial;
|
||||
|
||||
[Title("Trail相关")]
|
||||
public GameObject trail;
|
||||
public Material defaultTrailMaterial;
|
||||
|
||||
[Title("Note 相关")]
|
||||
public GameObject tapNote;
|
||||
@@ -27,8 +31,7 @@ public class BasePrefabsCollection : SerializedScriptableObject
|
||||
public AudioClip holdNoteLoopSound;
|
||||
public AudioClip holdNoteEndSound;
|
||||
public AudioClip flickNoteSound;
|
||||
|
||||
|
||||
|
||||
[Title("Effect相关")]
|
||||
public GameObject bloomShake;
|
||||
}
|
||||
|
||||
@@ -11,10 +11,11 @@ namespace Ichni
|
||||
public class EditorManager : SerializedMonoBehaviour
|
||||
{
|
||||
public static EditorManager instance;
|
||||
|
||||
public SongModule songModule;
|
||||
public BasePrefabsCollection basePrefabs;
|
||||
|
||||
public SongModule songModule;
|
||||
public NoteBase.NoteJudgeType currentJudgeType;
|
||||
public BasePrefabsCollection basePrefabs;
|
||||
|
||||
public List<BaseElement> elementList = new List<BaseElement>();
|
||||
|
||||
private void Awake()
|
||||
@@ -24,19 +25,28 @@ namespace Ichni
|
||||
|
||||
private void Start()
|
||||
{
|
||||
var f0 = ElementFolder.GenerateElement("Folder", null);
|
||||
var dis0 = Displacement.GenerateElement("Displacement-0", f0,
|
||||
new FlexibleFloat(),
|
||||
new FlexibleFloat(new List<AnimatedFloat>(){new (0,2,0,2, AnimationCurveType.Linear)}),
|
||||
new FlexibleFloat());
|
||||
var t0 = Track.GenerateElement("Track", f0, Vector3.left * 5f);
|
||||
t0.trackPathSubmodule = new TrackPathSubmodule(t0, Track.TrackSpaceType.Linear, Track.TrackSamplingType.TimeDistributed, false);
|
||||
t0.trackTimeSubmodule = new TrackTimeSubmoduleMovable(t0, 0, 2, 1, AnimationCurveType.Linear);
|
||||
t0.trackRendererSubmodule = new TrackRendererSubmoduleAutoOrient(t0);
|
||||
var p0 = PathNode.GenerateElement("PathNode-0", t0, 0, new Vector3(-5,5,10), Vector3.forward, 1, Color.white);
|
||||
var p1 = PathNode.GenerateElement("PathNode-1", t0, 1, new Vector3(5,-5,10), Vector3.forward, 0, Color.red);
|
||||
var n0 = Tap.GenerateElement("Note-0", 1f, t0);
|
||||
var n0v = BasicNoteVisual.GenerateElement("Note-0-V", "basic", "BasicNoteTap3D", Vector3.zero, Vector3.zero, Vector3.one, n0);
|
||||
//currentJudgeType = NoteBase.NoteJudgeType.Perfect;
|
||||
|
||||
var f0 = ElementFolder.GenerateElement("Folder", Guid.NewGuid(), new List<string>(), null);
|
||||
// var dis0 = Displacement.GenerateElement("Displacement-0", f0,
|
||||
// new FlexibleFloat(),
|
||||
// new FlexibleFloat(new List<AnimatedFloat>(){new (0,2,0,2, AnimationCurveType.Linear)}),
|
||||
// new FlexibleFloat());
|
||||
var t0 = Track.GenerateElement("Track", Guid.NewGuid(), new List<string>(), f0, Vector3.left * 5f);
|
||||
t0.trackPathSubmodule = new TrackPathSubmodule(t0, Track.TrackSpaceType.Linear,
|
||||
Track.TrackSamplingType.TimeDistributed, false);
|
||||
t0.trackTimeSubmodule = new TrackTimeSubmoduleMovable(t0, 0, 2, 1, AnimationCurveType.OutQuad);
|
||||
var pp0 = TrackPercentPoint.GenerateElement("TrackPercentPoint-0", Guid.NewGuid(), new List<string>(), t0,
|
||||
new FlexibleFloat(new List<AnimatedFloat>() { new(0, 2, 0, 1, AnimationCurveType.OutQuad) }));
|
||||
var tr0 = Trail.GenerateElement("Trail-0", Guid.NewGuid(), new List<string>(), pp0, 5);
|
||||
// t0.trackRendererSubmodule = new TrackRendererSubmoduleAutoOrient(t0);
|
||||
var p0 = PathNode.GenerateElement("PathNode-0", Guid.NewGuid(), new List<string>(), t0,
|
||||
new Vector3(-5, 5, 10), Vector3.forward, 1, Color.white);
|
||||
var p1 = PathNode.GenerateElement("PathNode-1", Guid.NewGuid(), new List<string>(), t0,
|
||||
new Vector3(5, -5, 10), Vector3.forward, 0, Color.red);
|
||||
var n0 = Tap.GenerateElement("Note-0", Guid.NewGuid(), new List<string>(), 1f, t0);
|
||||
var n0v = BasicNoteVisual.GenerateElement("Note-0-V", Guid.NewGuid(), new List<string>(), "basic",
|
||||
"BasicNoteTap3D", Vector3.zero, Vector3.zero, Vector3.one, n0);
|
||||
|
||||
elementList.ForEach(e => e.AfterInitialize());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user