HeavenStudio/Assets/Scripts/Games/Flockstep/Flockstep.cs
colorplease 1a24d22a9e bopping
2024-02-23 17:40:55 -08:00

128 lines
4.3 KiB
C#

using System;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using HeavenStudio.Util;
using HeavenStudio.InputSystem;
using Jukebox;
namespace HeavenStudio.Games.Loaders
{
using static Minigames;
/// Minigame loaders handle the setup of your minigame.
/// Here, you designate the game prefab, define entities, and mark what AssetBundle to load
/// Names of minigame loaders follow a specific naming convention of `PlatformcodeNameLoader`, where:
/// `Platformcode` is a three-leter platform code with the minigame's origin
/// `Name` is a short internal name
/// `Loader` is the string "Loader"
/// Platform codes are as follows:
/// Agb: Gameboy Advance ("Advance Gameboy")
/// Ntr: Nintendo DS ("Nitro")
/// Rvl: Nintendo Wii ("Revolution")
/// Ctr: Nintendo 3DS ("Centrair")
/// Mob: Mobile
/// Pco: PC / Other
/// Fill in the loader class label, "*prefab name*", and "*Display Name*" with the relevant information
/// For help, feel free to reach out to us on our discord, in the #development channel.
public static class RvlFlockstepLoader
{
public static Minigame AddGame(EventCaller eventCaller)
{
return new Minigame("flockstep", "Flock-Step", "ffffff", false, false, new List<GameAction>()
{
new GameAction("bop", "Bop")
{
function = delegate { var e = eventCaller.currentEntity; Flockstep.instance.Bop(e.beat, e.length, e["toggle2"], e["toggle"]); },
resizable = true,
parameters = new List<Param>()
{
new Param("toggle2", true, "Bop", "Toggle if the the Hue Birds should bop for the duration of this event."),
new Param("toggle", false, "Bop (Auto)", "Toggle if the Hue Birds should automatically bop until another Bop event is reached.")
}
},
new GameAction("march", "Stepping")
{
defaultLength = 1,
},
new GameAction("jump", "Jump")
{
defaultLength = 4f,
},
new GameAction("color", "Birds Color")
{
defaultLength = 0.5f,
},
new GameAction("force", "Force Stepping")
{
resizable = true,
},
}
);
}
}
}
namespace HeavenStudio.Games
{
/// This class handles the minigame logic.
/// Minigame inherits directly from MonoBehaviour, and adds Heaven Studio specific methods to override.
public class Flockstep : Minigame
{
public static Flockstep instance;
bool goBop;
public GameEvent bop = new GameEvent();
[SerializeField] Animator[] allThemOtherBirbs;
[SerializeField] Animator birbPlayer;
public override void OnBeatPulse(double beat)
{
if (goBop)
{
PlayBirbAnim("bop", true, 0.5f);
}
}
void PlayBirbAnim(string animName, bool player, float timescale = 1f, float startpos = 0f, int layer = -1)
{
if (player) birbPlayer.DoScaledAnimationAsync(animName, timescale, startpos, layer);
foreach(Animator birb in allThemOtherBirbs)
{
birb.DoScaledAnimationAsync(animName, timescale, startpos, layer);
}
}
public void Bop(double beat, float length, bool shouldBop, bool autoBop)
{
goBop = autoBop;
if (shouldBop)
{
for (int i = 0; i < length; i++)
{
BeatAction.New(instance, new List<BeatAction.Action>()
{
new BeatAction.Action(beat + i, delegate
{
PlayBirbAnim("bop", true, 0.5f);
})
});
}
}
}
// Start is called before the first frame update
void Awake()
{
instance = this;
SetupBopRegion("flockstep", "bop", "toggle");
}
}
}