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

78 lines
2.3 KiB
C#
Raw Normal View History

2025-07-10 08:42:30 -04:00
using System.Collections;
using System.Collections.Generic;
using DG.Tweening;
using Ichni.RhythmGame.Beatmap;
using Lean.Pool;
using MoreMountains.Feedbacks;
using UnityEngine;
namespace Ichni.RhythmGame
{
public class CameraOffsetEffect : EffectBase
{
public float duration;
public Vector3 offsetValue;
public AnimationCurve offsetCurve;
2025-09-05 10:14:45 -04:00
Transform gameCameraTransform => GameManager.instance.cameraManager.gameCamera.cam.transform;
2025-07-10 08:42:30 -04:00
Tweener offsetTweener;
public CameraOffsetEffect(float duration, Vector3 offsetValue, AnimationCurve offsetCurve)
{
this.effectTime = this.duration;
this.duration = duration;
this.offsetValue = offsetValue;
this.offsetCurve = offsetCurve;
}
public override void Recover()
{
offsetTweener?.Kill(true);
gameCameraTransform.localPosition = Vector3.zero;
}
public override void PreExecute()
{
2025-08-22 14:54:40 -04:00
offsetTweener = gameCameraTransform.DOBlendableLocalMoveBy(offsetValue, duration).SetEase(offsetCurve).Play();
}
public override void Adjust()
{
}
public override void Disrupt()
{
offsetTweener?.Kill();
gameCameraTransform.DOLocalMove(Vector3.zero, 0.4f).Play();
2025-07-10 08:42:30 -04:00
}
public override EffectBase_BM ConvertToBM()
{
return new CameraOffsetEffect_BM(duration, offsetValue, offsetCurve);
}
}
namespace Beatmap
{
public class CameraOffsetEffect_BM : EffectBase_BM
{
public float duration;
public Vector3 offsetValue;
public AnimationCurve offsetCurve;
public CameraOffsetEffect_BM(float duration, Vector3 offsetValue, AnimationCurve offsetCurve)
{
this.effectTime = duration;
this.duration = duration;
this.offsetValue = offsetValue;
this.offsetCurve = offsetCurve;
}
public override EffectBase ConvertToGameType(GameElement attachedGameElement)
{
return new CameraOffsetEffect(duration, offsetValue, offsetCurve);
}
}
}
}