Space gramps sniff and talk animations implemented (#326)

This commit is contained in:
Rapandrasmus 2023-03-03 20:19:33 +01:00 committed by GitHub
parent 5952d4d8d1
commit e2918e4ea5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -82,6 +82,16 @@ namespace HeavenStudio.Games.Loaders
new Param("toggle", true, "Should bop?", "Should the dancers bop?"), new Param("toggle", true, "Should bop?", "Should the dancers bop?"),
new Param("gramps", false, "Gramps Bop", "Should Space Gramps bop with the dancers?") new Param("gramps", false, "Gramps Bop", "Should Space Gramps bop with the dancers?")
} }
},
new GameAction("grampsAnims", "Space Gramps Animations")
{
function = delegate {var e = eventCaller.currentEntity; SpaceDance.instance.GrampsAnimations(e.beat, e["type"], e["toggle"]); },
defaultLength = 0.5f,
parameters = new List<Param>()
{
new Param("toggle", true, "Looping", "Should the animation loop?"),
new Param("type", SpaceDance.GrampsAnimationType.Talk, "Which animation?", "Which animation should space gramps do?")
}
} }
}); });
} }
@ -108,6 +118,12 @@ namespace HeavenStudio.Games
Gramps = 1, Gramps = 1,
Both = 2 Both = 2
} }
public enum GrampsAnimationType
{
Stand = 0,
Talk = 1,
Sniff = 2
}
Tween bgColorTween; Tween bgColorTween;
[SerializeField] SpriteRenderer bg; [SerializeField] SpriteRenderer bg;
[SerializeField] Animator shootingStarAnim; [SerializeField] Animator shootingStarAnim;
@ -126,6 +142,8 @@ namespace HeavenStudio.Games
float shootingStarStartBeat; float shootingStarStartBeat;
EasingFunction.Ease lastEase; EasingFunction.Ease lastEase;
bool isShootingStar; bool isShootingStar;
bool grampsLoopingAnim;
bool grampsSniffing;
public GameEvent bop = new GameEvent(); public GameEvent bop = new GameEvent();
@ -193,6 +211,128 @@ namespace HeavenStudio.Games
} }
} }
public void GrampsAnimations(float beat, int type, bool looping)
{
switch (type)
{
case (int)GrampsAnimationType.Stand:
Gramps.Play("GrampsStand", 0, 0);
grampsLoopingAnim = false;
grampsSniffing = false;
break;
case (int)GrampsAnimationType.Talk:
if (looping)
{
grampsLoopingAnim = true;
grampsSniffing = false;
GrampsTalkLoop(beat);
}
else
{
grampsLoopingAnim = false;
grampsSniffing = false;
Gramps.DoScaledAnimationAsync("GrampsTalk", 0.5f);
}
break;
case (int)GrampsAnimationType.Sniff:
if (looping)
{
grampsLoopingAnim = true;
grampsSniffing = true;
GrampsSniffLoop(beat);
}
else
{
grampsLoopingAnim = false;
grampsSniffing = false;
Gramps.DoScaledAnimationAsync("GrampsSniff", 0.5f);
}
break;
}
}
void GrampsSniffLoop(float beat)
{
if (!grampsLoopingAnim || !grampsSniffing) return;
spaceGrampsShouldBop = false;
BeatAction.New(instance.gameObject, new List<BeatAction.Action>()
{
new BeatAction.Action(beat, delegate
{
if (grampsSniffing && grampsLoopingAnim)
{
Gramps.DoScaledAnimationAsync("GrampsSniff", 0.5f);
}
}),
new BeatAction.Action(beat + 3, delegate
{
if (grampsSniffing && grampsLoopingAnim)
{
Gramps.DoScaledAnimationAsync("GrampsSniff", 0.5f);
}
}),
new BeatAction.Action(beat + 3.5f, delegate
{
if (grampsSniffing && grampsLoopingAnim)
{
Gramps.DoScaledAnimationAsync("GrampsSniff", 0.5f);
}
}),
new BeatAction.Action(beat + 5.5f, delegate
{
GrampsSniffLoop(beat + 5.5f);
}),
});
}
void GrampsTalkLoop(float beat)
{
if (!grampsLoopingAnim || grampsSniffing) return;
spaceGrampsShouldBop = false;
BeatAction.New(instance.gameObject, new List<BeatAction.Action>()
{
new BeatAction.Action(beat + 0.66666f , delegate
{
if (!grampsSniffing && grampsLoopingAnim)
{
Gramps.DoScaledAnimationAsync("GrampsTalk", 0.5f);
}
}),
new BeatAction.Action(beat + 1.33333f, delegate
{
if (!grampsSniffing && grampsLoopingAnim)
{
Gramps.DoScaledAnimationAsync("GrampsTalk", 0.5f);
}
}),
new BeatAction.Action(beat + 2f, delegate
{
if (!grampsSniffing && grampsLoopingAnim)
{
Gramps.DoScaledAnimationAsync("GrampsTalk", 0.5f);
}
}),
new BeatAction.Action(beat + 3f, delegate
{
if (!grampsSniffing && grampsLoopingAnim)
{
Gramps.DoScaledAnimationAsync("GrampsTalk", 0.5f);
}
}),
new BeatAction.Action(beat + 3.5f, delegate
{
if (!grampsSniffing && grampsLoopingAnim)
{
Gramps.DoScaledAnimationAsync("GrampsTalk", 0.5f);
}
}),
new BeatAction.Action(beat + 4f, delegate
{
GrampsTalkLoop(beat + 4f);
}),
});
}
public void UpdateShootingStar(float beat, float length, int ease) public void UpdateShootingStar(float beat, float length, int ease)
{ {
lastEase = (EasingFunction.Ease)ease; lastEase = (EasingFunction.Ease)ease;