Hold Tilt

This commit is contained in:
SoulliesOfficial
2025-06-01 07:41:55 -04:00
parent df7abdb320
commit 61e6ac3a32
13 changed files with 16677 additions and 16674 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -10,6 +10,7 @@ GameObject:
m_Component:
- component: {fileID: 6794014747502131782}
- component: {fileID: 2505559936379693214}
- component: {fileID: -1980890364959568758}
m_Layer: 0
m_Name: CameraTiltEffect
m_TagString: Untagged
@@ -389,3 +390,15 @@ MonoBehaviour:
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 4
--- !u!114 &-1980890364959568758
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 5030288017655597913}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: d6ba0e915cddec743a29f85a93f12594, type: 3}
m_Name:
m_EditorClassIdentifier:

View File

@@ -1,209 +0,0 @@
using System.Collections;
using System.Collections.Generic;
using System;
using DG.Tweening.Core.Easing;
using UnityEngine;
using Ichni.Editor;
using Ichni.RhythmGame.Beatmap;
namespace Ichni.RhythmGame
{
public class CameraAngleOffset : AnimationBase
{
public List<Hold> holds => Hold.holdingHoldList;
public TransformSubmodule camtransformSubmodule;
public FlexibleBool enabling;
public float MaxxOffset;
public float MaxyOffset;
public float MaxzOffset;
public float TimeToMax;
public AnimationCurveType animationCurveType;
public float xCurrentValue;
public float yCurrentValue;
public float zCurrentValue;
bool xOffseting;
bool yOffseting;
bool zOffseting;
float xOffsetStartTime = 0f;
float yOffsetStartTime = 0f;
float zOffsetStartTime = 0f;
protected override void UpdateAnimation(float songTime)
{
if (enabling == null)
return;
enabling.UpdateFlexibleBool(songTime);
if (enabling.value && Hold.holdingHoldList.Count != 0)
{
animationReturnType = FlexibleReturnType.MiddleExecuting;
float xValue = 0;
float yValue = 0;
float zValue = 0;
if (Hold.holdingHoldList != null)
{
foreach (Hold i in Hold.holdingHoldList)
{
xValue += i.noteScreenPosition.x - (Screen.width / 2);
yValue += i.noteScreenPosition.y - (Screen.width / 2);
}
}
zValue = xValue;
JudgeState(ref xCurrentValue, xValue, ref xOffseting, ref xOffsetStartTime, songTime);
JudgeState(ref yCurrentValue, yValue, ref yOffseting, ref yOffsetStartTime, songTime);
JudgeState(ref zCurrentValue, zValue, ref zOffseting, ref zOffsetStartTime, songTime);
// 平滑过渡到目标值
if (xOffseting)
{
xCurrentValue = UpdateOffset(xOffsetStartTime, ref xOffseting, songTime, MaxxOffset);
}
if (yOffseting)
{
yCurrentValue = UpdateOffset(yOffsetStartTime, ref yOffseting, songTime, MaxyOffset);
}
if (zOffseting)
{
zCurrentValue = UpdateOffset(zOffsetStartTime, ref zOffseting, songTime, MaxzOffset);
}
if (camtransformSubmodule != null && camtransformSubmodule.eulerAnglesOffset != null)
{
Vector3 currentEulerAngles = new(xCurrentValue, yCurrentValue, zCurrentValue);
camtransformSubmodule.eulerAnglesOffset.Add(currentEulerAngles);
camtransformSubmodule.eulerAnglesDirtyMark = true;
}
}
else
{
animationReturnType = FlexibleReturnType.MiddleInterval;
}
}
public override void SetDefaultSubmodules()
{
timeDurationSubmodule = new TimeDurationSubmodule(this);
}
private void JudgeState(ref float CurrentValue, float Value, ref bool Offseting, ref float OffsetStartTime, float songtime)
{
if (Mathf.Abs(Value - CurrentValue) >= 1)
{
Offseting = true;
OffsetStartTime = songtime;
}
else
{
CurrentValue = Value;
}
}
private float UpdateOffset(float OffsetStartTime, ref bool Offseting, float songTime, float MaxOffset)
{
if (OffsetStartTime + TimeToMax < songTime)
{
Offseting = false;
return MaxOffset;
}
float denominator = songTime + TimeToMax - OffsetStartTime;
if (Mathf.Approximately(denominator, 0f))
return 0f;
float Value = AnimationCurveEvaluator.Evaluate(animationCurveType, (songTime - OffsetStartTime) / denominator);
return Value * MaxOffset;
}
public static CameraAngleOffset GenerateElement(
string elementName, Guid id, List<string> tags, bool isFirstGenerated, GameElement animatedObject,
FlexibleBool enabling, float maxX, float maxY, float maxZ, float timeToMax, AnimationCurveType curveType)
{
CameraAngleOffset offset = Instantiate(EditorManager.instance.basePrefabs.emptyObject)
.AddComponent<CameraAngleOffset>();
offset.Initialize(elementName, id, tags, isFirstGenerated, animatedObject);
offset.animatedObject = animatedObject;
var submoduleHolder = animatedObject as IHaveTransformSubmodule;
if (submoduleHolder != null)
offset.camtransformSubmodule = EditorManager.instance.cameraManager.gameCamera.transformSubmodule;
offset.enabling = enabling;
offset.MaxxOffset = maxX;
offset.MaxyOffset = maxY;
offset.MaxzOffset = maxZ;
offset.TimeToMax = timeToMax;
offset.animationCurveType = curveType;
offset.animationReturnType = FlexibleReturnType.Before;
return offset;
}
public override void SaveBM()
{
matchedBM = new CameraAngleOffset_BM(
elementName, elementGuid, tags, parentElement.matchedBM as GameElement_BM,
enabling.ConvertToBM(), MaxxOffset, MaxyOffset, MaxzOffset, TimeToMax, animationCurveType
);
}
public override void SetUpInspector()
{
base.SetUpInspector();
IHaveInspection inspector = EditorManager.instance.uiManager.inspector;
var container = inspector.GenerateContainer("CameraAngleOffset");
var subcontainer = container.GenerateSubcontainer(5);
inspector.GenerateButton(this, subcontainer, "Enabling", () =>
{
inspector.GenerateCompositeParameterWindow(this, "Enabling", nameof(enabling)).SetAsFlexibleBool();
});
inspector.GenerateInputField(this, subcontainer, "Max X Offset", nameof(MaxxOffset));
inspector.GenerateInputField(this, subcontainer, "Max Y Offset", nameof(MaxyOffset));
inspector.GenerateInputField(this, subcontainer, "Max Z Offset", nameof(MaxzOffset));
inspector.GenerateInputField(this, subcontainer, "Time To Max", nameof(TimeToMax));
inspector.GenerateDropdown(this, subcontainer, "Offset Ease", typeof(AnimationCurveType), nameof(animationCurveType));
}
}
// BM类
namespace Beatmap
{
public class CameraAngleOffset_BM : AnimationBase_BM
{
public FlexibleBool_BM enabling;
public float maxX, maxY, maxZ, timeToMax;
public AnimationCurveType animationCurveType;
public CameraAngleOffset_BM() { }
public CameraAngleOffset_BM(string elementName, Guid elementGuid, List<string> tags, GameElement_BM attachedElement,
FlexibleBool_BM enabling, float maxX, float maxY, float maxZ, float timeToMax, AnimationCurveType curveType)
: base(elementName, elementGuid, tags, attachedElement)
{
this.enabling = enabling;
this.maxX = maxX;
this.maxY = maxY;
this.maxZ = maxZ;
this.timeToMax = timeToMax;
this.animationCurveType = curveType;
}
public override void ExecuteBM()
{
matchedElement = CameraAngleOffset.GenerateElement(
elementName, elementGuid, tags, false, GetElement(attachedElementGuid),
enabling.ConvertToGameType(), maxX, maxY, maxZ, timeToMax, animationCurveType
);
}
public override GameElement DuplicateBM(GameElement parent)
{
return CameraAngleOffset.GenerateElement(
elementName, Guid.NewGuid(), tags, false, parent,
enabling.ConvertToGameType(), maxX, maxY, maxZ, timeToMax, animationCurveType
);
}
}
}
}

View File

@@ -30,6 +30,7 @@ namespace Ichni.RhythmGame
{
effectCollection.Add("Generate", new List<EffectBase>());
effectCollection.Add("GeneralJudge", new List<EffectBase>());
effectCollection.Add("StartHold", new List<EffectBase>());
effectCollection.Add("Holding", new List<EffectBase>()); //仅用于Hold
effectCollection.Add("Perfect", new List<EffectBase>());
effectCollection.Add("Good", new List<EffectBase>());
@@ -322,6 +323,15 @@ namespace Ichni.RhythmGame
}
/// <summary>
/// 如果效果被打断主要对于Holding Effect则触发这个方法
/// </summary>
public virtual void Disrupt()
{
}
/// <summary>
/// 转换为存档类
/// </summary>

View File

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

View File

@@ -0,0 +1,56 @@
using System.Collections;
using System.Collections.Generic;
using Lean.Pool;
using UnityEngine;
using UnityEngine.Events;
namespace Ichni
{
public class PooledObject : MonoBehaviour, IPoolable
{
public UnityAction onSpawn;
public UnityAction onDespawn;
public void OnSpawn()
{
onSpawn?.Invoke();
}
public void OnDespawn()
{
onDespawn?.Invoke();
}
public void SetOnSpawn(UnityAction action, bool isOverride = false, bool isAdditive = false)
{
if (isOverride)
{
onSpawn = action;
}
else if (isAdditive)
{
onSpawn += action;
}
else
{
onSpawn ??= action;
}
}
public void SetOnDespawn(UnityAction action, bool isOverride = false, bool isAdditive = false)
{
if (isOverride)
{
onDespawn = action;
}
else if (isAdditive)
{
onDespawn += action;
}
else
{
onDespawn ??= action;
}
}
}
}

View File

@@ -1,5 +1,5 @@
fileFormatVersion: 2
guid: 1ec2771618afafe489a6cd3de5b20bc1
guid: d6ba0e915cddec743a29f85a93f12594
MonoImporter:
externalObjects: {}
serializedVersion: 2

View File

@@ -79,23 +79,6 @@ namespace Ichni.RhythmGame
var extensionButton = inspector.GenerateButton(this, generateAnimation, "Extension",
() => GameCameraExtension.GenerateElement("New Extension", Guid.NewGuid(),
new List<string>(), true, this, 1000f));
if (childElementList.Where(i => i is CameraAngleOffset).Count() == 0)
{
var CAOButton = inspector.GenerateButton(this, generateAnimation, "CameraAngleOffset",
() => CameraAngleOffset.GenerateElement(
"New CameraAngleOffset",
Guid.NewGuid(),
new List<string>(),
true,
this,
new FlexibleBool(),
0f,
0f,
0f,
0f,
AnimationCurveType.Linear
));
}
}
}

View File

@@ -1,5 +1,6 @@
using System.Collections;
using System.Collections.Generic;
using DG.Tweening;
using Ichni.Editor;
using Ichni.RhythmGame.Beatmap;
using Lean.Pool;
@@ -26,6 +27,8 @@ namespace Ichni.RhythmGame
public float zPeak;
public AnimationCurve tiltCurveZ;
public List<MMF_Player> avtiveEffectExecutors;
public CameraTiltEffect(bool haveXTilt, float xDuration, float xPeak, AnimationCurve tiltCurveX,
bool haveYTilt, float yDuration, float yPeak, AnimationCurve tiltCurveY,
bool haveZTilt, float zDuration, float zPeak, AnimationCurve tiltCurveZ)
@@ -46,6 +49,8 @@ namespace Ichni.RhythmGame
this.zDuration = zDuration;
this.zPeak = zPeak;
this.tiltCurveZ = tiltCurveZ;
avtiveEffectExecutors = new List<MMF_Player>();
}
public override void Adjust()
@@ -66,6 +71,8 @@ namespace Ichni.RhythmGame
effect.GetFeedbackOfType<MMF_Rotation>().AnimateZ = false;
effect.GetFeedbackOfType<MMF_Rotation>().RemapCurveOne = xPeak;
effect.GetFeedbackOfType<MMF_Rotation>().AnimateRotationX = tiltCurveX;
effect.GetComponent<PooledObject>().SetOnDespawn(() => avtiveEffectExecutors.Remove(effect));
avtiveEffectExecutors.Add(effect);
effect.PlayFeedbacks();
LeanPool.Despawn(effect.gameObject, xDuration);
}
@@ -80,6 +87,8 @@ namespace Ichni.RhythmGame
effect.GetFeedbackOfType<MMF_Rotation>().AnimateZ = false;
effect.GetFeedbackOfType<MMF_Rotation>().RemapCurveOne = yPeak;
effect.GetFeedbackOfType<MMF_Rotation>().AnimateRotationY = tiltCurveY;
effect.GetComponent<PooledObject>().SetOnDespawn(() => avtiveEffectExecutors.Remove(effect));
avtiveEffectExecutors.Add(effect);
effect.PlayFeedbacks();
LeanPool.Despawn(effect.gameObject, yDuration);
}
@@ -94,6 +103,8 @@ namespace Ichni.RhythmGame
effect.GetFeedbackOfType<MMF_Rotation>().AnimateY = false;
effect.GetFeedbackOfType<MMF_Rotation>().RemapCurveOne = zPeak;
effect.GetFeedbackOfType<MMF_Rotation>().AnimateRotationZ = tiltCurveZ;
effect.GetComponent<PooledObject>().SetOnDespawn(() => avtiveEffectExecutors.Remove(effect));
avtiveEffectExecutors.Add(effect);
effect.PlayFeedbacks();
LeanPool.Despawn(effect.gameObject, zDuration);
}
@@ -106,7 +117,22 @@ namespace Ichni.RhythmGame
haveYTilt, yDuration, yPeak, tiltCurveY,
haveZTilt, zDuration, zPeak, tiltCurveZ);
}
public override void Disrupt()
{
foreach (MMF_Player executor in avtiveEffectExecutors)
{
executor.StopFeedbacks();
}
for (var i = 0; i < avtiveEffectExecutors.Count; i++)
{
LeanPool.Despawn(avtiveEffectExecutors[i].gameObject);
}
EditorManager.instance.cameraManager.gameCamera.gameCamera.transform.DOLocalRotate(Vector3.zero, 0.2f);
}
public override void SetUpInspector()
{
IHaveInspection inspector = EditorManager.instance.uiManager.inspector;

View File

@@ -0,0 +1,24 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
namespace Ichni.RhythmGame
{
public class CameraTiltHoldingEffect : MonoBehaviour
{
public bool haveXTilt;
public float xDuration;
public float xPeak;
public AnimationCurve tiltCurveX;
public bool haveYTilt;
public float yDuration;
public float yPeak;
public AnimationCurve tiltCurveY;
public bool haveZTilt;
public float zDuration;
public float zPeak;
public AnimationCurve tiltCurveZ;
}
}

View File

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

View File

@@ -7,6 +7,7 @@ using Ichni.Editor;
using Ichni.RhythmGame.Beatmap;
using Unity.VisualScripting;
using UnityEngine;
using UnityEngine.InputSystem;
namespace Ichni.RhythmGame
{
@@ -135,6 +136,15 @@ namespace Ichni.RhythmGame
{
protected override void Update()
{
if (Keyboard.current.hKey.wasPressedThisFrame)
{
foreach (KeyValuePair<string,List<EffectBase>> effect in noteVisual.effectSubmodule.effectCollection)
{
effect.Value.ForEach(x => x.Disrupt());
}
}
if (holdEndTime < exactJudgeTime)
{
LogWindow.Log("Hold end time is earlier than exact judge time.", Color.red);
@@ -193,9 +203,11 @@ namespace Ichni.RhythmGame
if (noteVisual != null)
{
noteVisual.effectSubmodule.effectCollection["Generate"].ForEach(e => e.UpdateEffect(exactJudgeTime));
noteVisual.effectSubmodule.effectCollection["GeneralJudge"].ForEach(e => e.UpdateEffect(holdEndTime));
noteVisual.effectSubmodule.effectCollection["StartHold"].ForEach(e => e.UpdateEffect(exactJudgeTime));
noteVisual.effectSubmodule.effectCollection["Holding"].ForEach(e => e.UpdateEffect(exactJudgeTime));
noteVisual.effectSubmodule.effectCollection["GeneralJudge"].ForEach(e => e.UpdateEffect(holdEndTime));
switch (EditorManager.instance.currentJudgeType)
{
case NoteJudgeType.Perfect:
@@ -211,6 +223,8 @@ namespace Ichni.RhythmGame
noteVisual.effectSubmodule.effectCollection["Miss"].ForEach(e => e.UpdateEffect(holdEndTime));
break;
}
noteVisual.effectSubmodule.effectCollection["AfterJudge"].ForEach(e => e.UpdateEffect(holdEndTime));
if (EditorManager.instance.cameraManager.haveGameCamera)
{

View File

@@ -19896,45 +19896,9 @@
"attachedElementGuid" : {
"value" : "5df3368d-144c-44c5-87d1-9b8b51919fbf"
}
},{
"__type" : "Ichni.RhythmGame.Beatmap.CameraAngleOffset_BM,Assembly-CSharp",
"enabling" : {
"animatedBoolList" : [
{
"value" : true,
"time" : 0
},{
"value" : false,
"time" : 999
}
]
},
"maxX" : 0,
"maxY" : 0,
"maxZ" : 15,
"timeToMax" : 0.3,
"animationCurveType" : 0,
"elementName" : "New CameraAngleOffset",
"tags" : [
],
"elementGuid" : {
"value" : "9cfb6584-6135-4a8f-9884-07078629ab3d"
},
"attachedElementGuid" : {
"value" : "fd3aa9d5-da52-4a3e-94ce-41478f20492b"
}
},{
"__type" : "Ichni.RhythmGame.Beatmap.TimeDurationSubmodule_BM,Assembly-CSharp",
"isOverridingDuration" : false,
"startTime" : -32767,
"endTime" : 32767,
"attachedElementGuid" : {
"value" : "9cfb6584-6135-4a8f-9884-07078629ab3d"
}
},{
"__type" : "Ichni.RhythmGame.Beatmap.Hold_BM,Assembly-CSharp",
"holdEndTime" : 16.1,
"holdEndTime" : 18,
"exactJudgeTime" : 15.6,
"elementName" : "New Hold",
"tags" : [
@@ -19955,7 +19919,7 @@
],
"elementGuid" : {
"value" : "25ff9650-92e4-4808-87c4-5096deda9c7a"
"value" : "5afbdf27-2b0e-443a-afb1-731a5eea6302"
},
"attachedElementGuid" : {
"value" : "912bc6d1-5e73-4e34-8f6e-d50bcfda5f99"
@@ -19963,7 +19927,7 @@
},{
"__type" : "Ichni.RhythmGame.Beatmap.TransformSubmodule_BM,Assembly-CSharp",
"originalPosition" : {
"x" : 5,
"x" : 0,
"y" : 0,
"z" : 0
},
@@ -19978,7 +19942,7 @@
"z" : 1
},
"attachedElementGuid" : {
"value" : "25ff9650-92e4-4808-87c4-5096deda9c7a"
"value" : "5afbdf27-2b0e-443a-afb1-731a5eea6302"
}
},{
"__type" : "Ichni.RhythmGame.Beatmap.TimeDurationSubmodule_BM,Assembly-CSharp",
@@ -19986,7 +19950,7 @@
"startTime" : -32767,
"endTime" : 32767,
"attachedElementGuid" : {
"value" : "25ff9650-92e4-4808-87c4-5096deda9c7a"
"value" : "5afbdf27-2b0e-443a-afb1-731a5eea6302"
}
},{
"__type" : "Ichni.RhythmGame.Beatmap.ColorSubmodule_BM,Assembly-CSharp",
@@ -20005,7 +19969,7 @@
},
"originalEmissionIntensity" : 0,
"attachedElementGuid" : {
"value" : "25ff9650-92e4-4808-87c4-5096deda9c7a"
"value" : "5afbdf27-2b0e-443a-afb1-731a5eea6302"
}
},{
"__type" : "Ichni.RhythmGame.Beatmap.EffectSubmodule_BM,Assembly-CSharp",
@@ -20017,6 +19981,86 @@
}
],"GeneralJudge":[
],"StartHold":[
{
"__type" : "Ichni.RhythmGame.Beatmap.CameraTiltEffect_BM,Assembly-CSharp",
"haveXTilt" : false,
"xDuration" : 0.2,
"xPeak" : 5,
"tiltCurveX" : {
"keys" : [
{
"time" : 0,
"value" : 0,
"inTangent" : 0,
"outTangent" : 0
},{
"time" : 0.3,
"value" : 1,
"inTangent" : 0,
"outTangent" : 0
},{
"time" : 1,
"value" : 0,
"inTangent" : 0,
"outTangent" : 0
}
],
"preWrapMode" : 8,
"postWrapMode" : 8
},
"haveYTilt" : true,
"yDuration" : 2.4,
"yPeak" : 60,
"tiltCurveY" : {
"keys" : [
{
"time" : 0,
"value" : 0,
"inTangent" : 0,
"outTangent" : 0
},{
"time" : 0.3,
"value" : 1,
"inTangent" : 0,
"outTangent" : 0
},{
"time" : 1,
"value" : 0,
"inTangent" : 0,
"outTangent" : 0
}
],
"preWrapMode" : 8,
"postWrapMode" : 8
},
"haveZTilt" : false,
"zDuration" : 0.2,
"zPeak" : 5,
"tiltCurveZ" : {
"keys" : [
{
"time" : 0,
"value" : 0,
"inTangent" : 0,
"outTangent" : 0
},{
"time" : 0.3,
"value" : 1,
"inTangent" : 0,
"outTangent" : 0
},{
"time" : 1,
"value" : 0,
"inTangent" : 0,
"outTangent" : 0
}
],
"preWrapMode" : 8,
"postWrapMode" : 8
},
"effectTime" : 0
}
],"Holding":[
],"Perfect":[
@@ -20044,7 +20088,7 @@
]
},
"attachedElementGuid" : {
"value" : "25ff9650-92e4-4808-87c4-5096deda9c7a"
"value" : "5afbdf27-2b0e-443a-afb1-731a5eea6302"
}
}
],