mirror of
https://github.com/RHeavenStudioPlus/HeavenStudioPlus.git
synced 2024-11-27 03:53:01 +00:00
start work on screen shake
This commit is contained in:
parent
bd027977c7
commit
886de49a89
2 changed files with 39 additions and 1 deletions
|
@ -15,6 +15,7 @@ namespace HeavenStudio
|
|||
private List<Beatmap.Entity> positionEvents = new List<Beatmap.Entity>();
|
||||
private List<Beatmap.Entity> rotationEvents = new List<Beatmap.Entity>();
|
||||
private List<Beatmap.Entity> scaleEvents = new List<Beatmap.Entity>();
|
||||
private List<Beatmap.Entity> shakeEvents = new List<Beatmap.Entity>();
|
||||
|
||||
/**
|
||||
default cam position, for quick-resetting
|
||||
|
@ -30,6 +31,7 @@ namespace HeavenStudio
|
|||
private static Vector3 position;
|
||||
private static Vector3 rotEluer;
|
||||
private static Vector3 scale;
|
||||
private static Vector3 shakeResult;
|
||||
|
||||
/**
|
||||
camera's last transformation
|
||||
|
@ -38,6 +40,7 @@ namespace HeavenStudio
|
|||
private static Vector3 positionLast;
|
||||
private static Vector3 rotEluerLast;
|
||||
private static Vector3 scaleLast;
|
||||
private static Vector3 shakeLast;
|
||||
|
||||
/**
|
||||
transformations to apply *after* the global transform,
|
||||
|
@ -89,20 +92,27 @@ namespace HeavenStudio
|
|||
rotationEvents = EventCaller.GetAllInGameManagerList("vfx", new string[] { "rotate camera" });
|
||||
positionEvents.AddRange(EventCaller.GetAllInGameManagerList("gameManager", new string[] { "rotate camera" }));
|
||||
|
||||
//screen shake time baybee
|
||||
|
||||
shakeEvents = EventCaller.GetAllInGameManagerList("vfx", new string[] { "screen shake" });
|
||||
|
||||
|
||||
//scale (TODO)
|
||||
// scaleEvents = EventCaller.GetAllInGameManagerList("vfx", new string[] { "scale camera" });
|
||||
|
||||
UpdateCameraTranslate();
|
||||
UpdateCameraRotate();
|
||||
SetShakeIntensity();
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
UpdateCameraTranslate();
|
||||
UpdateCameraRotate();
|
||||
SetShakeIntensity();
|
||||
|
||||
Camera cam = GetCamera();
|
||||
cam.transform.localPosition = position + additionalPosition;
|
||||
cam.transform.localPosition = position + additionalPosition + shakeResult;
|
||||
cam.transform.eulerAngles = rotEluer + additionalRotEluer;
|
||||
cam.transform.localScale = Vector3.Scale(scale, additionalScale);
|
||||
}
|
||||
|
@ -147,6 +157,26 @@ namespace HeavenStudio
|
|||
}
|
||||
}
|
||||
|
||||
//scren shake spaghetti
|
||||
private void SetShakeIntensity()
|
||||
{
|
||||
foreach (var e in shakeEvents)
|
||||
{
|
||||
float prog = Conductor.instance.GetPositionFromBeat(e.beat, e.length);
|
||||
if (prog >= 0f)
|
||||
{
|
||||
EasingFunction.Function func = EasingFunction.GetEasingFunction(e.ease);
|
||||
float dx = func(positionLast.x, e.valA, Mathf.Min(prog, 1f));
|
||||
float dy = func(positionLast.y, e.valA, Mathf.Min(prog, 1f));
|
||||
shakeResult = new Vector3(dx, dy);
|
||||
}
|
||||
if (prog > 1f)
|
||||
{
|
||||
shakeLast = new Vector3(e.valA, e.valA);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void ResetTransforms()
|
||||
{
|
||||
position = defaultPosition;
|
||||
|
|
|
@ -332,6 +332,14 @@ namespace HeavenStudio
|
|||
new Param("ease", EasingFunction.Ease.Linear, "Ease")
|
||||
}, hidden: false ),
|
||||
|
||||
new GameAction("screen shake", delegate
|
||||
{
|
||||
//TODO: move cam
|
||||
}, 1f, true, new List<Param>()
|
||||
{
|
||||
new Param("valA", new EntityTypes.Float(0, 50, 10), "Intensity")
|
||||
} ),
|
||||
|
||||
new GameAction("move camera", delegate
|
||||
{
|
||||
//TODO: move cam
|
||||
|
|
Loading…
Reference in a new issue