Merge branch 'megaminerjenny:master' into remix-properties

This commit is contained in:
Zeo 2022-08-17 18:39:17 -05:00 committed by GitHub
commit a060fc27ee
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 47 additions and 5 deletions

View file

@ -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
@ -22,6 +23,7 @@ namespace HeavenStudio
public static Vector3 defaultPosition = new Vector3(0, 0, -10);
public static Vector3 defaultRotEluer = new Vector3(0, 0, 0);
public static Vector3 defaultScale = new Vector3(16, 9, 1);
public static Vector3 defaultShake = new Vector3(0, 0, 0);
/**
camera's current transformation
@ -30,6 +32,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 +41,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 +93,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);
}
@ -139,6 +150,7 @@ namespace HeavenStudio
float dy = func(rotEluerLast.y, e.valB, Mathf.Min(prog, 1f));
float dz = func(rotEluerLast.z, e.valC, Mathf.Min(prog, 1f));
rotEluer = new Vector3(dx, dy, dz);
}
if (prog > 1f)
{
@ -147,11 +159,33 @@ 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(Mathf.Cos(dx * e.length * 20f) * (e.valA / 2), Mathf.Cos(dy * e.length * 30f) * (e.valA / 2));
}
if (prog > 1f)
{
shakeResult = new Vector3(0, 0);
}
}
}
public static void ResetTransforms()
{
position = defaultPosition;
rotEluer = defaultRotEluer;
scale = defaultScale;
shakeResult = defaultShake;
}
public static void ResetAdditionalTransforms()

View file

@ -12,7 +12,7 @@ namespace HeavenStudio.Games.Loaders
public static Minigame AddGame(EventCaller eventCaller) {
return new Minigame("clappyTrio", "The Clappy Trio", "29E7FF", false, false, new List<GameAction>()
{
new GameAction("clap", delegate { ClappyTrio.instance.Clap(eventCaller.currentEntity.beat, eventCaller.currentEntity.length); }, 3, true),
new GameAction("clap", delegate { ClappyTrio.instance.Clap(eventCaller.currentEntity.beat, eventCaller.currentEntity.length); }, 1, true),
new GameAction("bop", delegate { ClappyTrio.instance.Bop(eventCaller.currentEntity.beat); } ),
new GameAction("prepare", delegate { ClappyTrio.instance.Prepare(eventCaller.currentEntity.toggle ? 3 : 0); }, parameters: new List<Param>()
{

View file

@ -81,9 +81,9 @@ namespace HeavenStudio.Games.Loaders
),
new GameAction("set object colors", delegate { var e = eventCaller.currentEntity; KarateMan.UpdateMaterialColour(e.colorA, e.colorB, e.colorC); }, 0.5f, false, new List<Param>()
{
new Param("colorA", new Color(), "Joe Body Color", "The color to use for Karate Joe's body"),
new Param("colorB", new Color(), "Joe Highlight Color", "The color to use for Karate Joe's highlights"),
new Param("colorC", new Color(), "Item Color", "The color to use for the thrown items"),
new Param("colorA", new Color(1,1,1,1), "Joe Body Color", "The color to use for Karate Joe's body"),
new Param("colorB", new Color(0.81f,0.81f,0.81f,1), "Joe Highlight Color", "The color to use for Karate Joe's highlights"),
new Param("colorC", new Color(1,1,1,1), "Item Color", "The color to use for the thrown items"),
},
inactiveFunction: delegate { var e = eventCaller.currentEntity; KarateMan.UpdateMaterialColour(e.colorA, e.colorB, e.colorC); }
),

View file

@ -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, 10, 2), "Intensity")
} ),
new GameAction("move camera", delegate
{
//TODO: move cam