CameraTilt初步
This commit is contained in:
@@ -24,5 +24,22 @@ namespace Ichni
|
||||
keys[2] = new Keyframe(totalTime, startValue, 0, 0);
|
||||
return new AnimationCurve(keys);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 自定义峰值点位置的抛物线曲线,在指定时间点达到最大值,两端为起始值
|
||||
/// </summary>
|
||||
/// <param name="totalTime">总时间</param>
|
||||
/// <param name="startValue">起始(和结束)值</param>
|
||||
/// <param name="peakValue">最大值</param>
|
||||
/// <param name="peakTimePercent">最大值的比例点</param>
|
||||
/// <returns></returns>
|
||||
public static AnimationCurve CustomPeakTimeParabolic(float totalTime, float startValue, float peakValue, float peakTimePercent)
|
||||
{
|
||||
Keyframe[] keys = new Keyframe[3];
|
||||
keys[0] = new Keyframe(0, startValue, 0, 0);
|
||||
keys[1] = new Keyframe(totalTime * peakTimePercent, peakValue, 0, 0);
|
||||
keys[2] = new Keyframe(totalTime, startValue, 0, 0);
|
||||
return new AnimationCurve(keys);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -127,6 +127,7 @@ namespace Ichni.RhythmGame
|
||||
{
|
||||
{ "Bloom", new BloomEffect(1, 2, CustomCurvePresets.Parabolic(1, 0, 1)) },
|
||||
{ "CameraShake", new CameraShakeEffect(1, 50, 1, 1, 1) },
|
||||
{"CameraTilt", new CameraTiltEffect(0.2f, 15f, CustomCurvePresets.CustomPeakTimeParabolic(1,0,1, 0.3f))},
|
||||
{ "ChromaticAberration", new ChromaticAberrationEffect(1, 1, CustomCurvePresets.Parabolic(1, 0, 1)) },
|
||||
{ "Vignette", new VignetteEffect(1, 1, 0.4f, Color.black, CustomCurvePresets.Parabolic(1, 0, 1)) },
|
||||
{ "SetInteger", new SetIntegerEffect("New Variable", 0, false, 0, 1) },
|
||||
|
||||
@@ -0,0 +1,85 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using Ichni.Editor;
|
||||
using Ichni.RhythmGame.Beatmap;
|
||||
using Lean.Pool;
|
||||
using MoreMountains.Feedbacks;
|
||||
using MoreMountains.FeedbacksForThirdParty;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Ichni.RhythmGame
|
||||
{
|
||||
public class CameraTiltEffect : EffectBase
|
||||
{
|
||||
public float duration;
|
||||
public float peakZ;
|
||||
public AnimationCurve tiltCurve;
|
||||
|
||||
public CameraTiltEffect(float duration, float peakZ, AnimationCurve tiltCurve)
|
||||
{
|
||||
this.effectTime = 0;
|
||||
this.duration = duration;
|
||||
this.peakZ = peakZ;
|
||||
this.tiltCurve = tiltCurve;
|
||||
}
|
||||
|
||||
public override void Adjust()
|
||||
{
|
||||
if (!EditorManager.instance.cameraManager.haveGameCamera)
|
||||
{
|
||||
LogWindow.Log("No game camera found, cannot apply camera tilt effect.", Color.yellow);
|
||||
return;
|
||||
}
|
||||
|
||||
MMF_Player effect = LeanPool.Spawn(EditorManager.instance.basePrefabs.cameraTiltEffect).GetComponent<MMF_Player>();
|
||||
effect.GetFeedbackOfType<MMF_Rotation>().AnimateRotationTarget = EditorManager.instance.cameraManager.gameCamera.gameCamera.transform;
|
||||
effect.GetFeedbackOfType<MMF_Rotation>().AnimateRotationDuration = duration;
|
||||
effect.GetFeedbackOfType<MMF_Rotation>().RemapCurveOne = peakZ;
|
||||
effect.GetFeedbackOfType<MMF_Rotation>().AnimateRotationZ = tiltCurve;
|
||||
effect.PlayFeedbacks();
|
||||
LeanPool.Despawn(effect.gameObject, duration);
|
||||
}
|
||||
|
||||
public override EffectBase_BM ConvertToBM()
|
||||
{
|
||||
return new CameraTiltEffect_BM(duration, peakZ, tiltCurve);
|
||||
}
|
||||
|
||||
public override void SetUpInspector()
|
||||
{
|
||||
IHaveInspection inspector = EditorManager.instance.uiManager.inspector;
|
||||
var container = inspector.GenerateContainer("Camera Tilt");
|
||||
var effectSettings = container.GenerateSubcontainer(3);
|
||||
var effectTimeField = inspector.GenerateInputField(this, effectSettings, "Duration", nameof(duration));
|
||||
var bloomPeakField = inspector.GenerateInputField(this, effectSettings, "Z Peak Value", nameof(peakZ));
|
||||
var intensityCurveButton = inspector.GenerateButton(this, effectSettings, "Intensity Curve", () =>
|
||||
{
|
||||
var intensityCurveWindow =
|
||||
inspector.GenerateCompositeParameterWindow(this, "Tilt Curve", nameof(tiltCurve)).SetAsCustomCurve();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
namespace Beatmap
|
||||
{
|
||||
public class CameraTiltEffect_BM : EffectBase_BM
|
||||
{
|
||||
public float duration;
|
||||
public float peakZ;
|
||||
public AnimationCurve tiltCurve;
|
||||
|
||||
public CameraTiltEffect_BM(float duration, float peakZ, AnimationCurve tiltCurve)
|
||||
{
|
||||
this.effectTime = 0;
|
||||
this.duration = duration;
|
||||
this.peakZ = peakZ;
|
||||
this.tiltCurve = tiltCurve;
|
||||
}
|
||||
|
||||
public override EffectBase ConvertToGameType(GameElement attachedGameElement)
|
||||
{
|
||||
return new CameraTiltEffect(duration, peakZ, tiltCurve);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7bb75ff6a4e7d9a4a9266e711eeadf10
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -35,7 +35,7 @@ namespace Ichni.RhythmGame
|
||||
|
||||
public override EffectBase_BM ConvertToBM()
|
||||
{
|
||||
return new ChromaticAberrationEffect_BM(duration, peak);
|
||||
return new ChromaticAberrationEffect_BM(duration, peak, intensityCurve);
|
||||
}
|
||||
|
||||
public override void SetUpInspector()
|
||||
@@ -66,11 +66,12 @@ namespace Ichni.RhythmGame
|
||||
|
||||
}
|
||||
|
||||
public ChromaticAberrationEffect_BM(float duration, float peak)
|
||||
public ChromaticAberrationEffect_BM(float duration, float peak, AnimationCurve intensityCurve)
|
||||
{
|
||||
this.effectTime = 0;
|
||||
this.duration = duration;
|
||||
this.peak = peak;
|
||||
this.intensityCurve = intensityCurve;
|
||||
}
|
||||
|
||||
public override EffectBase ConvertToGameType(GameElement attachedGameElement)
|
||||
|
||||
Reference in New Issue
Block a user