This commit is contained in:
2025-06-01 15:36:20 +08:00
parent 9d92c7c944
commit df7abdb320
18 changed files with 21599 additions and 19177 deletions

View File

@@ -0,0 +1,209 @@
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

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

View File

@@ -44,7 +44,7 @@ namespace Ichni.RhythmGame
eulerAngleY.UpdateFlexibleFloat(songTime);
eulerAngleZ.UpdateFlexibleFloat(songTime);
if ((eulerAngleX.returnType is FlexibleReturnType.MiddleExecuting || eulerAngleX.isSwitchingReturnType) ||
if (eulerAngleX.returnType is FlexibleReturnType.MiddleExecuting || eulerAngleX.isSwitchingReturnType ||
(eulerAngleY.returnType is FlexibleReturnType.MiddleExecuting || eulerAngleY.isSwitchingReturnType) ||
(eulerAngleZ.returnType is FlexibleReturnType.MiddleExecuting || eulerAngleZ.isSwitchingReturnType))
{

View File

@@ -15,7 +15,7 @@ namespace Ichni.RhythmGame
this.value = value;
this.time = time;
}
public void ApplyTimeOffset(float offset)
{
time += offset;
@@ -61,16 +61,20 @@ namespace Ichni.RhythmGame
/// <returns>返回距离当前时间最近的前一个AnimatedBool</returns>
AnimatedBool GetAnimatedBool(float nowTime)
{
if (animations.Count == 0)
{
return new AnimatedBool(0, false);
}
if (nowTime < animations[0].time)
{
return animations[0];
}
if (nowTime > animations[animations.Count - 1].time)
{
return animations[animations.Count - 1];
}
for (int i = 0; i < animations.Count; i++)
{
if (nowTime < animations[i].time)
@@ -81,7 +85,7 @@ namespace Ichni.RhythmGame
return new AnimatedBool(0, false);
}
/// <summary>
/// 转换为Beatmap存档类型
/// </summary>
@@ -89,7 +93,7 @@ namespace Ichni.RhythmGame
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));

View File

@@ -14,8 +14,8 @@ namespace Ichni.RhythmGame
public partial class EffectSubmodule : SubmoduleBase
{
public Dictionary<string, List<EffectBase>> effectCollection;
public EffectSubmodule(GameElement attachedGameElement, EffectSubmodulePreset preset = EffectSubmodulePreset.Default)
public EffectSubmodule(GameElement attachedGameElement, EffectSubmodulePreset preset = EffectSubmodulePreset.Default)
: base(attachedGameElement)
{
effectCollection = new Dictionary<string, List<EffectBase>>();
@@ -87,7 +87,7 @@ namespace Ichni.RhythmGame
{
IHaveInspection inspector = EditorManager.instance.uiManager.inspector;
Inspector inspectorMain = EditorManager.instance.uiManager.inspector;
foreach (var effect in effectCollection)
{
var container = inspector.GenerateContainer(effect.Key);
@@ -102,10 +102,10 @@ namespace Ichni.RhythmGame
}
else
{
LogWindow.Log("Effect Type not found.", Color.red);
LogWindow.Log("Effect Type not found.", Color.yellow);
}
});
foreach (var effectBase in effect.Value)
{
effectBase.SetUpInspector();
@@ -150,17 +150,17 @@ namespace Ichni.RhythmGame
public class EffectSubmodule_BM : Submodule_BM
{
public Dictionary<string, List<EffectBase_BM>> effectCollection;
public EffectSubmodule_BM()
{
}
public EffectSubmodule_BM(GameElement attachedElement) : base(attachedElement)
{
effectCollection = new Dictionary<string, List<EffectBase_BM>>();
IHaveEffectSubmodule element = attachedElement as IHaveEffectSubmodule;
foreach (var effect in element.effectSubmodule.effectCollection)
{
List<EffectBase_BM> effectList = new List<EffectBase_BM>();
@@ -177,7 +177,7 @@ namespace Ichni.RhythmGame
attachedElement = GameElement_BM.GetElement(attachedElementGuid);
(attachedElement as IHaveEffectSubmodule).effectSubmodule = new EffectSubmodule(attachedElement, effectCollection);
}
public override void DuplicateBM(GameElement attached)
{
(attached as IHaveEffectSubmodule).effectSubmodule = new EffectSubmodule(attached, effectCollection);
@@ -194,14 +194,14 @@ namespace Ichni.RhythmGame
After = 1,
Error = 100
}
public BaseElement_BM matchedBM { get; set; }
/// <summary>
/// 效果的持续时间如果为0则表示瞬间效果
/// </summary>
public float effectTime;
/// <summary>
/// 是否是瞬间效果
/// </summary>
@@ -211,7 +211,7 @@ namespace Ichni.RhythmGame
/// 效果的进度百分比
/// </summary>
public float effectProgressPercent;
/// <summary>
/// 效果当前的状态
/// </summary>
@@ -230,7 +230,7 @@ namespace Ichni.RhythmGame
this.nowEffectState = EffectState.Before;
this.effectProgressPercent = 0;
}
public void SaveBM()
{
throw new System.NotImplementedException();
@@ -240,7 +240,7 @@ namespace Ichni.RhythmGame
{
EffectState state = CheckEffectState(triggerTime);
float songTime = EditorManager.instance.songInformation.songTime;
if (state == EffectState.Before && nowEffectState != EffectState.Before)
{
nowEffectState = EffectState.Before;
@@ -253,7 +253,7 @@ namespace Ichni.RhythmGame
{
PreExecute();
}
nowEffectState = EffectState.Middle;
effectProgressPercent = (songTime - triggerTime) / effectTime;
Execute();
@@ -288,21 +288,21 @@ namespace Ichni.RhythmGame
return EffectState.Error;
}
/// <summary>
/// 当从Before状态进入Middle状态时仅在效果的开始时触发一次方法
/// </summary>
public virtual void PreExecute()
{
}
/// <summary>
/// 在效果的持续时间内,触发这个方法
/// </summary>
public virtual void Execute()
{
}
/// <summary>
@@ -311,7 +311,7 @@ namespace Ichni.RhythmGame
/// </summary>
public virtual void Adjust()
{
}
/// <summary>
@@ -319,7 +319,7 @@ namespace Ichni.RhythmGame
/// </summary>
public virtual void Recover()
{
}
/// <summary>
@@ -330,7 +330,7 @@ namespace Ichni.RhythmGame
public void Refresh()
{
}
public abstract void SetUpInspector();
@@ -341,17 +341,17 @@ namespace Ichni.RhythmGame
public abstract class EffectBase_BM
{
public float effectTime;
public EffectBase_BM()
{
}
public EffectBase_BM(float effectTime)
{
this.effectTime = effectTime;
}
/// <summary>
/// 转换为游戏类
/// </summary>

View File

@@ -75,10 +75,27 @@ namespace Ichni.RhythmGame
var swirlButton = inspector.GenerateButton(this, generateAnimation, "Swirl",
() => Swirl.GenerateElement("New Swirl", Guid.NewGuid(), new List<string>(), true, this,
new FlexibleFloat(), new FlexibleFloat(), new FlexibleFloat()));
var extensionButton = inspector.GenerateButton(this, generateAnimation, "Extension",
() => GameCameraExtension.GenerateElement("New Extension", Guid.NewGuid(),
() => 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
));
}
}
}
@@ -117,9 +134,9 @@ namespace Ichni.RhythmGame
{
return;
}
bool willRefresh = false;
if (transformSubmodule.eulerAnglesOffsetLock)
{
transform.localEulerAngles = transformSubmodule.originalEulerAngles;
@@ -151,15 +168,15 @@ namespace Ichni.RhythmGame
transformSubmodule.positionDirtyMark = false;
willRefresh = true;
}
if(willRefresh)
if (willRefresh)
{
this.Refresh();
}
transformSubmodule.eulerAnglesOffset.Clear();
transformSubmodule.positionOffset.Clear();
}).AddTo(gameObject);
}
}

View File

@@ -12,22 +12,24 @@ namespace Ichni.RhythmGame
{
public partial class Hold : NoteBase
{
public static List<Hold> holdingHoldList = new();
public float holdEndTime;
public float holdingTime;
public bool isHolding;
public bool isFinalJudged;
public static Hold GenerateElement(string elementName, Guid id, List<string> tags, bool isFirstGenerated,
GameElement parentElement, float exactJudgeTime, float holdEndTime)
{
Hold hold = Instantiate(EditorManager.instance.basePrefabs.holdNote, parentElement.transform)
.GetComponent<Hold>();
if (EditorManager.instance.useNotePrefab)
{
isFirstGenerated = false;
}
hold.Initialize(elementName, id, tags, isFirstGenerated, parentElement);
hold.exactJudgeTime = exactJudgeTime;
hold.holdEndTime = holdEndTime;
@@ -54,10 +56,10 @@ namespace Ichni.RhythmGame
hold.track = null;
hold.isOnTrack = false;
}
if (EditorManager.instance.useNotePrefab)
{
EditorManager.instance.projectManager.notePrefabManager.LoadNotePrefab(hold,GetNoteTypeName(hold) + "_Prefab");
EditorManager.instance.projectManager.notePrefabManager.LoadNotePrefab(hold, GetNoteTypeName(hold) + "_Prefab");
}
return hold;
@@ -88,7 +90,7 @@ namespace Ichni.RhythmGame
}
}
}
public partial class Hold
{
public override void SetDefaultSubmodules()
@@ -105,9 +107,9 @@ namespace Ichni.RhythmGame
public override void SetUpInspector()
{
base.SetUpInspector();
IHaveInspection inspector = EditorManager.instance.uiManager.inspector;
var holdSpecial = inspector.GenerateContainer("Hold");
var holdSpecialSubcontainer = holdSpecial.GenerateSubcontainer(3);
var holdEndTimeInputField = inspector.GenerateInputField(this, holdSpecialSubcontainer, "holdEndTime", nameof(holdEndTime));
@@ -118,7 +120,7 @@ namespace Ichni.RhythmGame
effect.effectTime = holdEndTime - exactJudgeTime;
});
});
inspector.MarkedElements["ExactJudgeTime"].AddListenerFunction(() =>
{
noteVisual?.effectSubmodule.effectCollection["Holding"].ForEach(effect =>
@@ -133,12 +135,12 @@ namespace Ichni.RhythmGame
{
protected override void Update()
{
if(holdEndTime < exactJudgeTime)
if (holdEndTime < exactJudgeTime)
{
LogWindow.Log("Hold end time is earlier than exact judge time.", Color.red);
return;
}
/*if (isOnTrack)
{
UpdateNoteInTrack();
@@ -148,22 +150,23 @@ namespace Ichni.RhythmGame
if (isFirstJudged && songTime < exactJudgeTime)
{
isFirstJudged = false;
isHolding = false;
isFinalJudged = false;
holdingTime = 0;
}
if (isHolding)
{
holdingTime = songTime - exactJudgeTime;
}
if (isHolding && songTime > holdEndTime)
{
isHolding = false;
isFinalJudged = true;
noteAudioSubmodule.PlayNoteJudgeAudios(EditorManager.instance.currentJudgeType);
noteAudioSubmodule?.PlayNoteJudgeAudios(EditorManager.instance.currentJudgeType);
}
if (!isFirstJudged && songTime >= exactJudgeTime)
@@ -214,8 +217,16 @@ namespace Ichni.RhythmGame
noteScreenPosition = EditorManager.instance.cameraManager.gameCamera.gameCamera.WorldToScreenPoint(noteVisual.transform.position);
}
}
if (isHolding && !holdingHoldList.Contains(this))
{
holdingHoldList.Add(this);
}
else if (!isHolding && holdingHoldList.Contains(this))
{
holdingHoldList.Remove(this);
}
}
private void LateUpdate()
{
if (isOnTrack)
@@ -230,7 +241,7 @@ namespace Ichni.RhythmGame
public class Hold_BM : NoteBase_BM
{
public float holdEndTime;
public Hold_BM()
{