From e2918e4ea5b783aa844547e0bf5e5e20640d56f1 Mon Sep 17 00:00:00 2001
From: Rapandrasmus <78219215+Rapandrasmus@users.noreply.github.com>
Date: Fri, 3 Mar 2023 20:19:33 +0100
Subject: [PATCH] Space gramps sniff and talk animations implemented (#326)
---
Assets/Scripts/Games/SpaceDance/SpaceDance.cs | 140 ++++++++++++++++++
1 file changed, 140 insertions(+)
diff --git a/Assets/Scripts/Games/SpaceDance/SpaceDance.cs b/Assets/Scripts/Games/SpaceDance/SpaceDance.cs
index 1649c9eb8..fffc73dc6 100644
--- a/Assets/Scripts/Games/SpaceDance/SpaceDance.cs
+++ b/Assets/Scripts/Games/SpaceDance/SpaceDance.cs
@@ -82,6 +82,16 @@ namespace HeavenStudio.Games.Loaders
new Param("toggle", true, "Should bop?", "Should the dancers bop?"),
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()
+ {
+ 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,
Both = 2
}
+ public enum GrampsAnimationType
+ {
+ Stand = 0,
+ Talk = 1,
+ Sniff = 2
+ }
Tween bgColorTween;
[SerializeField] SpriteRenderer bg;
[SerializeField] Animator shootingStarAnim;
@@ -126,6 +142,8 @@ namespace HeavenStudio.Games
float shootingStarStartBeat;
EasingFunction.Ease lastEase;
bool isShootingStar;
+ bool grampsLoopingAnim;
+ bool grampsSniffing;
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()
+ {
+ 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()
+ {
+ 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)
{
lastEase = (EasingFunction.Ease)ease;