Files
SoulliesOfficial 25b6da25ae 同步
2026-03-31 07:51:40 -04:00

61 lines
1.8 KiB
C#
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
using Ichni.RhythmGame.Beatmap;
using UnityEngine;
namespace Ichni.RhythmGame
{
public class CameraZoomEffect : EffectBase
{
#region [] Effect Parameters
public float relativeZoom;
public AnimationCurve zoomCurve;
private Camera _mainCamera;
private float _startFOV = 60f; // 请填入你项目的默认摄像机广角值
#endregion
#region [] Initialization
public CameraZoomEffect(float effectTime, float relativeZoom, AnimationCurve zoomCurve)
: base(effectTime)
{
this.effectTime = effectTime;
this.relativeZoom = relativeZoom;
this.zoomCurve = zoomCurve;
}
#endregion
#region [] Effect Pattern Overrides
public override void PreExecute()
{
if (_mainCamera == null)
{
_mainCamera = GameManager.Instance.cameraManager.gameCamera.cam;
}
_startFOV = _mainCamera.fieldOfView; // 记录初始 FOV结束时恢复
}
public override void Execute()
{
if (_mainCamera != null)
{
// relativeZoom > 0 代表拉近视野FOV 更小
float offset = zoomCurve.Evaluate(effectProgressPercent) * relativeZoom;
_mainCamera.fieldOfView = _startFOV - offset;
}
}
public override void Adjust() { ResetEffect(); }
public override void Recover() { ResetEffect(); }
public override void Disrupt() { ResetEffect(); }
private void ResetEffect()
{
if (_mainCamera != null) _mainCamera.fieldOfView = _startFOV;
}
#endregion
}
}