基础内容-7
Trail 完整Note
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
@@ -12,35 +13,10 @@ namespace Ichni.RhythmGame
|
||||
public FlexibleReturnType animationReturnType;
|
||||
//public ICanHaveAnimation target;
|
||||
|
||||
public void NewInitialize(string elementName, BaseElement targetObject)
|
||||
public override void Initialize(string elementName, Guid id, List<string> tags)
|
||||
{
|
||||
base.Initialize(elementName);
|
||||
this.targetObject = targetObject;
|
||||
SetParent(this.targetObject);
|
||||
}
|
||||
|
||||
public virtual void SetTimeDuration(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);
|
||||
}
|
||||
}
|
||||
|
||||
timeDurationSubmodule = new TimeDurationSubmodule(this, startTimes.Min(), endTimes.Max());
|
||||
}
|
||||
|
||||
public virtual void SetTimeDuration(float startTime, float endTime)
|
||||
{
|
||||
timeDurationSubmodule = new TimeDurationSubmodule(this, startTime, endTime);
|
||||
base.Initialize(elementName, id, tags);
|
||||
timeDurationSubmodule = new TimeDurationSubmodule(this);
|
||||
}
|
||||
|
||||
protected abstract void UpdateAnimation(float songTime);
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using Lean.Pool;
|
||||
@@ -10,12 +11,15 @@ namespace Ichni.RhythmGame
|
||||
public ColorSubmodule targetColorSubmodule;
|
||||
public FlexibleFloat colorR, colorG, colorB, colorA;
|
||||
|
||||
public static BaseColorChange GenerateElement(string elementName, BaseElement targetObject,
|
||||
public static BaseColorChange GenerateElement(string elementName, Guid id,
|
||||
List<string> tags, BaseElement targetObject,
|
||||
FlexibleFloat colorR, FlexibleFloat colorG, FlexibleFloat colorB, FlexibleFloat colorA)
|
||||
{
|
||||
BaseColorChange baseColorChange = Instantiate(EditorManager.instance.basePrefabs.emptyObject).AddComponent<BaseColorChange>();
|
||||
|
||||
baseColorChange.NewInitialize(elementName, targetObject);
|
||||
baseColorChange.Initialize(elementName, id, tags);
|
||||
baseColorChange.targetObject = targetObject;
|
||||
|
||||
baseColorChange.colorR = colorR;
|
||||
baseColorChange.colorG = colorG;
|
||||
baseColorChange.colorB = colorB;
|
||||
@@ -31,7 +35,8 @@ namespace Ichni.RhythmGame
|
||||
throw new System.Exception("Target object does not have a ColorSubmodule");
|
||||
}
|
||||
|
||||
baseColorChange.SetTimeDuration(colorR, colorG, colorB, colorA);
|
||||
baseColorChange.SetParent(targetObject);
|
||||
baseColorChange.timeDurationSubmodule.SetDuration(colorR, colorG, colorB, colorA);
|
||||
|
||||
return baseColorChange;
|
||||
}
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using Lean.Pool;
|
||||
@@ -10,30 +11,35 @@ namespace Ichni.RhythmGame
|
||||
public ColorSubmodule targetColorSubmodule;
|
||||
public FlexibleFloat colorR, colorG, colorB, colorI;
|
||||
|
||||
public static EmissionColorChange GenerateElement(string elementName, BaseElement targetObject,
|
||||
public static EmissionColorChange GenerateElement(string elementName, Guid id,
|
||||
List<string> tags, BaseElement targetObject,
|
||||
FlexibleFloat colorR, FlexibleFloat colorG, FlexibleFloat colorB, FlexibleFloat colorI)
|
||||
{
|
||||
EmissionColorChange baseColorChange = Instantiate(EditorManager.instance.basePrefabs.emptyObject).AddComponent<EmissionColorChange>();
|
||||
EmissionColorChange emissionColorChange = Instantiate(EditorManager.instance.basePrefabs.emptyObject).AddComponent<EmissionColorChange>();
|
||||
|
||||
baseColorChange.NewInitialize(elementName, targetObject);
|
||||
baseColorChange.colorR = colorR;
|
||||
baseColorChange.colorG = colorG;
|
||||
baseColorChange.colorB = colorB;
|
||||
baseColorChange.colorI = colorI;
|
||||
baseColorChange.animationReturnType = FlexibleReturnType.Before;
|
||||
emissionColorChange.Initialize(elementName, id, tags);
|
||||
emissionColorChange.targetObject = targetObject;
|
||||
|
||||
emissionColorChange.colorR = colorR;
|
||||
emissionColorChange.colorG = colorG;
|
||||
emissionColorChange.colorB = colorB;
|
||||
emissionColorChange.colorI = colorI;
|
||||
emissionColorChange.animationReturnType = FlexibleReturnType.Before;
|
||||
|
||||
if (targetObject.colorSubmodule != null)
|
||||
{
|
||||
baseColorChange.targetColorSubmodule = targetObject.colorSubmodule;
|
||||
emissionColorChange.targetColorSubmodule = targetObject.colorSubmodule;
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new System.Exception("Target object does not have a ColorSubmodule");
|
||||
}
|
||||
|
||||
baseColorChange.SetTimeDuration(colorR, colorG, colorB, colorI);
|
||||
emissionColorChange.SetParent(targetObject);
|
||||
|
||||
emissionColorChange.timeDurationSubmodule.SetDuration(colorR, colorG, colorB, colorI);
|
||||
|
||||
return baseColorChange;
|
||||
return emissionColorChange;
|
||||
}
|
||||
|
||||
protected override void UpdateAnimation(float songTime)
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using Lean.Pool;
|
||||
@@ -10,10 +11,13 @@ namespace Ichni.RhythmGame
|
||||
public FlexibleFloat totalTime;
|
||||
public TrackTimeSubmoduleStatic targetTrackTimeSubmoduleStatic;
|
||||
|
||||
public static TrackTotalTimeChange GenerateElement(string elementName, Track targetTrack, FlexibleFloat totalTime)
|
||||
public static TrackTotalTimeChange GenerateElement(string elementName, Guid id,
|
||||
List<string> tags, Track targetTrack, FlexibleFloat totalTime)
|
||||
{
|
||||
TrackTotalTimeChange trackTotalTimeChange = Instantiate(EditorManager.instance.basePrefabs.emptyObject).AddComponent<TrackTotalTimeChange>();
|
||||
trackTotalTimeChange.NewInitialize(elementName, targetTrack);
|
||||
trackTotalTimeChange.Initialize(elementName, id, tags);
|
||||
|
||||
trackTotalTimeChange.targetObject = targetTrack;
|
||||
|
||||
if (targetTrack.trackTimeSubmodule is TrackTimeSubmoduleStatic submoduleStatic)
|
||||
{
|
||||
@@ -26,7 +30,9 @@ namespace Ichni.RhythmGame
|
||||
|
||||
trackTotalTimeChange.totalTime = totalTime;
|
||||
trackTotalTimeChange.animationReturnType = FlexibleReturnType.Before;
|
||||
trackTotalTimeChange.SetTimeDuration(totalTime);
|
||||
trackTotalTimeChange.timeDurationSubmodule.SetDuration(totalTime);
|
||||
|
||||
trackTotalTimeChange.SetParent(targetTrack);
|
||||
return trackTotalTimeChange;
|
||||
}
|
||||
|
||||
|
||||
@@ -15,12 +15,15 @@ namespace Ichni.RhythmGame
|
||||
public TransformSubmodule targetTransformSubmodule;
|
||||
public FlexibleFloat positionX, positionY, positionZ;
|
||||
|
||||
public static Displacement GenerateElement(string elementName, BaseElement targetObject,
|
||||
public static Displacement GenerateElement(string elementName, Guid id,
|
||||
List<string> tags, BaseElement targetObject,
|
||||
FlexibleFloat positionX, FlexibleFloat positionY, FlexibleFloat positionZ)
|
||||
{
|
||||
Displacement displacement = Instantiate(EditorManager.instance.basePrefabs.emptyObject).AddComponent<Displacement>();
|
||||
|
||||
displacement.NewInitialize(elementName, targetObject);
|
||||
displacement.Initialize(elementName, id, tags);
|
||||
|
||||
displacement.targetObject = targetObject;
|
||||
|
||||
displacement.positionX = positionX;
|
||||
displacement.positionY = positionY;
|
||||
@@ -36,7 +39,9 @@ namespace Ichni.RhythmGame
|
||||
throw new System.Exception("Target object does not have a TransformSubmodule");
|
||||
}
|
||||
|
||||
displacement.SetTimeDuration(positionX, positionY, positionZ);
|
||||
displacement.SetParent(targetObject);
|
||||
|
||||
displacement.timeDurationSubmodule.SetDuration(positionX, positionY, positionZ);
|
||||
|
||||
return displacement;
|
||||
}
|
||||
|
||||
@@ -16,29 +16,33 @@ namespace Ichni.RhythmGame
|
||||
public BaseElement lookAtObject;
|
||||
public FlexibleBool enabling;
|
||||
|
||||
public static LookAt GenerateElement(string elementName, BaseElement targetObject,
|
||||
public static LookAt GenerateElement(string elementName, Guid id,
|
||||
List<string> tags, BaseElement targetObject,
|
||||
BaseElement lookAtTarget, FlexibleBool enabling)
|
||||
{
|
||||
LookAt swirl = Instantiate(EditorManager.instance.basePrefabs.emptyObject).AddComponent<LookAt>();
|
||||
LookAt look = Instantiate(EditorManager.instance.basePrefabs.emptyObject).AddComponent<LookAt>();
|
||||
|
||||
swirl.NewInitialize(elementName, targetObject);
|
||||
|
||||
swirl.lookAtObject = lookAtTarget;
|
||||
swirl.enabling = enabling;
|
||||
swirl.animationReturnType = FlexibleReturnType.Before;
|
||||
look.Initialize(elementName, id, tags);
|
||||
|
||||
look.targetObject = targetObject;
|
||||
look.lookAtObject = lookAtTarget;
|
||||
look.enabling = enabling;
|
||||
look.animationReturnType = FlexibleReturnType.Before;
|
||||
|
||||
if (targetObject.transformSubmodule != null)
|
||||
{
|
||||
swirl.targetTransformSubmodule = targetObject.transformSubmodule;
|
||||
look.targetTransformSubmodule = targetObject.transformSubmodule;
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new System.Exception("Target object does not have a TransformSubmodule");
|
||||
}
|
||||
|
||||
look.SetParent(targetObject);
|
||||
|
||||
swirl.SetTimeDuration(-999, 999); //TODO: 换为(-delay, songLength)
|
||||
look.timeDurationSubmodule.SetDuration(-999f, 999f); //TODO: 换为(-delay, songLength)
|
||||
|
||||
return swirl;
|
||||
return look;
|
||||
}
|
||||
|
||||
private void Start()
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
@@ -9,12 +10,15 @@ namespace Ichni.RhythmGame
|
||||
public TransformSubmodule targetTransformSubmodule;
|
||||
public FlexibleFloat scaleX, scaleY, scaleZ;
|
||||
|
||||
public static Scale GenerateElement(string elementName, BaseElement targetObject,
|
||||
public static Scale GenerateElement(string elementName, Guid id,
|
||||
List<string> tags, BaseElement targetObject,
|
||||
FlexibleFloat scaleX, FlexibleFloat scaleY, FlexibleFloat scaleZ)
|
||||
{
|
||||
Scale scale = Instantiate(EditorManager.instance.basePrefabs.emptyObject).AddComponent<Scale>();
|
||||
|
||||
scale.NewInitialize(elementName, targetObject);
|
||||
scale.Initialize(elementName, id, tags);
|
||||
|
||||
scale.targetObject = targetObject;
|
||||
|
||||
scale.scaleX = scaleX;
|
||||
scale.scaleY = scaleY;
|
||||
@@ -30,7 +34,8 @@ namespace Ichni.RhythmGame
|
||||
throw new System.Exception("Target object does not have a TransformSubmodule");
|
||||
}
|
||||
|
||||
scale.SetTimeDuration(scaleX, scaleY, scaleZ);
|
||||
scale.SetParent(targetObject);
|
||||
scale.timeDurationSubmodule.SetDuration(scaleX, scaleY, scaleZ);
|
||||
|
||||
return scale;
|
||||
}
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using Lean.Pool;
|
||||
@@ -10,12 +11,15 @@ namespace Ichni.RhythmGame
|
||||
public TransformSubmodule targetTransformSubmodule;
|
||||
public FlexibleFloat eulerAngleX, eulerAngleY, eulerAngleZ;
|
||||
|
||||
public static Swirl GenerateElement(string elementName, BaseElement targetObject,
|
||||
public static Swirl GenerateElement(string elementName, Guid id,
|
||||
List<string> tags, BaseElement targetObject,
|
||||
FlexibleFloat eulerAngleX, FlexibleFloat eulerAngleY, FlexibleFloat eulerAngleZ)
|
||||
{
|
||||
Swirl swirl = Instantiate(EditorManager.instance.basePrefabs.emptyObject).AddComponent<Swirl>();
|
||||
|
||||
swirl.NewInitialize(elementName, targetObject);
|
||||
swirl.Initialize(elementName, id, tags);
|
||||
|
||||
swirl.targetObject = targetObject;
|
||||
|
||||
swirl.eulerAngleX = eulerAngleX;
|
||||
swirl.eulerAngleY = eulerAngleY;
|
||||
@@ -31,7 +35,9 @@ namespace Ichni.RhythmGame
|
||||
throw new System.Exception("Target object does not have a TransformSubmodule");
|
||||
}
|
||||
|
||||
swirl.SetTimeDuration(eulerAngleX, eulerAngleY, eulerAngleZ);
|
||||
swirl.SetParent(targetObject);
|
||||
|
||||
swirl.timeDurationSubmodule.SetDuration(eulerAngleX, eulerAngleY, eulerAngleZ);
|
||||
|
||||
return swirl;
|
||||
}
|
||||
|
||||
@@ -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());
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@ namespace Ichni.Editor
|
||||
SetUpFunctions();
|
||||
|
||||
//Test
|
||||
functionInterpreter.Eval("Log(\"Hello World!\")");
|
||||
//functionInterpreter.Eval("Log(\"Hello World!\")");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,27 +0,0 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using Lean.Pool;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Ichni.RhythmGame
|
||||
{
|
||||
public class ElementFolder : BaseElement
|
||||
{
|
||||
public static ElementFolder GenerateElement(string name, BaseElement parentElement)
|
||||
{
|
||||
ElementFolder elementFolder = Instantiate(EditorManager.instance.basePrefabs.elementFolder).GetComponent<ElementFolder>();
|
||||
|
||||
elementFolder.Initialize(name);
|
||||
elementFolder.SetParent(parentElement);
|
||||
|
||||
elementFolder.transformSubmodule = new TransformSubmodule(elementFolder);
|
||||
elementFolder.timeDurationSubmodule = new TimeDurationSubmodule(elementFolder);
|
||||
//elementFolder.GenerateTab(parentElement);
|
||||
|
||||
elementFolder.SetTransformObserver();
|
||||
|
||||
return elementFolder;
|
||||
}
|
||||
}
|
||||
}
|
||||
8
Assets/Scripts/GameElements/ElementFolder.meta
Normal file
8
Assets/Scripts/GameElements/ElementFolder.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6944ee6ee5d024c15a16862148361df3
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
64
Assets/Scripts/GameElements/ElementFolder/ElementFolder.cs
Normal file
64
Assets/Scripts/GameElements/ElementFolder/ElementFolder.cs
Normal file
@@ -0,0 +1,64 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using Lean.Pool;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Ichni.RhythmGame
|
||||
{
|
||||
public partial class ElementFolder : BaseElement
|
||||
{
|
||||
public List<Track> trackList;
|
||||
|
||||
public static ElementFolder GenerateElement(string name, Guid id, List<string> tags, BaseElement parentElement)
|
||||
{
|
||||
ElementFolder elementFolder = Instantiate(EditorManager.instance.basePrefabs.elementFolder).GetComponent<ElementFolder>();
|
||||
|
||||
elementFolder.Initialize(name, id, tags);
|
||||
elementFolder.SetParent(parentElement);
|
||||
|
||||
elementFolder.transformSubmodule = new TransformSubmodule(elementFolder);
|
||||
elementFolder.timeDurationSubmodule = new TimeDurationSubmodule(elementFolder);
|
||||
//elementFolder.GenerateTab(parentElement);
|
||||
|
||||
elementFolder.SetTransformObserver();
|
||||
|
||||
return elementFolder;
|
||||
}
|
||||
}
|
||||
|
||||
public partial class ElementFolder
|
||||
{
|
||||
public override void SaveBM()
|
||||
{
|
||||
matchedBM = new Beatmap.ElementFolder_BM(elementName, elementGuid, tags, parentElement.matchedBM);
|
||||
}
|
||||
}
|
||||
|
||||
namespace Beatmap
|
||||
{
|
||||
public class ElementFolder_BM : BaseElement_BM
|
||||
{
|
||||
public ElementFolder_BM()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public ElementFolder_BM(string elementName, Guid elementGuid, List<string> tags, BaseElement_BM attachedElement)
|
||||
: base(elementName, elementGuid, tags, attachedElement)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public override void ExecuteBM()
|
||||
{
|
||||
matchedElement = ElementFolder.GenerateElement(elementName, elementGuid, tags, GetElement(attachedElementGuid));
|
||||
}
|
||||
|
||||
public override BaseElement DuplicateBM(BaseElement parent)
|
||||
{
|
||||
return ElementFolder.GenerateElement(elementName, elementGuid, tags, parent);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,3 +1,4 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using Lean.Pool;
|
||||
@@ -9,13 +10,14 @@ namespace Ichni.RhythmGame
|
||||
{
|
||||
public bool isStatic;
|
||||
|
||||
public static SubstantialObject GenerateElement(string elementName, string themeBundleName,
|
||||
string objectName, Vector3 position, Vector3 eulerAngles, Vector3 scale, BaseElement parent,
|
||||
public static SubstantialObject GenerateElement(string elementName, Guid id, List<string> tags,
|
||||
string themeBundleName, string objectName, BaseElement parent,
|
||||
Vector3 position, Vector3 eulerAngles, Vector3 scale,
|
||||
bool isStatic, bool isFirstGenerated = true)
|
||||
{
|
||||
EnvironmentObject themeBundleObject = ThemeBundleManager.instance.GetObject<EnvironmentObject>(themeBundleName, objectName);
|
||||
EnvironmentObject environmentObject = Instantiate(themeBundleObject, parent.transform).GetComponent<EnvironmentObject>();
|
||||
environmentObject.Initialize(elementName);
|
||||
environmentObject.Initialize(elementName, id, tags);
|
||||
environmentObject.isStatic = isStatic;
|
||||
return environmentObject;
|
||||
}
|
||||
|
||||
@@ -20,13 +20,14 @@ namespace Ichni.RhythmGame
|
||||
public float perspectiveAngle;
|
||||
public float orthographicSize;
|
||||
|
||||
public static GameCamera GenerateElement(string elementName, BaseElement parentElement,
|
||||
public static GameCamera GenerateElement(string elementName, Guid id,
|
||||
List<string> tags, BaseElement parentElement,
|
||||
CameraViewType cameraViewType, float perspectiveAngle, float orthographicSize,
|
||||
Vector3 initialPosition, Vector3 initialEulerAngles)
|
||||
{
|
||||
GameCamera gameCamera = Instantiate(EditorManager.instance.basePrefabs.gameCamera).GetComponent<GameCamera>();
|
||||
|
||||
gameCamera.Initialize(elementName);
|
||||
gameCamera.Initialize(elementName, id, tags);
|
||||
gameCamera.parentElement = parentElement;
|
||||
gameCamera.cameraViewType = cameraViewType;
|
||||
gameCamera.camera.orthographic = cameraViewType == CameraViewType.Orthographic;
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using Dreamteck.Splines;
|
||||
@@ -7,13 +8,14 @@ using UnityEngine;
|
||||
|
||||
namespace Ichni.RhythmGame
|
||||
{
|
||||
public class Flick : NoteBase
|
||||
public partial class Flick : NoteBase
|
||||
{
|
||||
public List<Vector2> availableFlickDirections;
|
||||
public static Flick GenerateElement(string elementName, float exactJudgeTime, BaseElement attach, List<Vector2> directions)
|
||||
public static Flick GenerateElement(string elementName, Guid id, List<string> tags,
|
||||
float exactJudgeTime, BaseElement attach, List<Vector2> directions)
|
||||
{
|
||||
Flick flick = Instantiate(EditorManager.instance.basePrefabs.tapNote, attach.transform).GetComponent<Flick>();
|
||||
flick.Initialize(elementName);
|
||||
flick.Initialize(elementName, id, tags);
|
||||
flick.exactJudgeTime = exactJudgeTime;
|
||||
flick.availableFlickDirections = directions;
|
||||
flick.transformSubmodule = new TransformSubmodule(flick);
|
||||
@@ -44,4 +46,42 @@ namespace Ichni.RhythmGame
|
||||
return flick;
|
||||
}
|
||||
}
|
||||
|
||||
public partial class Flick
|
||||
{
|
||||
public override void SaveBM()
|
||||
{
|
||||
matchedBM = new Beatmap.Flick_BM(elementName, elementGuid, tags, parentElement.matchedBM, exactJudgeTime, availableFlickDirections);
|
||||
}
|
||||
}
|
||||
|
||||
namespace Beatmap
|
||||
{
|
||||
public class Flick_BM : BaseElement_BM
|
||||
{
|
||||
public float exactJudgeTime;
|
||||
public List<Vector2> availableFlickDirections;
|
||||
public Flick_BM()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public Flick_BM(string elementName, Guid elementGuid, List<string> tags, BaseElement_BM attachedElement, float exactJudgeTime, List<Vector2> directions)
|
||||
: base(elementName, elementGuid, tags, attachedElement)
|
||||
{
|
||||
this.exactJudgeTime = exactJudgeTime;
|
||||
availableFlickDirections = directions;
|
||||
}
|
||||
|
||||
public override void ExecuteBM()
|
||||
{
|
||||
matchedElement = Flick.GenerateElement(elementName, elementGuid, tags, exactJudgeTime, GetElement(attachedElementGuid), availableFlickDirections);
|
||||
}
|
||||
|
||||
public override BaseElement DuplicateBM(BaseElement parent)
|
||||
{
|
||||
return Flick.GenerateElement(elementName, elementGuid, tags, exactJudgeTime, parent, availableFlickDirections);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -7,7 +7,7 @@ using UnityEngine;
|
||||
|
||||
namespace Ichni.RhythmGame
|
||||
{
|
||||
public abstract class NoteBase : BaseElement
|
||||
public abstract partial class NoteBase : BaseElement
|
||||
{
|
||||
[Title("Basic Info")]
|
||||
public float exactJudgeTime;
|
||||
@@ -41,9 +41,9 @@ namespace Ichni.RhythmGame
|
||||
public Vector2 noteScreenPosition;
|
||||
public bool isJudged;
|
||||
|
||||
public override void Initialize(string name)
|
||||
public override void Initialize(string name, Guid id, List<string> tags)
|
||||
{
|
||||
base.Initialize(name);
|
||||
base.Initialize(name, id, tags);
|
||||
generateEffects = new EffectSubmodule(this);
|
||||
generalJudgeEffects = new EffectSubmodule(this);
|
||||
perfectJudgeEffects = new EffectSubmodule(this);
|
||||
@@ -113,14 +113,23 @@ namespace Ichni.RhythmGame
|
||||
isJudged = true;
|
||||
}
|
||||
}
|
||||
|
||||
generateEffects.effectList.ForEach(e => e.UpdateEffect());
|
||||
|
||||
foreach (var effect in generateEffects.effectList)
|
||||
switch (EditorManager.instance.currentJudgeType)
|
||||
{
|
||||
effect.UpdateEffect();
|
||||
}
|
||||
foreach (var effect in perfectJudgeEffects.effectList)
|
||||
{
|
||||
effect.UpdateEffect();
|
||||
case NoteJudgeType.Perfect:
|
||||
perfectJudgeEffects.effectList.ForEach(e => e.UpdateEffect());
|
||||
break;
|
||||
case NoteJudgeType.Good:
|
||||
goodJudgeEffects.effectList.ForEach(e => e.UpdateEffect());
|
||||
break;
|
||||
case NoteJudgeType.Bad:
|
||||
badJudgeEffects.effectList.ForEach(e => e.UpdateEffect());
|
||||
break;
|
||||
case NoteJudgeType.Miss:
|
||||
missJudgeEffects.effectList.ForEach(e => e.UpdateEffect());
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -144,4 +153,15 @@ namespace Ichni.RhythmGame
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public abstract partial class NoteBase
|
||||
{
|
||||
public enum NoteJudgeType
|
||||
{
|
||||
Perfect,
|
||||
Good,
|
||||
Bad,
|
||||
Miss
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -13,11 +13,5 @@ namespace Ichni.RhythmGame
|
||||
|
||||
public List<GameObject> notePartList;
|
||||
public List<GameObject> effectPartList;
|
||||
|
||||
public void NewInitialize(NoteBase note)
|
||||
{
|
||||
base.Initialize(note.elementName + " Note Visual");
|
||||
this.note = note;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,3 +1,4 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using Dreamteck.Splines;
|
||||
@@ -7,12 +8,13 @@ using UnityEngine;
|
||||
|
||||
namespace Ichni.RhythmGame
|
||||
{
|
||||
public class Stay : NoteBase
|
||||
public partial class Stay : NoteBase
|
||||
{
|
||||
public static Stay GenerateElement(string elementName, float exactJudgeTime, BaseElement attach)
|
||||
public static Stay GenerateElement(string elementName, Guid id, List<string> tags,
|
||||
float exactJudgeTime, BaseElement attach)
|
||||
{
|
||||
Stay stay = Instantiate(EditorManager.instance.basePrefabs.tapNote, attach.transform).GetComponent<Stay>();
|
||||
stay.Initialize(elementName);
|
||||
stay.Initialize(elementName, id, tags);
|
||||
stay.exactJudgeTime = exactJudgeTime;
|
||||
stay.transformSubmodule = new TransformSubmodule(stay);
|
||||
stay.timeDurationSubmodule = new TimeDurationSubmodule(stay);
|
||||
@@ -42,4 +44,41 @@ namespace Ichni.RhythmGame
|
||||
return stay;
|
||||
}
|
||||
}
|
||||
|
||||
public partial class Stay
|
||||
{
|
||||
public override void SaveBM()
|
||||
{
|
||||
matchedBM = new Beatmap.Stay_BM(elementName, elementGuid, tags, parentElement.matchedBM, exactJudgeTime);
|
||||
}
|
||||
}
|
||||
|
||||
namespace Beatmap
|
||||
{
|
||||
public class Stay_BM : BaseElement_BM
|
||||
{
|
||||
public float exactJudgeTime;
|
||||
|
||||
public Stay_BM()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public Stay_BM(string elementName, Guid elementGuid, List<string> tags, BaseElement_BM attachedElement, float exactJudgeTime)
|
||||
: base(elementName, elementGuid, tags, attachedElement)
|
||||
{
|
||||
this.exactJudgeTime = exactJudgeTime;
|
||||
}
|
||||
|
||||
public override void ExecuteBM()
|
||||
{
|
||||
matchedElement = Stay.GenerateElement(elementName, elementGuid, tags, exactJudgeTime, GetElement(attachedElementGuid));
|
||||
}
|
||||
|
||||
public override BaseElement DuplicateBM(BaseElement parent)
|
||||
{
|
||||
return Stay.GenerateElement(elementName, elementGuid, tags, exactJudgeTime, parent);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,3 +1,4 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using Dreamteck.Splines;
|
||||
@@ -7,12 +8,13 @@ using UnityEngine;
|
||||
|
||||
namespace Ichni.RhythmGame
|
||||
{
|
||||
public class Tap : NoteBase
|
||||
public partial class Tap : NoteBase
|
||||
{
|
||||
public static Tap GenerateElement(string elementName, float exactJudgeTime, BaseElement attach)
|
||||
public static Tap GenerateElement(string elementName, Guid id, List<string> tags,
|
||||
float exactJudgeTime, BaseElement attach)
|
||||
{
|
||||
Tap tap = Instantiate(EditorManager.instance.basePrefabs.tapNote, attach.transform).GetComponent<Tap>();
|
||||
tap.Initialize(elementName);
|
||||
tap.Initialize(elementName, id, tags);
|
||||
tap.exactJudgeTime = exactJudgeTime;
|
||||
tap.transformSubmodule = new TransformSubmodule(tap);
|
||||
tap.timeDurationSubmodule = new TimeDurationSubmodule(tap);
|
||||
@@ -42,4 +44,41 @@ namespace Ichni.RhythmGame
|
||||
return tap;
|
||||
}
|
||||
}
|
||||
|
||||
public partial class Tap
|
||||
{
|
||||
public override void SaveBM()
|
||||
{
|
||||
matchedBM = new Beatmap.Tap_BM(elementName, elementGuid, tags, parentElement.matchedBM, exactJudgeTime);
|
||||
}
|
||||
}
|
||||
|
||||
namespace Beatmap
|
||||
{
|
||||
public class Tap_BM : BaseElement_BM
|
||||
{
|
||||
public float exactJudgeTime;
|
||||
|
||||
public Tap_BM()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public Tap_BM(string elementName, Guid elementGuid, List<string> tags, BaseElement_BM attachedElement, float exactJudgeTime)
|
||||
: base(elementName, elementGuid, tags, attachedElement)
|
||||
{
|
||||
this.exactJudgeTime = exactJudgeTime;
|
||||
}
|
||||
|
||||
public override void ExecuteBM()
|
||||
{
|
||||
matchedElement = Tap.GenerateElement(elementName, elementGuid, tags, exactJudgeTime, GetElement(attachedElementGuid));
|
||||
}
|
||||
|
||||
public override BaseElement DuplicateBM(BaseElement parent)
|
||||
{
|
||||
return Tap.GenerateElement(elementName, elementGuid, tags, exactJudgeTime, parent);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,3 +1,4 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using Lean.Pool;
|
||||
@@ -9,13 +10,13 @@ namespace Ichni.RhythmGame
|
||||
{
|
||||
public string themeBundleName, objectName;
|
||||
|
||||
public static SubstantialObject GenerateElement(string elementName, string themeBundleName,
|
||||
string objectName, Vector3 position, Vector3 eulerAngles, Vector3 scale, BaseElement parent,
|
||||
bool isFirstGenerated = true)
|
||||
public static SubstantialObject GenerateElement(string elementName, Guid id, List<string> tags,
|
||||
string themeBundleName, string objectName, Vector3 position, Vector3 eulerAngles, Vector3 scale,
|
||||
BaseElement parent, bool isFirstGenerated = true)
|
||||
{
|
||||
GameObject themeBundleObject = ThemeBundleManager.instance.GetObject<GameObject>(themeBundleName, objectName);
|
||||
SubstantialObject substantialObject = Instantiate(themeBundleObject, parent.transform).GetComponent<SubstantialObject>();
|
||||
substantialObject.Initialize(elementName);
|
||||
substantialObject.Initialize(elementName, id, tags);
|
||||
|
||||
substantialObject.transformSubmodule = new TransformSubmodule(substantialObject, position, eulerAngles, scale);
|
||||
substantialObject.timeDurationSubmodule = new TimeDurationSubmodule(substantialObject);
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using Dreamteck.Splines;
|
||||
@@ -18,12 +19,12 @@ namespace Ichni.RhythmGame
|
||||
|
||||
public SplinePoint node;
|
||||
|
||||
public static PathNode GenerateElement(string elementName, Track track, int index, Vector3 nodePosition,
|
||||
Vector3 nodeNormal, float nodeSize, Color nodeColor)
|
||||
public static PathNode GenerateElement(string elementName, Guid id, List<string> tags,
|
||||
Track track, Vector3 nodePosition, Vector3 nodeNormal, float nodeSize, Color nodeColor)
|
||||
{
|
||||
PathNode pathNode = Instantiate(EditorManager.instance.basePrefabs.pathNode, track.transform).GetComponent<PathNode>();
|
||||
|
||||
pathNode.Initialize(elementName);
|
||||
pathNode.Initialize(elementName, id, tags);
|
||||
pathNode.track = track;
|
||||
//pathNode.index = index;
|
||||
|
||||
|
||||
@@ -12,11 +12,12 @@ namespace Ichni.RhythmGame
|
||||
public TrackTimeSubmodule trackTimeSubmodule;
|
||||
public TrackRendererSubmodule trackRendererSubmodule;
|
||||
|
||||
public static Track GenerateElement(string elementName, BaseElement parent, Vector3 position)
|
||||
public static Track GenerateElement(string elementName, Guid id, List<string> tags,
|
||||
BaseElement parent, Vector3 position)
|
||||
{
|
||||
Track track = Instantiate(EditorManager.instance.basePrefabs.track, parent.transform).GetComponent<Track>();
|
||||
|
||||
track.Initialize(elementName);
|
||||
track.Initialize(elementName, id, tags);
|
||||
track.SetParent(parent);
|
||||
|
||||
track.transformSubmodule = new TransformSubmodule(track, position, Vector3.zero, Vector3.one);
|
||||
@@ -47,9 +48,9 @@ namespace Ichni.RhythmGame
|
||||
|
||||
public partial class Track
|
||||
{
|
||||
public override void Refresh()
|
||||
public override void SaveBM()
|
||||
{
|
||||
|
||||
matchedBM = new Beatmap.Track_BM(elementName, elementGuid, tags, parentElement.matchedBM);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -68,4 +69,31 @@ namespace Ichni.RhythmGame
|
||||
DistanceDistributed = 1
|
||||
}
|
||||
}
|
||||
|
||||
namespace Beatmap
|
||||
{
|
||||
public class Track_BM : BaseElement_BM
|
||||
{
|
||||
public Track_BM()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public Track_BM(string elementName, Guid elementGuid, List<string> tags, BaseElement_BM attachedElement)
|
||||
: base(elementName, elementGuid, tags, attachedElement)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public override void ExecuteBM()
|
||||
{
|
||||
matchedElement = Track.GenerateElement(elementName, elementGuid, tags, GetElement(attachedElementGuid), Vector3.zero);
|
||||
}
|
||||
|
||||
public override BaseElement DuplicateBM(BaseElement parent)
|
||||
{
|
||||
return Track.GenerateElement(elementName, elementGuid, tags, parent, Vector3.zero);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using Dreamteck.Splines;
|
||||
using Ichni.RhythmGame;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Ichni.RhythmGame
|
||||
{
|
||||
public class CrossTrackPoint : BaseElement
|
||||
{
|
||||
public ElementFolder trackListFolder;
|
||||
public Track nowAttachedTrack;
|
||||
private int nowAttachedTrackIndex;
|
||||
public SplinePositioner trackPositioner;
|
||||
|
||||
public FlexibleInt trackSwitch;
|
||||
public FlexibleFloat trackPercent;
|
||||
|
||||
public static CrossTrackPoint GenerateElement(string elementName, Guid id, List<string> tags,
|
||||
ElementFolder elementFolder, FlexibleInt trackSwitch, FlexibleFloat trackPercent)
|
||||
{
|
||||
CrossTrackPoint point = Instantiate(EditorManager.instance.basePrefabs.emptyObject, elementFolder.transform).AddComponent<CrossTrackPoint>();
|
||||
point.Initialize(elementName, id, tags);
|
||||
point.trackPositioner = point.gameObject.AddComponent<SplinePositioner>();
|
||||
point.nowAttachedTrackIndex = -1;
|
||||
point.trackListFolder = elementFolder;
|
||||
point.trackSwitch = trackSwitch;
|
||||
point.trackPercent = trackPercent;
|
||||
point.transformSubmodule = new TransformSubmodule(point);
|
||||
point.timeDurationSubmodule = new TimeDurationSubmodule(point);
|
||||
point.SetParent(elementFolder);
|
||||
|
||||
return point;
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
if (trackPercent.animations.Count > 0)
|
||||
{
|
||||
trackSwitch.UpdateFlexibleInt(EditorManager.instance.songModule.songTime);
|
||||
trackPercent.UpdateFlexibleFloat(EditorManager.instance.songModule.songTime);
|
||||
SetPoint();
|
||||
}
|
||||
}
|
||||
|
||||
private void SetPoint()
|
||||
{
|
||||
if (nowAttachedTrackIndex != trackSwitch.value && trackSwitch.value >= 0 && trackSwitch.value < trackListFolder.trackList.Count)
|
||||
{
|
||||
nowAttachedTrack = trackListFolder.trackList[trackSwitch.value];
|
||||
nowAttachedTrackIndex = trackSwitch.value;
|
||||
trackPositioner.spline = trackListFolder.trackList[trackSwitch.value].trackPathSubmodule.path;
|
||||
}
|
||||
|
||||
trackPositioner.SetPercent(trackPercent.value);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7dc68e9f357304d71a938d5e3f9b1125
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,3 +1,4 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using Dreamteck.Splines;
|
||||
@@ -12,24 +13,19 @@ namespace Ichni.RhythmGame
|
||||
public TrackTimeSubmoduleMovable trackTimeSubmoduleMovable;
|
||||
public SplinePositioner trackPositioner;
|
||||
|
||||
public static TrackHeadPoint GenerateElement(string elementName, Track track)
|
||||
public static TrackHeadPoint GenerateElement(string elementName, Guid id, List<string> tags, Track track)
|
||||
{
|
||||
TrackHeadPoint head = Instantiate(EditorManager.instance.basePrefabs.emptyObject, track.transform).AddComponent<TrackHeadPoint>();
|
||||
|
||||
head.NewInitialize(elementName, track);
|
||||
head.Initialize(elementName, id, tags);
|
||||
head.track = track;
|
||||
head.trackPositioner = head.gameObject.AddComponent<SplinePositioner>();
|
||||
head.trackPositioner.spline = track.trackPathSubmodule.path;
|
||||
head.trackTimeSubmoduleMovable = track.trackTimeSubmodule as TrackTimeSubmoduleMovable;
|
||||
head.SetParent(track);
|
||||
return head;
|
||||
}
|
||||
|
||||
private void NewInitialize(string elementName, Track track)
|
||||
{
|
||||
base.Initialize(elementName);
|
||||
this.track = track;
|
||||
this.trackPositioner = gameObject.AddComponent<SplinePositioner>();
|
||||
this.trackPositioner.spline = track.trackPathSubmodule.path;
|
||||
this.trackTimeSubmoduleMovable = track.trackTimeSubmodule as TrackTimeSubmoduleMovable;
|
||||
}
|
||||
|
||||
|
||||
public void Update()
|
||||
{
|
||||
if (track.timeDurationSubmodule.CheckTimeInDuration(EditorManager.instance.songModule.songTime))
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
@@ -19,27 +20,23 @@ namespace Ichni.RhythmGame
|
||||
|
||||
private bool isBeyond1 = false;
|
||||
|
||||
public static TrackPercentPoint GenerateElement(string elementName, Track track, FlexibleFloat trackPercent)
|
||||
public static TrackPercentPoint GenerateElement(string elementName, Guid id, List<string> tags,
|
||||
Track track, FlexibleFloat trackPercent)
|
||||
{
|
||||
TrackPercentPoint point = Instantiate(EditorManager.instance.basePrefabs.emptyObject, track.transform).AddComponent<TrackPercentPoint>();
|
||||
|
||||
point.NewInitialize(elementName, track, trackPercent);
|
||||
point.Initialize(elementName, id, tags);
|
||||
point.track = track;
|
||||
point.trackPositioner = point.gameObject.AddComponent<SplinePositioner>();
|
||||
point.trackPositioner.spline = track.trackPathSubmodule.path;
|
||||
point.trackPercent = trackPercent;
|
||||
point.SetParent(track);
|
||||
|
||||
point.isBeyond1 = trackPercent.animations.Any(animation => animation.endValue > 1);//判断是否有超过1的动画,超过1将会循环
|
||||
|
||||
return point;
|
||||
}
|
||||
|
||||
private void NewInitialize(string elementName, Track track, FlexibleFloat trackPercent)
|
||||
{
|
||||
base.Initialize(elementName);
|
||||
this.track = track;
|
||||
this.trackPositioner = gameObject.AddComponent<SplinePositioner>();
|
||||
this.trackPositioner.spline = track.trackPathSubmodule.path;
|
||||
this.trackPercent = trackPercent;
|
||||
}
|
||||
|
||||
|
||||
public void Update()
|
||||
{
|
||||
if (trackPercent.animations.Count > 0)
|
||||
|
||||
32
Assets/Scripts/GameElements/Track/Trail.cs
Normal file
32
Assets/Scripts/GameElements/Track/Trail.cs
Normal file
@@ -0,0 +1,32 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Ichni.RhythmGame
|
||||
{
|
||||
public class Trail : BaseElement
|
||||
{
|
||||
public TrailRenderer trailRenderer;
|
||||
public Material renderMaterial;
|
||||
|
||||
public float visibleTimeLength;
|
||||
|
||||
public static Trail GenerateElement(string name, Guid id, List<string> tags,
|
||||
BaseElement parentElement, float visibleTimeLength, Material material = null)
|
||||
{
|
||||
Trail trail = Instantiate(EditorManager.instance.basePrefabs.trail).GetComponent<Trail>();
|
||||
trail.trailRenderer = trail.GetComponent<TrailRenderer>();
|
||||
|
||||
trail.Initialize(name, id, tags);
|
||||
trail.renderMaterial = material == null ? EditorManager.instance.basePrefabs.defaultTrailMaterial : material;
|
||||
trail.trailRenderer.material = trail.renderMaterial;
|
||||
trail.visibleTimeLength = visibleTimeLength;
|
||||
trail.SetParent(parentElement);
|
||||
|
||||
trail.transformSubmodule = new TransformSubmodule(trail);
|
||||
|
||||
return trail;
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Assets/Scripts/GameElements/Track/Trail.cs.meta
Normal file
11
Assets/Scripts/GameElements/Track/Trail.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 48120e902e0734a51a10b8b4c0229afa
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user