基础内容-8

添加BM存档类
This commit is contained in:
SoulliesOfficial
2025-02-02 21:59:43 -05:00
parent efca87e9cd
commit bc1c5d65ef
20 changed files with 926 additions and 90 deletions

View File

@@ -1,25 +1,27 @@
using System;
using System.Collections;
using System.Collections.Generic;
using Ichni.RhythmGame.Beatmap;
using Lean.Pool;
using UnityEngine;
namespace Ichni.RhythmGame
{
public class BaseColorChange : AnimationBase
public partial class BaseColorChange : AnimationBase
{
public ColorSubmodule targetColorSubmodule;
public FlexibleFloat colorR, colorG, colorB, colorA;
public static BaseColorChange GenerateElement(string elementName, Guid id,
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 baseColorChange = Instantiate(EditorManager.instance.basePrefabs.emptyObject)
.AddComponent<BaseColorChange>();
baseColorChange.Initialize(elementName, id, tags);
baseColorChange.targetObject = targetObject;
baseColorChange.colorR = colorR;
baseColorChange.colorG = colorG;
baseColorChange.colorB = colorB;
@@ -34,7 +36,7 @@ namespace Ichni.RhythmGame
{
throw new System.Exception("Target object does not have a ColorSubmodule");
}
baseColorChange.SetParent(targetObject);
baseColorChange.timeDurationSubmodule.SetDuration(colorR, colorG, colorB, colorA);
@@ -47,10 +49,10 @@ namespace Ichni.RhythmGame
colorG.UpdateFlexibleFloat(songTime);
colorB.UpdateFlexibleFloat(songTime);
colorA.UpdateFlexibleFloat(songTime);
if (colorR.returnType is FlexibleReturnType.MiddleExecuting ||
colorG.returnType is FlexibleReturnType.MiddleExecuting ||
colorB.returnType is FlexibleReturnType.MiddleExecuting ||
if (colorR.returnType is FlexibleReturnType.MiddleExecuting ||
colorG.returnType is FlexibleReturnType.MiddleExecuting ||
colorB.returnType is FlexibleReturnType.MiddleExecuting ||
colorA.returnType is FlexibleReturnType.MiddleExecuting)
{
animationReturnType = FlexibleReturnType.MiddleExecuting;
@@ -64,4 +66,51 @@ namespace Ichni.RhythmGame
}
}
}
public partial class BaseColorChange
{
public override void SaveBM()
{
matchedBM = new BaseColorChange_BM(elementName, elementGuid, tags, targetObject.matchedBM as BaseElement_BM,
colorR.ConvertToBM(), colorG.ConvertToBM(), colorB.ConvertToBM(), colorA.ConvertToBM());
}
}
namespace Beatmap
{
public class BaseColorChange_BM : BaseElement_BM
{
public FlexibleFloat_BM colorR, colorG, colorB, colorA;
public BaseColorChange_BM()
{
}
public BaseColorChange_BM(string elementName, Guid elementGuid, List<string> tags,
BaseElement_BM attachedElement, FlexibleFloat_BM colorR, FlexibleFloat_BM colorG,
FlexibleFloat_BM colorB, FlexibleFloat_BM colorA) : base(elementName, elementGuid, tags,
attachedElement)
{
this.colorR = colorR;
this.colorG = colorG;
this.colorB = colorB;
this.colorA = colorA;
}
public override void ExecuteBM()
{
BaseColorChange.GenerateElement(elementName, elementGuid, tags, GetElement(attachedElementGuid),
colorR.ConvertToGameType(), colorG.ConvertToGameType(), colorB.ConvertToGameType(),
colorA.ConvertToGameType());
}
public override BaseElement DuplicateBM(BaseElement parent)
{
return BaseColorChange.GenerateElement(elementName, elementGuid, tags, parent,
colorR.ConvertToGameType(), colorG.ConvertToGameType(), colorB.ConvertToGameType(),
colorA.ConvertToGameType());
}
}
}
}

View File

@@ -1,12 +1,13 @@
using System;
using System.Collections;
using System.Collections.Generic;
using Ichni.RhythmGame.Beatmap;
using Lean.Pool;
using UnityEngine;
namespace Ichni.RhythmGame
{
public class EmissionColorChange : AnimationBase
public partial class EmissionColorChange : AnimationBase
{
public ColorSubmodule targetColorSubmodule;
public FlexibleFloat colorR, colorG, colorB, colorI;
@@ -68,4 +69,47 @@ namespace Ichni.RhythmGame
}
}
}
public partial class EmissionColorChange
{
public override void SaveBM()
{
matchedBM = new EmissionColorChange_BM(elementName, elementGuid, tags, targetObject.matchedBM,
colorR.ConvertToBM(), colorG.ConvertToBM(), colorB.ConvertToBM(), colorI.ConvertToBM());
}
}
namespace Beatmap
{
public class EmissionColorChange_BM : BaseElement_BM
{
public FlexibleFloat_BM colorR, colorG, colorB, colorI;
public EmissionColorChange_BM()
{
}
public EmissionColorChange_BM(string elementName, Guid elementGuid, List<string> tags, BaseElement_BM parentElement,
FlexibleFloat_BM colorR, FlexibleFloat_BM colorG, FlexibleFloat_BM colorB, FlexibleFloat_BM colorI) : base(elementName, elementGuid, tags, parentElement)
{
this.colorR = colorR;
this.colorG = colorG;
this.colorB = colorB;
this.colorI = colorI;
}
public override void ExecuteBM()
{
EmissionColorChange.GenerateElement(elementName, elementGuid, tags, GetElement(attachedElementGuid),
colorR.ConvertToGameType(), colorG.ConvertToGameType(), colorB.ConvertToGameType(), colorI.ConvertToGameType());
}
public override BaseElement DuplicateBM(BaseElement parent)
{
return EmissionColorChange.GenerateElement(elementName, elementGuid, tags, parent,
colorR.ConvertToGameType(), colorG.ConvertToGameType(), colorB.ConvertToGameType(), colorI.ConvertToGameType());
}
}
}
}

View File

@@ -1,24 +1,26 @@
using System;
using System.Collections;
using System.Collections.Generic;
using Ichni.RhythmGame.Beatmap;
using Lean.Pool;
using UnityEngine;
namespace Ichni.RhythmGame
{
public class TrackTotalTimeChange : AnimationBase
public partial class TrackTotalTimeChange : AnimationBase
{
public FlexibleFloat totalTime;
public TrackTimeSubmoduleStatic targetTrackTimeSubmoduleStatic;
public static TrackTotalTimeChange GenerateElement(string elementName, Guid id,
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 trackTotalTimeChange = Instantiate(EditorManager.instance.basePrefabs.emptyObject)
.AddComponent<TrackTotalTimeChange>();
trackTotalTimeChange.Initialize(elementName, id, tags);
trackTotalTimeChange.targetObject = targetTrack;
if (targetTrack.trackTimeSubmodule is TrackTimeSubmoduleStatic submoduleStatic)
{
trackTotalTimeChange.targetTrackTimeSubmoduleStatic = submoduleStatic;
@@ -31,7 +33,7 @@ namespace Ichni.RhythmGame
trackTotalTimeChange.totalTime = totalTime;
trackTotalTimeChange.animationReturnType = FlexibleReturnType.Before;
trackTotalTimeChange.timeDurationSubmodule.SetDuration(totalTime);
trackTotalTimeChange.SetParent(targetTrack);
return trackTotalTimeChange;
}
@@ -39,11 +41,51 @@ namespace Ichni.RhythmGame
protected override void UpdateAnimation(float songTime)
{
totalTime.UpdateFlexibleFloat(songTime);
if (totalTime.returnType == FlexibleReturnType.MiddleExecuting)
{
targetTrackTimeSubmoduleStatic.trackTotalTime = totalTime.value;
}
}
}
public partial class TrackTotalTimeChange
{
public override void SaveBM()
{
matchedBM = new TrackTotalTimeChange_BM(elementName, elementGuid, tags, targetObject.matchedBM as Track_BM, totalTime.ConvertToBM());
}
}
namespace Beatmap
{
public class TrackTotalTimeChange_BM : BaseElement_BM
{
public FlexibleFloat_BM totalTime;
public TrackTotalTimeChange_BM()
{
}
public TrackTotalTimeChange_BM(string elementName, Guid elementGuid, List<string> tags,
BaseElement_BM attachedElement, FlexibleFloat_BM totalTime) : base(elementName, elementGuid, tags,
attachedElement)
{
this.totalTime = totalTime;
}
public override void ExecuteBM()
{
TrackTotalTimeChange.GenerateElement(elementName, elementGuid, tags,
GetElement(attachedElementGuid) as Track, totalTime.ConvertToGameType());
}
public override BaseElement DuplicateBM(BaseElement parent)
{
return TrackTotalTimeChange.GenerateElement(elementName, elementGuid, tags, parent as Track,
totalTime.ConvertToGameType());
}
}
}
}

View File

@@ -10,7 +10,7 @@ using UnityEngine;
namespace Ichni.RhythmGame
{
public class Displacement : AnimationBase
public partial class Displacement : AnimationBase
{
public TransformSubmodule targetTransformSubmodule;
public FlexibleFloat positionX, positionY, positionZ;
@@ -84,4 +84,47 @@ namespace Ichni.RhythmGame
// }
}
}
public partial class Displacement
{
public override void SaveBM()
{
matchedBM = new Beatmap.Displacement_BM(elementName, elementGuid, tags, parentElement.matchedBM,
positionX.ConvertToBM(), positionY.ConvertToBM(), positionZ.ConvertToBM());
}
}
namespace Beatmap
{
public class Displacement_BM : BaseElement_BM
{
public FlexibleFloat_BM positionX, positionY, positionZ;
public Displacement_BM()
{
}
public Displacement_BM(string elementName, Guid elementGuid, List<string> tags,
BaseElement_BM attachedElement, FlexibleFloat_BM positionX, FlexibleFloat_BM positionY, FlexibleFloat_BM positionZ)
: base(elementName, elementGuid, tags, attachedElement)
{
this.positionX = positionX;
this.positionY = positionY;
this.positionZ = positionZ;
}
public override void ExecuteBM()
{
Displacement.GenerateElement(elementName, elementGuid, tags, GetElement(attachedElementGuid),
positionX.ConvertToGameType(), positionY.ConvertToGameType(), positionZ.ConvertToGameType());
}
public override BaseElement DuplicateBM(BaseElement parent)
{
return Displacement.GenerateElement(elementName, elementGuid, tags, parent,
positionX.ConvertToGameType(), positionY.ConvertToGameType(), positionZ.ConvertToGameType());
}
}
}
}

View File

@@ -10,7 +10,7 @@ namespace Ichni.RhythmGame
/// <summary>
/// 将物体的z轴指向目标物体注意LookAt的启用期间物体的旋转将被锁定
/// </summary>
public class LookAt : AnimationBase
public partial class LookAt : AnimationBase
{
public TransformSubmodule targetTransformSubmodule;
public BaseElement lookAtObject;
@@ -23,7 +23,7 @@ namespace Ichni.RhythmGame
LookAt look = Instantiate(EditorManager.instance.basePrefabs.emptyObject).AddComponent<LookAt>();
look.Initialize(elementName, id, tags);
look.targetObject = targetObject;
look.lookAtObject = lookAtTarget;
look.enabling = enabling;
@@ -37,7 +37,7 @@ namespace Ichni.RhythmGame
{
throw new System.Exception("Target object does not have a TransformSubmodule");
}
look.SetParent(targetObject);
look.timeDurationSubmodule.SetDuration(-999f, 999f); //TODO: 换为(-delay, songLength)
@@ -71,5 +71,44 @@ namespace Ichni.RhythmGame
targetTransformSubmodule.eulerAnglesOffsetLock = false;
}
}
public override void SaveBM()
{
matchedBM = new Beatmap.LookAt_BM(elementName, elementGuid, tags, parentElement.matchedBM,
enabling.ConvertToBM(), lookAtObject.elementGuid);
}
}
namespace Beatmap
{
public class LookAt_BM : BaseElement_BM
{
public FlexibleBool_BM enabling;
public Guid lookAtObjectGuid;
public LookAt_BM()
{
}
public LookAt_BM(string elementName, Guid elementGuid, List<string> tags,
BaseElement_BM attachedElement, FlexibleBool_BM enabling, Guid lookAtObjectGuid) : base(elementName,
elementGuid, tags, attachedElement)
{
this.enabling = enabling;
this.lookAtObjectGuid = lookAtObjectGuid;
}
public override void ExecuteBM()
{
matchedElement = LookAt.GenerateElement(elementName, elementGuid, tags,
GetElement(attachedElementGuid), GetElement(lookAtObjectGuid), enabling.ConvertToGameType());
}
public override BaseElement DuplicateBM(BaseElement parent)
{
return LookAt.GenerateElement(elementName, elementGuid, tags, parent,
GetElement(lookAtObjectGuid), enabling.ConvertToGameType());
}
}
}
}

View File

@@ -5,26 +5,26 @@ using UnityEngine;
namespace Ichni.RhythmGame
{
public class Scale : AnimationBase
public partial class Scale : AnimationBase
{
public TransformSubmodule targetTransformSubmodule;
public FlexibleFloat scaleX, scaleY, scaleZ;
public static Scale GenerateElement(string elementName, Guid id,
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.Initialize(elementName, id, tags);
scale.targetObject = targetObject;
scale.scaleX = scaleX;
scale.scaleY = scaleY;
scale.scaleZ = scaleZ;
scale.animationReturnType = FlexibleReturnType.Before;
if (targetObject.transformSubmodule != null)
{
scale.targetTransformSubmodule = targetObject.transformSubmodule;
@@ -33,13 +33,13 @@ namespace Ichni.RhythmGame
{
throw new System.Exception("Target object does not have a TransformSubmodule");
}
scale.SetParent(targetObject);
scale.timeDurationSubmodule.SetDuration(scaleX, scaleY, scaleZ);
return scale;
}
protected override void UpdateAnimation(float songTime)
{
scaleX.UpdateFlexibleFloat(songTime);
@@ -54,11 +54,55 @@ namespace Ichni.RhythmGame
Vector3 currentScale = new Vector3(scaleX.value, scaleY.value, scaleZ.value);
targetTransformSubmodule.scaleOffset.Add(currentScale);
targetTransformSubmodule.scaleDirtyMark = true;
}
}
else
{
animationReturnType = FlexibleReturnType.MiddleInterval;
}
}
}
public partial class Scale
{
public override void SaveBM()
{
matchedBM = new Beatmap.Scale_BM(elementName, elementGuid, tags, parentElement.matchedBM,
scaleX.ConvertToBM(), scaleY.ConvertToBM(), scaleZ.ConvertToBM());
}
}
namespace Beatmap
{
public class Scale_BM : BaseElement_BM
{
public FlexibleFloat_BM scaleX, scaleY, scaleZ;
public Scale_BM()
{
}
public Scale_BM(string elementName, Guid elementGuid, List<string> tags,
BaseElement_BM attachedElement, FlexibleFloat_BM scaleX, FlexibleFloat_BM scaleY,
FlexibleFloat_BM scaleZ)
: base(elementName, elementGuid, tags, attachedElement)
{
this.scaleX = scaleX;
this.scaleY = scaleY;
this.scaleZ = scaleZ;
}
public override void ExecuteBM()
{
Scale.GenerateElement(elementName, elementGuid, tags, GetElement(attachedElementGuid),
scaleX.ConvertToGameType(), scaleY.ConvertToGameType(), scaleZ.ConvertToGameType());
}
public override BaseElement DuplicateBM(BaseElement parent)
{
return Scale.GenerateElement(elementName, elementGuid, tags, parent, scaleX.ConvertToGameType(),
scaleY.ConvertToGameType(), scaleZ.ConvertToGameType());
}
}
}
}

View File

@@ -6,7 +6,7 @@ using UnityEngine;
namespace Ichni.RhythmGame
{
public class Swirl : AnimationBase
public partial class Swirl : AnimationBase
{
public TransformSubmodule targetTransformSubmodule;
public FlexibleFloat eulerAngleX, eulerAngleY, eulerAngleZ;
@@ -63,4 +63,46 @@ namespace Ichni.RhythmGame
}
}
}
public partial class Swirl
{
public override void SaveBM()
{
matchedBM = new Beatmap.Swirl_BM(elementName, elementGuid, tags, parentElement.matchedBM,
eulerAngleX.ConvertToBM(), eulerAngleY.ConvertToBM(), eulerAngleZ.ConvertToBM());
}
}
namespace Beatmap
{
public class Swirl_BM : BaseElement_BM
{
public FlexibleFloat_BM eulerAngleX, eulerAngleY, eulerAngleZ;
public Swirl_BM()
{
}
public Swirl_BM(string elementName, Guid elementGuid, List<string> tags,
BaseElement_BM attachedElement, FlexibleFloat_BM eulerAngleX, FlexibleFloat_BM eulerAngleY, FlexibleFloat_BM eulerAngleZ)
: base(elementName, elementGuid, tags, attachedElement)
{
this.eulerAngleX = eulerAngleX;
this.eulerAngleY = eulerAngleY;
this.eulerAngleZ = eulerAngleZ;
}
public override void ExecuteBM()
{
Swirl.GenerateElement(elementName, elementGuid, tags, GetElement(attachedElementGuid),
eulerAngleX.ConvertToGameType(), eulerAngleY.ConvertToGameType(), eulerAngleZ.ConvertToGameType());
}
public override BaseElement DuplicateBM(BaseElement parent)
{
return Swirl.GenerateElement(elementName, elementGuid, tags, parent,
eulerAngleX.ConvertToGameType(), eulerAngleY.ConvertToGameType(), eulerAngleZ.ConvertToGameType());
}
}
}
}

View File

@@ -1,16 +1,16 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Ichni.RhythmGame.Beatmap;
namespace Ichni
namespace Ichni.RhythmGame
{
[System.Serializable]
public class AnimatedBool
{
public bool value; //bool值
public float time; //当前时间
public AnimatedBool(bool value, float time)
public AnimatedBool(float time, bool value)
{
this.value = value;
this.time = time;
@@ -37,7 +37,7 @@ namespace Ichni
{
animations.Add(animatedBool);
}
/// <summary>
/// 在动画脚本的Update中更新Bool Value
/// </summary>
@@ -48,7 +48,7 @@ namespace Ichni
value = nowAnimatedBool.value; //更新value
return FlexibleReturnType.MiddleExecuting;
}
/// <summary>
/// 获取songTime对应的AnimatedBool的时间段
/// </summary>
@@ -64,7 +64,63 @@ namespace Ichni
}
}
return new AnimatedBool(false, 0);
return new AnimatedBool(0, false);
}
/// <summary>
/// 转换为Beatmap存档类型
/// </summary>
/// <returns></returns>
public FlexibleBool_BM ConvertToBM()
{
FlexibleBool_BM flexibleBool_BM = new FlexibleBool_BM();
foreach (AnimatedBool animatedBool in animations)
{
flexibleBool_BM.animatedBoolList.Add(new AnimatedBool(animatedBool.time, animatedBool.value));
}
return flexibleBool_BM;
}
}
namespace Beatmap
{
public class FlexibleBool_BM
{
public List<AnimatedBool> animatedBoolList;
public FlexibleBool_BM()
{
this.animatedBoolList = new List<AnimatedBool>();
}
public FlexibleBool_BM(List<AnimatedBool> animatedBoolList)
{
this.animatedBoolList = animatedBoolList;
}
public FlexibleBool ConvertToGameType()
{
FlexibleBool flexibleBool;
if (this.animatedBoolList.Count == 0)
{
flexibleBool = new FlexibleBool();
}
else
{
List<AnimatedBool> animations = new List<AnimatedBool>();
foreach (AnimatedBool animatedBool in animatedBoolList)
{
animations.Add(new AnimatedBool(animatedBool.time, animatedBool.value));
}
flexibleBool = new FlexibleBool(animations);
}
return flexibleBool;
}
}
}
}

View File

@@ -1,23 +1,21 @@
using System;
using System.Collections;
using System.Collections.Generic;
using Unity.Burst;
using Unity.Collections;
using Unity.Jobs;
using UnityEngine;
using UnityEngine.Serialization;
using Ichni.RhythmGame.Beatmap;
namespace Ichni
namespace Ichni.RhythmGame
{
[System.Serializable]
public class AnimatedFloat : IComparable<AnimatedFloat>
{
public float startValue, endValue; //起止值
public float differenceValue; //差值
public float startTime, endTime; //起止时间
public float totalTime; //总时间
public AnimationCurveType animationCurveType; //动画曲线类型
public float differenceValue => endValue - startValue; //差值
public float totalTime => endTime - startTime; //总时间
public AnimatedFloat(float startTime, float endTime, float startValue, float endValue,
AnimationCurveType animationCurveType)
@@ -26,8 +24,6 @@ namespace Ichni
this.endValue = endValue;
this.startTime = startTime;
this.endTime = endTime;
totalTime = endTime - startTime;
differenceValue = endValue - startValue;
this.animationCurveType = animationCurveType;
}
@@ -152,5 +148,66 @@ namespace Ichni
return null;
}
/// <summary>
/// 转换为Beatmap存档类型
/// </summary>
public FlexibleFloat_BM ConvertToBM()
{
FlexibleFloat_BM flexibleFloat_BM = new FlexibleFloat_BM();
foreach (AnimatedFloat animatedFloat in animations)
{
flexibleFloat_BM.animatedFloatList.Add(new AnimatedFloat(animatedFloat.startTime, animatedFloat.endTime,
animatedFloat.startValue, animatedFloat.endValue, animatedFloat.animationCurveType));
}
return flexibleFloat_BM;
}
}
namespace Beatmap
{
[System.Serializable]
public class FlexibleFloat_BM
{
public List<AnimatedFloat> animatedFloatList;
public FlexibleFloat_BM()
{
this.animatedFloatList = new List<AnimatedFloat>();
}
public FlexibleFloat_BM(List<AnimatedFloat> animatedFloatList)
{
this.animatedFloatList = animatedFloatList;
}
public FlexibleFloat ConvertToGameType()
{
FlexibleFloat flexibleFloat;
if (animatedFloatList.Count == 0)
{
flexibleFloat = new FlexibleFloat();
}
else
{
List<AnimatedFloat> animatedFloatList = new List<AnimatedFloat>();
foreach (AnimatedFloat animatedFloat in this.animatedFloatList)
{
animatedFloatList.Add(new AnimatedFloat(
animatedFloat.startTime, animatedFloat.endTime,
animatedFloat.startValue, animatedFloat.endValue,
animatedFloat.animationCurveType));
}
flexibleFloat = new FlexibleFloat(animatedFloatList);
}
return flexibleFloat;
}
}
}
}

View File

@@ -1,8 +1,10 @@
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using Ichni.RhythmGame.Beatmap;
using UnityEngine;
namespace Ichni
namespace Ichni.RhythmGame
{
[System.Serializable]
public class AnimatedInt
@@ -14,7 +16,7 @@ namespace Ichni
{
}
public AnimatedInt(int value, float time)
public AnimatedInt(float time, int value)
{
this.value = value;
this.time = time;
@@ -77,5 +79,63 @@ namespace Ichni
return new AnimatedInt(0, 0);
}
/// <summary>
/// 转换为Beatmap存档类型
/// </summary>
/// <returns></returns>
public FlexibleInt_BM ConvertToBM()
{
FlexibleInt_BM flexibleInt_BM = new FlexibleInt_BM();
foreach (AnimatedInt animatedInt in animations)
{
flexibleInt_BM.animatedIntList.Add(new AnimatedInt(animatedInt.time, animatedInt.value));
}
return flexibleInt_BM;
}
}
namespace Beatmap
{
[System.Serializable]
public class FlexibleInt_BM
{
public List<AnimatedInt> animatedIntList;
public FlexibleInt_BM()
{
this.animatedIntList = new List<AnimatedInt>();
}
public FlexibleInt_BM(List<AnimatedInt> animatedIntList)
{
this.animatedIntList = animatedIntList;
}
public FlexibleInt ConvertToGameType()
{
FlexibleInt flexibleInt;
if (animatedIntList.Count == 0)
{
flexibleInt = new FlexibleInt();
}
else
{
List<AnimatedInt> animations = new List<AnimatedInt>();
foreach (AnimatedInt animatedInt in animatedIntList)
{
animations.Add(new AnimatedInt(animatedInt.time, animatedInt.value));
}
flexibleInt = new FlexibleInt(animations);
}
return flexibleInt;
}
}
}
}

View File

@@ -6,20 +6,69 @@ using UnityEngine;
namespace Ichni.RhythmGame
{
public class EnvironmentObject : SubstantialObject
public partial class EnvironmentObject : SubstantialObject
{
public bool isStatic;
public static SubstantialObject GenerateElement(string elementName, Guid id, List<string> tags,
string themeBundleName, string objectName, BaseElement parent,
Vector3 position, Vector3 eulerAngles, Vector3 scale,
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 themeBundleObject =
ThemeBundleManager.instance.GetObject<EnvironmentObject>(themeBundleName, objectName);
EnvironmentObject environmentObject =
Instantiate(themeBundleObject, parent.transform).GetComponent<EnvironmentObject>();
environmentObject.Initialize(elementName, id, tags);
environmentObject.isStatic = isStatic;
return environmentObject;
}
}
public partial class EnvironmentObject
{
public override void SaveBM()
{
matchedBM = new Beatmap.EnvironmentObject_BM(elementName, elementGuid, tags, parentElement.matchedBM,
themeBundleName, objectName, isStatic);
}
}
namespace Beatmap
{
public class EnvironmentObject_BM : BaseElement_BM
{
public string themeBundleName;
public string objectName;
public bool isStatic;
public EnvironmentObject_BM()
{
}
public EnvironmentObject_BM(string elementName, Guid elementGuid, List<string> tags,
BaseElement_BM attachedElement, string themeBundleName, string objectName, bool isStatic)
: base(elementName, elementGuid, tags, attachedElement)
{
this.themeBundleName = themeBundleName;
this.objectName = objectName;
this.isStatic = isStatic;
}
public override void ExecuteBM()
{
matchedElement = EnvironmentObject.GenerateElement(elementName, elementGuid, tags,
themeBundleName, objectName, GetElement(attachedElementGuid),
Vector3.zero, Vector3.zero, Vector3.one, isStatic, false);
}
public override BaseElement DuplicateBM(BaseElement parent)
{
return EnvironmentObject.GenerateElement(elementName, elementGuid, tags,
themeBundleName, objectName, parent,
Vector3.zero, Vector3.zero, Vector3.one, isStatic, false);
}
}
}
}

View File

@@ -15,25 +15,27 @@ namespace Ichni.RhythmGame
public Transform rotationPoint;
public Transform positionPoint;
public Transform cameraTransform;
public CameraViewType cameraViewType;
public float perspectiveAngle;
public float orthographicSize;
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 gameCamera =
Instantiate(EditorManager.instance.basePrefabs.gameCamera).GetComponent<GameCamera>();
gameCamera.Initialize(elementName, id, tags);
gameCamera.parentElement = parentElement;
gameCamera.cameraViewType = cameraViewType;
gameCamera.camera.orthographic = cameraViewType == CameraViewType.Orthographic;
gameCamera.perspectiveAngle = perspectiveAngle;
gameCamera.orthographicSize = orthographicSize;
gameCamera.transformSubmodule = new TransformSubmodule(gameCamera, initialPosition, initialEulerAngles, Vector3.one);
gameCamera.transformSubmodule =
new TransformSubmodule(gameCamera, initialPosition, initialEulerAngles, Vector3.one);
gameCamera.cameraTransform = gameCamera.transform;
gameCamera.SetParent(parentElement);
@@ -41,7 +43,7 @@ namespace Ichni.RhythmGame
return gameCamera;
}
}
public partial class GameCamera
{
public enum CameraViewType
@@ -51,7 +53,7 @@ namespace Ichni.RhythmGame
Orthographic = 1
}
}
public partial class GameCamera
{
public override void SetTransformObserver()
@@ -69,11 +71,12 @@ namespace Ichni.RhythmGame
{
offset += eulerOffset;
}
transformSubmodule.currentEulerAngles = transformSubmodule.originalEulerAngles + offset;
rotationPoint.eulerAngles = transformSubmodule.currentEulerAngles;
transformSubmodule.eulerAnglesDirtyMark = false;
}
if (transformSubmodule.positionDirtyMark)
{
Vector3 offset = Vector3.zero;
@@ -81,6 +84,7 @@ namespace Ichni.RhythmGame
{
offset += posOffset;
}
transformSubmodule.currentPosition = transformSubmodule.originalPosition + offset;
positionPoint.localPosition = transformSubmodule.currentPosition;
transformSubmodule.positionDirtyMark = false;
@@ -88,4 +92,56 @@ namespace Ichni.RhythmGame
}).AddTo(gameObject);
}
}
public partial class GameCamera
{
public override void SaveBM()
{
matchedBM = new Beatmap.GameCamera_BM(elementName, elementGuid, tags, parentElement.matchedBM,
cameraViewType, perspectiveAngle, orthographicSize, transformSubmodule.currentPosition,
transformSubmodule.currentEulerAngles);
}
}
namespace Beatmap
{
public class GameCamera_BM : BaseElement_BM
{
public GameCamera.CameraViewType cameraViewType;
public float perspectiveAngle;
public float orthographicSize;
public Vector3 initialPosition;
public Vector3 initialEulerAngles;
public GameCamera_BM()
{
}
public GameCamera_BM(string elementName, Guid elementGuid, List<string> tags,
BaseElement_BM attachedElement,
GameCamera.CameraViewType cameraViewType, float perspectiveAngle, float orthographicSize,
Vector3 initialPosition, Vector3 initialEulerAngles)
: base(elementName, elementGuid, tags, attachedElement)
{
this.cameraViewType = cameraViewType;
this.perspectiveAngle = perspectiveAngle;
this.orthographicSize = orthographicSize;
this.initialPosition = initialPosition;
this.initialEulerAngles = initialEulerAngles;
}
public override void ExecuteBM()
{
GameCamera.GenerateElement(elementName, elementGuid, tags, GetElement(attachedElementGuid),
cameraViewType, perspectiveAngle, orthographicSize, initialPosition, initialEulerAngles);
}
public override BaseElement DuplicateBM(BaseElement parent)
{
return GameCamera.GenerateElement(elementName, elementGuid, tags, parent, cameraViewType,
perspectiveAngle, orthographicSize, initialPosition, initialEulerAngles);
}
}
}
}

View File

@@ -4,7 +4,7 @@ using UnityEngine;
namespace Ichni.RhythmGame
{
public class NoteVisualBase : SubstantialObject
public abstract class NoteVisualBase : SubstantialObject
{
public NoteBase note;

View File

@@ -6,7 +6,7 @@ using UnityEngine;
namespace Ichni.RhythmGame
{
public class SubstantialObject : BaseElement
public abstract class SubstantialObject : BaseElement
{
public string themeBundleName, objectName;

View File

@@ -12,29 +12,31 @@ namespace Ichni.RhythmGame
public partial class PathNode : BaseElement
{
public ColorSubmodule colorSubmodule;
public Track track;
public int index => track.trackPathSubmodule.pathNodeList.IndexOf(this);
public SplinePoint node;
public static PathNode GenerateElement(string elementName, Guid id, List<string> tags,
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 pathNode = Instantiate(EditorManager.instance.basePrefabs.pathNode, track.transform)
.GetComponent<PathNode>();
pathNode.Initialize(elementName, id, tags);
pathNode.track = track;
//pathNode.index = index;
pathNode.transformSubmodule = new TransformSubmodule(pathNode, nodePosition, Quaternion.LookRotation(nodeNormal, Vector3.up).eulerAngles, Vector3.one * nodeSize);
pathNode.transformSubmodule = new TransformSubmodule(pathNode, nodePosition,
Quaternion.LookRotation(nodeNormal, Vector3.up).eulerAngles, Vector3.one * nodeSize);
pathNode.timeDurationSubmodule = new TimeDurationSubmodule(pathNode);
pathNode.colorSubmodule = new ColorSubmodule(pathNode, nodeColor);
track.trackPathSubmodule.pathNodeList.Add(pathNode);
pathNode.SetParent(track);
return pathNode;
}
@@ -47,7 +49,7 @@ namespace Ichni.RhythmGame
}
}
}
public partial class PathNode
{
public override void Refresh()
@@ -61,4 +63,53 @@ namespace Ichni.RhythmGame
track.trackPathSubmodule.SetPathNode(this);
}
}
public partial class PathNode
{
public override void SaveBM()
{
matchedBM = new Beatmap.PathNode_BM(elementName, elementGuid, tags, parentElement.matchedBM, index,
node.position, node.normal, node.size, node.color);
}
}
namespace Beatmap
{
public class PathNode_BM : BaseElement_BM
{
public int index;
public Vector3 position;
public Vector3 normal;
public float size;
public Color color;
public PathNode_BM()
{
}
public PathNode_BM(string elementName, Guid elementGuid, List<string> tags, BaseElement_BM attachedElement,
int index, Vector3 position, Vector3 normal, float size, Color color)
: base(elementName, elementGuid, tags, attachedElement)
{
this.index = index;
this.position = position;
this.normal = normal;
this.size = size;
this.color = color;
}
public override void ExecuteBM()
{
matchedElement = PathNode.GenerateElement(elementName, elementGuid, tags,
GetElement(attachedElementGuid) as Track, position, normal, size, color);
}
public override BaseElement DuplicateBM(BaseElement parent)
{
return PathNode.GenerateElement(elementName, elementGuid, tags, parent as Track,
position, normal, size, color);
}
}
}
}

View File

@@ -7,7 +7,7 @@ using UnityEngine;
namespace Ichni.RhythmGame
{
public class CrossTrackPoint : BaseElement
public partial class CrossTrackPoint : BaseElement
{
public ElementFolder trackListFolder;
public Track nowAttachedTrack;
@@ -56,4 +56,45 @@ namespace Ichni.RhythmGame
trackPositioner.SetPercent(trackPercent.value);
}
}
public partial class CrossTrackPoint
{
public override void SaveBM()
{
matchedBM = new Beatmap.CrossTrackPoint_BM(elementName, elementGuid, tags, parentElement.matchedBM, trackSwitch, trackPercent);
}
}
namespace Beatmap
{
public class CrossTrackPoint_BM : BaseElement_BM
{
public FlexibleInt trackSwitch;
public FlexibleFloat trackPercent;
public CrossTrackPoint_BM()
{
}
public CrossTrackPoint_BM(string elementName, Guid elementGuid, List<string> tags,
BaseElement_BM attachedElement, FlexibleInt trackSwitch, FlexibleFloat trackPercent)
: base(elementName, elementGuid, tags, attachedElement)
{
this.trackSwitch = trackSwitch;
this.trackPercent = trackPercent;
}
public override void ExecuteBM()
{
CrossTrackPoint.GenerateElement(elementName, elementGuid, tags, GetElement(attachedElementGuid) as ElementFolder,
trackSwitch, trackPercent);
}
public override BaseElement DuplicateBM(BaseElement parent)
{
return CrossTrackPoint.GenerateElement(elementName, elementGuid, tags, parent as ElementFolder,
trackSwitch, trackPercent);
}
}
}
}

View File

@@ -7,16 +7,17 @@ using UnityEngine;
namespace Ichni.RhythmGame
{
public class TrackHeadPoint : BaseElement
public partial class TrackHeadPoint : BaseElement
{
public Track track;
public TrackTimeSubmoduleMovable trackTimeSubmoduleMovable;
public SplinePositioner trackPositioner;
public static TrackHeadPoint GenerateElement(string elementName, Guid id, List<string> tags, Track track)
{
TrackHeadPoint head = Instantiate(EditorManager.instance.basePrefabs.emptyObject, track.transform).AddComponent<TrackHeadPoint>();
TrackHeadPoint head = Instantiate(EditorManager.instance.basePrefabs.emptyObject, track.transform)
.AddComponent<TrackHeadPoint>();
head.Initialize(elementName, id, tags);
head.track = track;
head.trackPositioner = head.gameObject.AddComponent<SplinePositioner>();
@@ -34,4 +35,40 @@ namespace Ichni.RhythmGame
}
}
}
public partial class TrackHeadPoint
{
public override void SaveBM()
{
matchedBM = new Beatmap.TrackHeadPoint_BM(elementName, elementGuid, tags, parentElement.matchedBM);
}
}
namespace Beatmap
{
public class TrackHeadPoint_BM : BaseElement_BM
{
public TrackHeadPoint_BM()
{
}
public TrackHeadPoint_BM(string elementName, Guid elementGuid, List<string> tags,
BaseElement_BM attachedElement)
: base(elementName, elementGuid, tags, attachedElement)
{
}
public override void ExecuteBM()
{
TrackHeadPoint.GenerateElement(elementName, elementGuid, tags,
GetElement(attachedElementGuid) as Track);
}
public override BaseElement DuplicateBM(BaseElement parent)
{
return TrackHeadPoint.GenerateElement(elementName, elementGuid, tags, parent as Track);
}
}
}
}

View File

@@ -12,7 +12,7 @@ namespace Ichni.RhythmGame
/// <summary>
/// 在轨道上根据百分比进行运动的点
/// </summary>
public class TrackPercentPoint : BaseElement
public partial class TrackPercentPoint : BaseElement
{
public Track track;
public SplinePositioner trackPositioner;
@@ -56,4 +56,41 @@ namespace Ichni.RhythmGame
}
}
}
public partial class TrackPercentPoint
{
public override void SaveBM()
{
matchedBM = new Beatmap.TrackPercentPoint_BM(elementName, elementGuid, tags, parentElement.matchedBM, trackPercent.ConvertToBM());
}
}
namespace Beatmap
{
public class TrackPercentPoint_BM : BaseElement_BM
{
public FlexibleFloat_BM trackPercent;
public TrackPercentPoint_BM()
{
}
public TrackPercentPoint_BM(string elementName, Guid elementGuid, List<string> tags,
BaseElement_BM attachedElement, FlexibleFloat_BM trackPercent)
: base(elementName, elementGuid, tags, attachedElement)
{
this.trackPercent = trackPercent;
}
public override void ExecuteBM()
{
TrackPercentPoint.GenerateElement(elementName, elementGuid, tags, GetElement(attachedElementGuid) as Track, trackPercent.ConvertToGameType());
}
public override BaseElement DuplicateBM(BaseElement parent)
{
return TrackPercentPoint.GenerateElement(elementName, elementGuid, tags, parent as Track, trackPercent.ConvertToGameType());
}
}
}
}

View File

@@ -5,13 +5,13 @@ using UnityEngine;
namespace Ichni.RhythmGame
{
public class Trail : BaseElement
public partial 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)
{
@@ -19,14 +19,57 @@ namespace Ichni.RhythmGame
trail.trailRenderer = trail.GetComponent<TrailRenderer>();
trail.Initialize(name, id, tags);
trail.renderMaterial = material == null ? EditorManager.instance.basePrefabs.defaultTrailMaterial : material;
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;
}
}
public partial class Trail
{
public override void SaveBM()
{
matchedBM = new Beatmap.Trail_BM(elementName, elementGuid, tags, parentElement.matchedBM, visibleTimeLength,
renderMaterial);
}
}
namespace Beatmap
{
public class Trail_BM : BaseElement_BM
{
public float visibleTimeLength;
public Material renderMaterial;
public Trail_BM()
{
}
public Trail_BM(string elementName, Guid elementGuid, List<string> tags, BaseElement_BM attachedElement,
float visibleTimeLength, Material renderMaterial)
: base(elementName, elementGuid, tags, attachedElement)
{
this.visibleTimeLength = visibleTimeLength;
this.renderMaterial = renderMaterial;
}
public override void ExecuteBM()
{
matchedElement = Trail.GenerateElement(elementName, elementGuid, tags, GetElement(attachedElementGuid),
visibleTimeLength, renderMaterial);
}
public override BaseElement DuplicateBM(BaseElement parent)
{
return Trail.GenerateElement(elementName, elementGuid, tags, parent, visibleTimeLength, renderMaterial);
}
}
}
}

View File

@@ -1,12 +1,13 @@
using System;
using System.Collections;
using System.Collections.Generic;
using Ichni.RhythmGame.Beatmap;
using Lean.Pool;
using UnityEngine;
namespace Ichni.RhythmGame.ThemeBundles.Basic
{
public class BasicNoteVisual : NoteVisualBase
public partial class BasicNoteVisual : NoteVisualBase
{
public new static BasicNoteVisual GenerateElement(string elementName, Guid id, List<string> tags,
string themeBundleName, string objectName,
@@ -33,4 +34,49 @@ namespace Ichni.RhythmGame.ThemeBundles.Basic
return noteVisual;
}
}
public partial class BasicNoteVisual
{
public override void SaveBM()
{
}
}
namespace Beatmap
{
public class BasicNoteVisual_BM : BaseElement_BM
{
public BasicNoteVisual_BM()
{
}
public BasicNoteVisual_BM(string elementName, Guid id, List<string> tags, BaseElement_BM parent,
string themeBundleName, string objectName, Vector3 position, Vector3 eulerAngles, Vector3 scale) :
base(elementName, id, tags, parent)
{
this.elementName = elementName;
this.elementGuid = id;
this.tags = tags;
// this.themeBundleName = themeBundleName;
// this.objectName = objectName;
// this.position = position;
// this.eulerAngles = eulerAngles;
// this.scale = scale;
// this.parent = parent;
}
public override void ExecuteBM()
{
//TODO: 生成NoteVisual
}
public override BaseElement DuplicateBM(BaseElement parent)
{
//TODO: 生成NoteVisual
return null;
}
}
}
}