2023-02-23 00:25:14 +00:00
|
|
|
using HeavenStudio.Util;
|
2023-10-29 19:44:47 +00:00
|
|
|
using HeavenStudio.InputSystem;
|
2023-02-23 00:25:14 +00:00
|
|
|
using System;
|
|
|
|
using System.Collections.Generic;
|
|
|
|
using UnityEngine;
|
|
|
|
|
|
|
|
using NaughtyBezierCurves;
|
|
|
|
|
|
|
|
namespace HeavenStudio.Games.Loaders
|
|
|
|
{
|
|
|
|
using static Minigames;
|
|
|
|
public static class pcoMeatLoader
|
|
|
|
{
|
2023-10-29 19:44:47 +00:00
|
|
|
public static Minigame AddGame(EventCaller eventCaller)
|
|
|
|
{
|
2023-04-02 02:28:23 +00:00
|
|
|
return new Minigame("meatGrinder", "Meat Grinder", "501d18", false, false, new List<GameAction>()
|
2023-02-23 00:25:14 +00:00
|
|
|
{
|
|
|
|
new GameAction("MeatToss", "Meat Toss")
|
|
|
|
{
|
|
|
|
function = delegate {
|
2023-10-29 19:44:47 +00:00
|
|
|
var e = eventCaller.currentEntity;
|
|
|
|
MeatGrinder.instance.MeatToss(e.beat);
|
2023-02-23 00:25:14 +00:00
|
|
|
},
|
|
|
|
defaultLength = 2f,
|
|
|
|
priority = 2,
|
|
|
|
},
|
|
|
|
new GameAction("MeatCall", "Meat Call")
|
|
|
|
{
|
|
|
|
function = delegate {
|
2023-10-29 19:44:47 +00:00
|
|
|
var e = eventCaller.currentEntity;
|
|
|
|
MeatGrinder.instance.MeatCall(e.beat);
|
2023-02-23 00:25:14 +00:00
|
|
|
},
|
|
|
|
defaultLength = 0.5f,
|
|
|
|
priority = 2,
|
2023-03-18 04:40:20 +00:00
|
|
|
preFunctionLength = 1f,
|
|
|
|
preFunction = delegate {
|
2023-10-29 19:44:47 +00:00
|
|
|
var e = eventCaller.currentEntity;
|
2023-05-07 04:45:44 +00:00
|
|
|
MeatGrinder.PreInterval(e.beat, 4f);
|
2023-03-18 04:40:20 +00:00
|
|
|
},
|
2023-02-23 00:25:14 +00:00
|
|
|
},
|
|
|
|
new GameAction("StartInterval", "Start Interval")
|
|
|
|
{
|
|
|
|
defaultLength = 4f,
|
|
|
|
resizable = true,
|
2023-06-04 04:30:42 +00:00
|
|
|
priority = 5,
|
2023-02-23 00:25:14 +00:00
|
|
|
preFunction = delegate {
|
2023-05-07 04:45:44 +00:00
|
|
|
var e = eventCaller.currentEntity;
|
2023-02-23 00:25:14 +00:00
|
|
|
MeatGrinder.PreInterval(e.beat, e.length);
|
|
|
|
},
|
|
|
|
},
|
|
|
|
new GameAction("bop", "Bop")
|
|
|
|
{
|
|
|
|
function = delegate {
|
2023-10-29 19:44:47 +00:00
|
|
|
var e = eventCaller.currentEntity;
|
|
|
|
MeatGrinder.instance.Bop(e.beat, e.length, e["bop"], e["bossBop"]);
|
2023-02-23 00:25:14 +00:00
|
|
|
},
|
|
|
|
parameters = new List<Param>()
|
|
|
|
{
|
2023-03-07 17:22:32 +00:00
|
|
|
new Param("bop", true, "Boss Bops?", "Does Boss bop?"),
|
|
|
|
new Param("bossBop", false, "Boss Bops? (Auto)", "Does Boss Auto bop?"),
|
2023-02-23 00:25:14 +00:00
|
|
|
},
|
2023-03-07 17:22:32 +00:00
|
|
|
resizable = true,
|
2023-06-04 04:30:42 +00:00
|
|
|
priority = 1,
|
2023-02-23 00:25:14 +00:00
|
|
|
},
|
2023-05-28 17:34:44 +00:00
|
|
|
},
|
2023-10-29 19:44:47 +00:00
|
|
|
new List<string>() { "pco", "normal", "repeat" },
|
2023-05-28 17:34:44 +00:00
|
|
|
"pcomeat", "en",
|
2023-10-29 19:44:47 +00:00
|
|
|
new List<string>() { }
|
2023-05-28 17:34:44 +00:00
|
|
|
);
|
2023-02-23 00:25:14 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
namespace HeavenStudio.Games
|
|
|
|
{
|
|
|
|
using Scripts_MeatGrinder;
|
|
|
|
public class MeatGrinder : Minigame
|
|
|
|
{
|
2023-06-10 19:17:06 +00:00
|
|
|
static List<double> queuedInputs = new();
|
2023-05-07 04:45:44 +00:00
|
|
|
static List<QueuedInterval> queuedIntervals = new List<QueuedInterval>();
|
|
|
|
struct QueuedInterval
|
|
|
|
{
|
2023-06-10 19:17:06 +00:00
|
|
|
public double beat;
|
2023-06-10 20:55:10 +00:00
|
|
|
public double length;
|
2023-05-07 04:45:44 +00:00
|
|
|
}
|
2023-02-23 00:25:14 +00:00
|
|
|
|
|
|
|
[Header("Objects")]
|
|
|
|
public GameObject MeatBase;
|
|
|
|
|
|
|
|
[Header("Animators")]
|
|
|
|
public Animator BossAnim;
|
|
|
|
public Animator TackAnim;
|
|
|
|
|
|
|
|
[Header("Variables")]
|
|
|
|
bool intervalStarted;
|
2023-06-10 19:17:06 +00:00
|
|
|
double intervalStartBeat;
|
2023-06-10 20:55:10 +00:00
|
|
|
public double beatInterval = 4f;
|
2023-02-23 00:25:14 +00:00
|
|
|
public bool bossAnnoyed = false;
|
|
|
|
const string sfxName = "meatGrinder/";
|
|
|
|
|
|
|
|
public static MeatGrinder instance;
|
|
|
|
|
|
|
|
public enum MeatType
|
|
|
|
{
|
|
|
|
Dark,
|
|
|
|
Light,
|
|
|
|
}
|
2023-10-29 19:44:47 +00:00
|
|
|
|
|
|
|
protected static bool IA_PadAny(out double dt)
|
|
|
|
{
|
|
|
|
return PlayerInput.GetPadDown(InputController.ActionsPad.East, out dt)
|
|
|
|
|| PlayerInput.GetPadDown(InputController.ActionsPad.Up, out dt)
|
|
|
|
|| PlayerInput.GetPadDown(InputController.ActionsPad.Down, out dt)
|
|
|
|
|| PlayerInput.GetPadDown(InputController.ActionsPad.Left, out dt)
|
|
|
|
|| PlayerInput.GetPadDown(InputController.ActionsPad.Right, out dt);
|
|
|
|
}
|
|
|
|
|
|
|
|
public static PlayerInput.InputAction InputAction_Press =
|
|
|
|
new("PcoMeatPress", new int[] { IAPressCat, IAFlickCat, IAPressCat },
|
|
|
|
IA_PadAny, IA_TouchBasicPress, IA_BatonBasicPress);
|
|
|
|
|
2023-02-23 00:25:14 +00:00
|
|
|
private void Awake()
|
|
|
|
{
|
|
|
|
instance = this;
|
2023-12-05 22:38:52 +00:00
|
|
|
SetupBopRegion("meatGrinder", "bop", "bossBop");
|
2023-02-23 00:25:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void OnDestroy()
|
|
|
|
{
|
2023-10-29 19:44:47 +00:00
|
|
|
if (!Conductor.instance.isPlaying || Conductor.instance.isPaused)
|
|
|
|
{
|
2023-02-23 00:25:14 +00:00
|
|
|
if (queuedInputs.Count > 0) queuedInputs.Clear();
|
2023-05-07 04:45:44 +00:00
|
|
|
if (queuedIntervals.Count > 0) queuedIntervals.Clear();
|
|
|
|
intervalStarted = false;
|
2023-06-04 04:30:42 +00:00
|
|
|
beatInterval = 4f;
|
2023-02-23 00:25:14 +00:00
|
|
|
}
|
2023-06-10 19:18:45 +00:00
|
|
|
foreach (var evt in scheduledInputs) evt.Disable();
|
2023-02-23 00:25:14 +00:00
|
|
|
}
|
|
|
|
|
2023-10-29 19:44:47 +00:00
|
|
|
private void Update()
|
2023-02-23 00:25:14 +00:00
|
|
|
{
|
2023-10-29 19:44:47 +00:00
|
|
|
if (PlayerInput.GetIsAction(InputAction_Press) && !IsExpectingInputNow(InputAction_Press))
|
|
|
|
{
|
2023-02-23 00:25:14 +00:00
|
|
|
TackAnim.DoScaledAnimationAsync("TackEmptyHit", 0.5f);
|
|
|
|
TackAnim.SetBool("tackMeated", false);
|
2023-10-29 19:44:47 +00:00
|
|
|
SoundByte.PlayOneShotGame(sfxName + "whiff");
|
2023-06-10 20:55:10 +00:00
|
|
|
bossAnnoyed = false;
|
2023-02-23 00:25:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (bossAnnoyed) BossAnim.SetBool("bossAnnoyed", true);
|
2023-05-07 04:45:44 +00:00
|
|
|
|
2023-10-29 19:44:47 +00:00
|
|
|
if (queuedIntervals.Count > 0)
|
|
|
|
{
|
2023-06-10 19:18:45 +00:00
|
|
|
foreach (var interval in queuedIntervals) StartInterval(interval.beat, interval.length);
|
2023-05-07 04:45:44 +00:00
|
|
|
queuedIntervals.Clear();
|
|
|
|
}
|
2023-02-23 00:25:14 +00:00
|
|
|
}
|
|
|
|
|
2023-11-23 16:19:39 +00:00
|
|
|
public override void OnBeatPulse(double beat)
|
2023-02-23 00:25:14 +00:00
|
|
|
{
|
2023-12-06 01:59:36 +00:00
|
|
|
if (!BossAnim.IsPlayingAnimationNames("BossCall")
|
|
|
|
&& !BossAnim.IsPlayingAnimationNames("BossSignal")
|
2023-12-05 22:38:52 +00:00
|
|
|
&& BeatIsInBopRegion(beat))
|
2023-02-23 00:25:14 +00:00
|
|
|
{
|
|
|
|
BossAnim.DoScaledAnimationAsync(bossAnnoyed ? "BossMiss" : "Bop", 0.5f);
|
2023-06-04 04:30:42 +00:00
|
|
|
}
|
2023-02-23 00:25:14 +00:00
|
|
|
}
|
|
|
|
|
2023-06-10 20:55:10 +00:00
|
|
|
public void Bop(double beat, double length, bool doesBop, bool autoBop)
|
2023-02-23 00:25:14 +00:00
|
|
|
{
|
2023-10-29 19:44:47 +00:00
|
|
|
if (doesBop)
|
|
|
|
{
|
|
|
|
for (int i = 0; i < length; i++)
|
|
|
|
{
|
2023-09-11 22:28:04 +00:00
|
|
|
BeatAction.New(instance, new List<BeatAction.Action>() {
|
2023-06-04 04:30:42 +00:00
|
|
|
new BeatAction.Action(beat + i, delegate {
|
2023-12-06 01:59:36 +00:00
|
|
|
if (!BossAnim.IsPlayingAnimationNames("BossCall") && !BossAnim.IsPlayingAnimationNames("BossSignal")) {
|
2023-03-07 17:22:32 +00:00
|
|
|
BossAnim.DoScaledAnimationAsync(bossAnnoyed ? "BossMiss" : "Bop", 0.5f);
|
2023-06-04 04:30:42 +00:00
|
|
|
}
|
2023-03-07 17:22:32 +00:00
|
|
|
})
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
2023-02-23 00:25:14 +00:00
|
|
|
}
|
|
|
|
|
2023-06-10 20:55:10 +00:00
|
|
|
public static void PreInterval(double beat, double length)
|
2023-02-23 00:25:14 +00:00
|
|
|
{
|
2023-05-07 04:45:44 +00:00
|
|
|
if (MeatGrinder.instance.intervalStarted || MeatGrinder.queuedIntervals.Count > 0) return;
|
2023-02-23 00:25:14 +00:00
|
|
|
|
2023-10-29 19:44:47 +00:00
|
|
|
MeatGrinder.queuedIntervals.Add(new QueuedInterval()
|
|
|
|
{
|
2023-05-07 04:45:44 +00:00
|
|
|
beat = beat,
|
|
|
|
length = length,
|
|
|
|
});
|
2023-02-23 00:25:14 +00:00
|
|
|
|
2023-06-10 20:55:10 +00:00
|
|
|
SoundByte.PlayOneShotGame("meatGrinder/startSignal", beat - 1, forcePlay: true);
|
2023-05-07 04:45:44 +00:00
|
|
|
|
2023-10-29 19:44:47 +00:00
|
|
|
if (GameManager.instance.currentGame == "meatGrinder")
|
|
|
|
{
|
2023-09-11 22:28:04 +00:00
|
|
|
BeatAction.New(MeatGrinder.instance, new List<BeatAction.Action>() {
|
2023-10-29 19:44:47 +00:00
|
|
|
new BeatAction.Action(beat - 1, delegate {
|
2023-05-07 04:45:44 +00:00
|
|
|
MeatGrinder.instance.BossAnim.DoScaledAnimationAsync("BossSignal", 0.5f);
|
|
|
|
}),
|
2023-10-29 19:44:47 +00:00
|
|
|
});
|
2023-05-07 04:45:44 +00:00
|
|
|
}
|
2023-02-23 00:25:14 +00:00
|
|
|
}
|
|
|
|
|
2023-06-10 20:55:10 +00:00
|
|
|
public void StartInterval(double beat, double length)
|
2023-02-23 00:25:14 +00:00
|
|
|
{
|
2023-05-07 04:45:44 +00:00
|
|
|
if (MeatGrinder.instance.intervalStarted) return;
|
|
|
|
|
2023-02-23 00:25:14 +00:00
|
|
|
intervalStartBeat = beat;
|
2023-05-07 04:45:44 +00:00
|
|
|
intervalStarted = true;
|
|
|
|
beatInterval = length;
|
2023-02-23 00:25:14 +00:00
|
|
|
|
2023-09-11 22:28:04 +00:00
|
|
|
BeatAction.New(this, new List<BeatAction.Action>() {
|
2023-05-07 04:45:44 +00:00
|
|
|
new BeatAction.Action(beat + length - 0.33f, delegate { PassTurn(beat); }),
|
2023-02-23 00:25:14 +00:00
|
|
|
});
|
|
|
|
}
|
2023-10-29 19:44:47 +00:00
|
|
|
|
2023-06-10 19:17:06 +00:00
|
|
|
public void MeatToss(double beat)
|
2023-02-23 00:25:14 +00:00
|
|
|
{
|
2023-10-29 19:44:47 +00:00
|
|
|
SoundByte.PlayOneShotGame(sfxName + "toss");
|
|
|
|
|
2023-05-07 04:45:44 +00:00
|
|
|
MeatToss Meat = Instantiate(MeatBase, gameObject.transform).GetComponent<MeatToss>();
|
2023-02-23 00:25:14 +00:00
|
|
|
Meat.startBeat = beat;
|
|
|
|
Meat.cueLength = 1f;
|
|
|
|
Meat.cueBased = true;
|
|
|
|
Meat.meatType = "DarkMeat";
|
|
|
|
}
|
|
|
|
|
2023-10-29 19:44:47 +00:00
|
|
|
public void MeatCall(double beat)
|
2023-02-23 00:25:14 +00:00
|
|
|
{
|
|
|
|
BossAnim.DoScaledAnimationAsync("BossCall", 0.5f);
|
2023-10-29 19:44:47 +00:00
|
|
|
SoundByte.PlayOneShotGame(sfxName + "signal");
|
|
|
|
|
2023-06-04 04:30:42 +00:00
|
|
|
StartInterval(beat, beatInterval);
|
2023-02-23 00:25:14 +00:00
|
|
|
|
2023-03-18 04:40:20 +00:00
|
|
|
queuedInputs.Add(beat - intervalStartBeat);
|
2023-02-23 00:25:14 +00:00
|
|
|
}
|
|
|
|
|
2023-06-10 19:17:06 +00:00
|
|
|
public void PassTurn(double beat)
|
2023-02-23 00:25:14 +00:00
|
|
|
{
|
|
|
|
intervalStarted = false;
|
|
|
|
foreach (var input in queuedInputs)
|
|
|
|
{
|
2023-09-11 22:28:04 +00:00
|
|
|
BeatAction.New(instance, new List<BeatAction.Action>()
|
2023-02-23 00:25:14 +00:00
|
|
|
{
|
2023-10-29 19:44:47 +00:00
|
|
|
new BeatAction.Action(input + beatInterval , delegate {
|
2023-05-07 04:45:44 +00:00
|
|
|
MeatToss Meat = Instantiate(MeatBase, gameObject.transform).GetComponent<MeatToss>();
|
2023-02-23 00:25:14 +00:00
|
|
|
Meat.startBeat = beat;
|
2023-03-18 04:40:20 +00:00
|
|
|
Meat.cueLength = beatInterval + input;
|
2023-02-23 00:25:14 +00:00
|
|
|
Meat.cueBased = false;
|
|
|
|
Meat.meatType = "LightMeat";
|
|
|
|
}),
|
|
|
|
});
|
2023-10-29 19:44:47 +00:00
|
|
|
|
2023-02-23 00:25:14 +00:00
|
|
|
}
|
|
|
|
queuedInputs.Clear();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|