基础内容-3

Swirl Scale动画
四种Note代码建立
Note Judge Submodule构思中
This commit is contained in:
SoulliesOfficial
2025-01-27 22:11:24 -05:00
parent 8d887d5a7c
commit 70d06c6334
43 changed files with 2084 additions and 94 deletions

View File

@@ -19,6 +19,33 @@ namespace Ichni.RhythmGame
SetParent(this.targetObject);
}
public abstract void UpdateAnimation(float songTime);
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(startTimes.Min(), endTimes.Max());
}
protected abstract void UpdateAnimation(float songTime);
protected virtual void Update()
{
if (timeDurationSubmodule.CheckTimeInDuration(EditorManager.instance.songModule.songTime))
{
UpdateAnimation(EditorManager.instance.songModule.songTime);
}
}
}
}

View File

@@ -18,7 +18,7 @@ namespace Ichni.RhythmGame
public static Displacement GenerateElement(string elementName, BaseElement targetObject,
FlexibleFloat positionX, FlexibleFloat positionY, FlexibleFloat positionZ)
{
Displacement displacement = LeanPool.Spawn(new GameObject()).AddComponent<Displacement>();//TODO: 替换 new GameObject();
Displacement displacement = LeanPool.Spawn(EditorManager.instance.basePrefabs.emptyObject).AddComponent<Displacement>();
displacement.NewInitialize(elementName, targetObject);
@@ -35,54 +35,13 @@ namespace Ichni.RhythmGame
{
throw new System.Exception("Target object does not have a TransformSubmodule");
}
displacement.SetTimeDuration();
displacement.SetTimeDuration(positionX, positionY, positionZ);
return displacement;
}
public override void SetTimeDuration()
{
positionX.Sort();
positionY.Sort();
positionZ.Sort();
List<float> startTimes = new List<float>();
List<float> endTimes = new List<float>();
if (positionX.animations.Count > 0)
{
startTimes.Add(positionX.animations[0].startTime);
endTimes.Add(positionX.animations[^1].endTime);
}
if (positionY.animations.Count > 0)
{
startTimes.Add(positionY.animations[0].startTime);
endTimes.Add(positionY.animations[^1].endTime);
}
if (positionZ.animations.Count > 0)
{
startTimes.Add(positionZ.animations[0].startTime);
endTimes.Add(positionZ.animations[^1].endTime);
}
float startTime = startTimes.Min();
float endTime = endTimes.Max();
timeDurationSubmodule = new TimeDurationSubmodule(startTime, endTime);
}
protected void Update()
{
if (timeDurationSubmodule.CheckTimeInDuration(EditorManager.instance.songModule.songTime))
{
UpdateAnimation(EditorManager.instance.songModule.songTime);
}
}
public override void UpdateAnimation(float songTime)
protected override void UpdateAnimation(float songTime)
{
positionX.UpdateFlexibleFloat(songTime);
positionY.UpdateFlexibleFloat(songTime);

View File

@@ -0,0 +1,55 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
namespace Ichni.RhythmGame
{
public class Scale : AnimationBase
{
public TransformSubmodule targetTransformSubmodule;
public FlexibleFloat scaleX, scaleY, scaleZ;
public static Scale GenerateElement(string elementName, BaseElement targetObject,
FlexibleFloat scaleX, FlexibleFloat scaleY, FlexibleFloat scaleZ)
{
Scale scale = Lean.Pool.LeanPool.Spawn(EditorManager.instance.basePrefabs.emptyObject).AddComponent<Scale>();
scale.NewInitialize(elementName, targetObject);
scale.scaleX = scaleX;
scale.scaleY = scaleY;
scale.scaleZ = scaleZ;
scale.animationReturnType = FlexibleReturnType.Before;
if (targetObject.transformSubmodule != null)
{
scale.targetTransformSubmodule = targetObject.transformSubmodule;
}
else
{
throw new System.Exception("Target object does not have a TransformSubmodule");
}
scale.SetTimeDuration(scaleX, scaleY, scaleZ);
return scale;
}
protected override void UpdateAnimation(float songTime)
{
scaleX.UpdateFlexibleFloat(songTime);
scaleY.UpdateFlexibleFloat(songTime);
scaleZ.UpdateFlexibleFloat(songTime);
if (scaleX.returnType is FlexibleReturnType.MiddleExecuting ||
scaleY.returnType is FlexibleReturnType.MiddleExecuting ||
scaleZ.returnType is FlexibleReturnType.MiddleExecuting)
{
animationReturnType = FlexibleReturnType.MiddleExecuting;
Vector3 currentScale = new Vector3(scaleX.value, scaleY.value, scaleZ.value);
targetTransformSubmodule.scaleOffset.Add(currentScale);
targetTransformSubmodule.scaleDirtyMark = true;
}
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 1119784540bef4e73b37c7cb9f597065
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,56 @@
using System.Collections;
using System.Collections.Generic;
using Lean.Pool;
using UnityEngine;
namespace Ichni.RhythmGame
{
public class Swirl : AnimationBase
{
public TransformSubmodule targetTransformSubmodule;
public FlexibleFloat eulerAngleX, eulerAngleY, eulerAngleZ;
public static Swirl GenerateElement(string elementName, BaseElement targetObject,
FlexibleFloat eulerAngleX, FlexibleFloat eulerAngleY, FlexibleFloat eulerAngleZ)
{
Swirl swirl = LeanPool.Spawn(EditorManager.instance.basePrefabs.emptyObject).AddComponent<Swirl>();
swirl.NewInitialize(elementName, targetObject);
swirl.eulerAngleX = eulerAngleX;
swirl.eulerAngleY = eulerAngleY;
swirl.eulerAngleZ = eulerAngleZ;
swirl.animationReturnType = FlexibleReturnType.Before;
if (targetObject.transformSubmodule != null)
{
swirl.targetTransformSubmodule = targetObject.transformSubmodule;
}
else
{
throw new System.Exception("Target object does not have a TransformSubmodule");
}
swirl.SetTimeDuration(eulerAngleX, eulerAngleY, eulerAngleZ);
return swirl;
}
protected override void UpdateAnimation(float songTime)
{
eulerAngleX.UpdateFlexibleFloat(songTime);
eulerAngleY.UpdateFlexibleFloat(songTime);
eulerAngleZ.UpdateFlexibleFloat(songTime);
if (eulerAngleX.returnType is FlexibleReturnType.MiddleExecuting ||
eulerAngleY.returnType is FlexibleReturnType.MiddleExecuting ||
eulerAngleZ.returnType is FlexibleReturnType.MiddleExecuting)
{
animationReturnType = FlexibleReturnType.MiddleExecuting;
Vector3 currentEulerAngles = new Vector3(eulerAngleX.value, eulerAngleY.value, eulerAngleZ.value);
targetTransformSubmodule.eulerAnglesOffset.Add(currentEulerAngles);
targetTransformSubmodule.eulerAnglesDirtyMark = true;
}
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: e6daf69621681491bb09cc72e2ff4bdb
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -11,6 +11,64 @@ namespace Ichni.RhythmGame
public abstract class EffectBase
{
public abstract void Execute();
public enum EffectState
{
Before = -1,
Middle = 0,
After = 1,
Error = 100
}
/// <summary>
/// 效果的持续时间如果为0则表示瞬间效果
/// </summary>
public float effectTime;
/// <summary>
/// 是否是瞬间效果
/// </summary>
public bool isInstantEffect => effectTime <= 0;
/// <summary>
/// 效果当前的状态
/// </summary>
public EffectState nowEffectState;
protected EffectBase()
{
this.effectTime = 0;
this.nowEffectState = EffectState.Before;
}
protected EffectBase(float effectTime)
{
this.effectTime = effectTime;
this.nowEffectState = EffectState.Before;
}
/// <summary>
/// 在效果的持续时间内,触发这个方法
/// </summary>
public virtual void Execute()
{
}
/// <summary>
/// 如果是非瞬间效果,在效果完成后,触发这个方法;
/// 如果是瞬间效果则此方法即为Execute。原有的Execute方法不被调用。
/// </summary>
public virtual void Adjust()
{
}
/// <summary>
/// 如果时间轴回退到效果的触发时间之前,则触发这个方法
/// </summary>
public virtual void Recover()
{
}
}
}

View File

@@ -8,16 +8,19 @@ namespace Ichni.RhythmGame
{
public class TimeDurationSubmodule: SubmoduleBase
{
public bool isOverridingDuration; //是否手动设置了时间区间,开启时,子物体的时间区间将被忽略
public float startTime, endTime; //起止时间
public TimeDurationSubmodule()
{
isOverridingDuration = false;
startTime = 0;
endTime = 0;
}
public TimeDurationSubmodule(float startTime, float endTime)
{
this.isOverridingDuration = false;
this.startTime = startTime;
this.endTime = endTime;
}

View File

@@ -14,4 +14,7 @@ public class BasePrefabsCollection : SerializedScriptableObject
public GameObject track;
public GameObject pathNode;
public Material defaultTrackMaterial;
[Title("Effect相关")]
public GameObject bloomShake;
}

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 22d9d055a57b4494a85bf79a857d96ed
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,27 @@
using System;
using System.Collections;
using System.Collections.Generic;
using Lean.Pool;
using MoreMountains.Feedbacks;
using MoreMountains.FeedbacksForThirdParty;
using Sirenix.OdinInspector;
using UnityEngine;
namespace Ichni.RhythmGame
{
public class BloomShake : EffectBase
{
public float bloomTime;
public float bloomPeak;
[Button("Test Bloom Shake")]
public override void Adjust()
{
MMF_Player effect = LeanPool.Spawn(EditorManager.instance.basePrefabs.bloomShake).GetComponent<MMF_Player>();
effect.GetFeedbackOfType<MMF_Bloom_URP>().ShakeDuration = bloomTime;
effect.GetFeedbackOfType<MMF_Bloom_URP>().RemapIntensityOne = bloomPeak;
effect.PlayFeedbacks();
LeanPool.Despawn(effect.gameObject, bloomTime);
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: fbe90f2898886421aa1ecfe2a2aaf4f5
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,19 @@
using System.Collections;
using System.Collections.Generic;
using Sirenix.OdinInspector;
using UnityEngine;
namespace Ichni.RhythmGame
{
public class TimeEffectsCollection : SerializedMonoBehaviour
{
public List<TimeEffectUnit> timeEffectUnits;
}
public class TimeEffectUnit
{
public string unitName;
public float unitTime;
public EffectSubmodule effectSubmodule;
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: af21e649d109b416aa81541349c26926
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,18 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Flick : MonoBehaviour
{
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: db9afa4209e714d689fc9b15d81c6f50
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,18 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Hold : MonoBehaviour
{
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 3d86cc42eec2b42e3aa9571c916401e6
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: acc133c3d8ab345e1ac8d703e4ce2f18
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,18 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class FullScreenBalancedJudgeSubmodule : MonoBehaviour
{
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 0afb3700dadc6439aa12380eba145393
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,18 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class FullScreenNearTimeJudgeSubmodule : MonoBehaviour
{
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 8bf5b334d67634f4688a5481f1ccc42f
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,16 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
namespace Ichni.RhythmGame
{
public class NoteJudgeSubmodule : SubmoduleBase
{
}
public class NoteJudgeUnit
{
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 68da77ce27dec41478846a37c8a491cd
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,18 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class TouchAreaJudgeSubmodule : MonoBehaviour
{
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: e217631f39751452bad007e0cb075e61
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,18 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class TriggerConnectJudgeSubmodule : MonoBehaviour
{
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 16de260925efb4951afd63b8dc4a5d6c
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -20,11 +20,22 @@ namespace Ichni.RhythmGame
// [Title("NoteVisual")]
// public GeneralNoteVisual noteVisual;
//
// [Title("NoteEffect")]
// public List<NoteEffectGenerate> noteEffectGenerateList;
// public List<NoteEffectPerfect> noteEffectPerfectList;
// public List<NoteEffectGood> noteEffectGoodList;
// public List<NoteEffectMiss> noteEffectMissList;
[Title("NoteEffect")]
[Tooltip("生成Note时的特效")]
public EffectSubmodule generateEffects;
[Tooltip("Note被判定时的特效不包括Miss")]
public EffectSubmodule generalJudgeEffects;
[Tooltip("Note被Perfect判定时的特效")]
public EffectSubmodule perfectJudgeEffects;
[Tooltip("Note被Good判定时的特效")]
public EffectSubmodule goodJudgeEffects;
[Tooltip("Note被Bad判定时的特效")]
public EffectSubmodule badJudgeEffects;
[Tooltip("Note未被判定时的特效即Miss")]
public EffectSubmodule missJudgeEffects;
[Title("Judge Info")]
public NoteJudgeSubmodule noteJudgeSubmodule;
[Title("In-Game Info")]
public Vector2 noteScreenPosition;

View File

@@ -0,0 +1,18 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Stay : MonoBehaviour
{
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 1ec53002feb264ae7b2bb0386ac37ad2
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,18 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Tap : MonoBehaviour
{
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 6b1bd7cbcd49b4f0b805e902cd7c3025
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -8,7 +8,6 @@ namespace Ichni.RhythmGame
{
public class TrackRendererSubmodule : TrackSubmodule
{
public Track track;
public MeshGenerator meshGenerator;
public MeshRenderer meshRenderer;
public Material renderMaterial;
@@ -30,7 +29,6 @@ namespace Ichni.RhythmGame
this.splineRenderer.clipFrom = 0;
this.splineRenderer.clipTo = 1;
this.meshRenderer.material = renderMaterial;
Debug.Log(splineRenderer.clipFrom + " " + splineRenderer.clipTo);
this.splineRenderer.color = Color.white;
}