Files
ichni_Official/Assets/Scripts/Game/GameElements/GeneralEffects/CameraZoomEffect.cs

61 lines
1.8 KiB
C#
Raw Normal View History

2025-07-10 08:42:30 -04:00
using Ichni.RhythmGame.Beatmap;
using UnityEngine;
namespace Ichni.RhythmGame
{
public class CameraZoomEffect : EffectBase
{
2026-03-14 03:13:10 -04:00
#region [] Effect Parameters
2025-07-10 08:42:30 -04:00
public float relativeZoom;
public AnimationCurve zoomCurve;
2026-03-14 03:13:10 -04:00
private Camera _mainCamera;
private float _startFOV = 60f; // 请填入你项目的默认摄像机广角值
#endregion
2025-07-10 08:42:30 -04:00
2026-03-14 03:13:10 -04:00
#region [] Initialization
2026-03-31 07:51:40 -04:00
public CameraZoomEffect(float effectTime, float relativeZoom, AnimationCurve zoomCurve)
: base(effectTime)
2025-07-10 08:42:30 -04:00
{
2026-03-31 07:51:40 -04:00
this.effectTime = effectTime;
2025-07-10 08:42:30 -04:00
this.relativeZoom = relativeZoom;
this.zoomCurve = zoomCurve;
}
2026-03-14 03:13:10 -04:00
#endregion
2025-07-10 08:42:30 -04:00
2026-03-14 03:13:10 -04:00
#region [] Effect Pattern Overrides
public override void PreExecute()
2025-07-10 08:42:30 -04:00
{
2026-03-14 03:13:10 -04:00
if (_mainCamera == null)
{
_mainCamera = GameManager.Instance.cameraManager.gameCamera.cam;
}
_startFOV = _mainCamera.fieldOfView; // 记录初始 FOV结束时恢复
2025-07-10 08:42:30 -04:00
}
2026-03-14 03:13:10 -04:00
public override void Execute()
2025-07-10 08:42:30 -04:00
{
2026-03-14 03:13:10 -04:00
if (_mainCamera != null)
{
// relativeZoom > 0 代表拉近视野FOV 更小
float offset = zoomCurve.Evaluate(effectProgressPercent) * relativeZoom;
_mainCamera.fieldOfView = _startFOV - offset;
}
2025-07-10 08:42:30 -04:00
}
2026-03-14 03:13:10 -04:00
public override void Adjust() { ResetEffect(); }
public override void Recover() { ResetEffect(); }
public override void Disrupt() { ResetEffect(); }
2025-07-10 08:42:30 -04:00
2026-03-14 03:13:10 -04:00
private void ResetEffect()
{
if (_mainCamera != null) _mainCamera.fieldOfView = _startFOV;
2025-07-10 08:42:30 -04:00
}
2026-03-14 03:13:10 -04:00
#endregion
2025-07-10 08:42:30 -04:00
}
2026-03-14 03:13:10 -04:00
}
2026-03-31 07:51:40 -04:00