2023-01-19 17:18:55 +00:00
|
|
|
using HeavenStudio.Util;
|
2023-10-29 19:44:47 +00:00
|
|
|
using HeavenStudio.InputSystem;
|
2023-01-19 17:18:55 +00:00
|
|
|
using System;
|
|
|
|
using System.Collections.Generic;
|
|
|
|
using UnityEngine;
|
|
|
|
|
|
|
|
namespace HeavenStudio.Games.Loaders
|
|
|
|
{
|
|
|
|
using static Minigames;
|
|
|
|
public static class RvlWorkingDoughLoader
|
|
|
|
{
|
|
|
|
public static Minigame AddGame(EventCaller eventCaller)
|
|
|
|
{
|
2023-04-02 02:28:23 +00:00
|
|
|
return new Minigame("workingDough", "Working Dough", "000000", false, false, new List<GameAction>()
|
2023-01-19 17:18:55 +00:00
|
|
|
{
|
|
|
|
new GameAction("beat intervals", "Start Interval")
|
|
|
|
{
|
2023-06-28 04:51:53 +00:00
|
|
|
preFunction = delegate { var e = eventCaller.currentEntity; WorkingDough.PreSetIntervalStart(e.beat, e.length, e["auto"]); },
|
2023-01-20 15:48:30 +00:00
|
|
|
defaultLength = 8f,
|
2023-01-19 17:18:55 +00:00
|
|
|
resizable = true,
|
2023-06-28 04:51:53 +00:00
|
|
|
parameters = new List<Param>()
|
|
|
|
{
|
2024-01-15 02:04:10 +00:00
|
|
|
new Param("auto", true, "Auto Pass Turn", "Toggle if the turn should be passed automatically at the end of the start interval.")
|
2023-06-28 04:51:53 +00:00
|
|
|
}
|
2023-01-19 17:18:55 +00:00
|
|
|
},
|
|
|
|
new GameAction("small ball", "Small Ball")
|
|
|
|
{
|
|
|
|
defaultLength = 0.5f,
|
2023-06-13 22:47:52 +00:00
|
|
|
priority = 1,
|
2023-01-19 17:18:55 +00:00
|
|
|
},
|
|
|
|
new GameAction("big ball", "Big Ball")
|
|
|
|
{
|
|
|
|
defaultLength = 0.5f,
|
2023-06-13 22:47:52 +00:00
|
|
|
priority = 1,
|
|
|
|
parameters = new List<Param>()
|
|
|
|
{
|
2024-01-15 02:04:10 +00:00
|
|
|
new Param("hasGandw", false, "Mr. Game & Watch", "Toggle if Mr. Game & Watch should be riding on the ball.")
|
2023-06-13 22:47:52 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
new GameAction("passTurn", "Pass Turn")
|
|
|
|
{
|
|
|
|
preFunction = delegate { WorkingDough.PrePassTurn(eventCaller.currentEntity.beat); },
|
|
|
|
preFunctionLength = 1
|
2023-01-19 17:18:55 +00:00
|
|
|
},
|
2024-01-15 02:04:10 +00:00
|
|
|
new GameAction("rise spaceship", "Rise Up Spaceship")
|
2023-01-19 17:18:55 +00:00
|
|
|
{
|
2024-01-15 02:04:10 +00:00
|
|
|
function = delegate { var e = eventCaller.currentEntity; WorkingDough.instance.RiseUpShip(e.beat, e.length); },
|
2023-01-19 17:18:55 +00:00
|
|
|
defaultLength = 4f,
|
2023-01-20 15:48:30 +00:00
|
|
|
resizable = true,
|
2023-01-22 19:22:39 +00:00
|
|
|
priority = 0
|
2023-01-19 17:18:55 +00:00
|
|
|
},
|
2024-01-15 02:04:10 +00:00
|
|
|
new GameAction("launch spaceship", "Launch Spaceship")
|
2023-01-19 17:18:55 +00:00
|
|
|
{
|
2024-01-15 02:04:10 +00:00
|
|
|
function = delegate { var e = eventCaller.currentEntity; WorkingDough.instance.LaunchShip(e.beat, e.length); },
|
2023-01-19 17:18:55 +00:00
|
|
|
defaultLength = 4f,
|
2023-01-20 15:48:30 +00:00
|
|
|
resizable = true,
|
2023-01-22 19:22:39 +00:00
|
|
|
priority = 0
|
2023-01-19 17:18:55 +00:00
|
|
|
},
|
|
|
|
new GameAction("lift dough dudes", "Lift Dough Dudes")
|
|
|
|
{
|
|
|
|
function = delegate { var e = eventCaller.currentEntity; WorkingDough.instance.Elevate(e.beat, e.length, e["toggle"]); },
|
|
|
|
defaultLength = 4f,
|
|
|
|
parameters = new List<Param>()
|
|
|
|
{
|
2024-01-15 02:04:10 +00:00
|
|
|
new Param("toggle", false, "Up", "Toggle if the dough dudes should go up or down.")
|
2023-01-19 17:18:55 +00:00
|
|
|
},
|
2023-01-20 15:48:30 +00:00
|
|
|
resizable = true,
|
2023-01-22 19:22:39 +00:00
|
|
|
priority = 0
|
2023-01-19 17:18:55 +00:00
|
|
|
},
|
|
|
|
new GameAction("instant lift", "Instant Lift")
|
|
|
|
{
|
|
|
|
function = delegate { var e = eventCaller.currentEntity; WorkingDough.instance.InstantElevation(e["toggle"]); },
|
|
|
|
parameters = new List<Param>()
|
|
|
|
{
|
2024-01-15 02:04:10 +00:00
|
|
|
new Param("toggle", true, "Up", "Toggle if the dough dudes should go up or down.")
|
2023-01-19 17:18:55 +00:00
|
|
|
},
|
|
|
|
defaultLength = 0.5f,
|
2023-01-22 19:22:39 +00:00
|
|
|
priority = 0
|
2023-01-19 17:18:55 +00:00
|
|
|
},
|
|
|
|
new GameAction("mr game and watch enter or exit", "Mr. G&W Enter or Exit")
|
|
|
|
{
|
|
|
|
function = delegate { var e = eventCaller.currentEntity; WorkingDough.instance.GANDWEnterOrExit(e.beat, e.length, e["toggle"]); },
|
|
|
|
defaultLength = 4f,
|
|
|
|
parameters = new List<Param>()
|
|
|
|
{
|
2024-01-15 02:04:10 +00:00
|
|
|
new Param("toggle", false, "Exit", "Toggle if Mr. Game & Watch should exit or enter the scene.")
|
2023-01-19 17:18:55 +00:00
|
|
|
},
|
2023-01-20 15:48:30 +00:00
|
|
|
resizable = true,
|
2023-01-22 19:22:39 +00:00
|
|
|
priority = 0
|
2023-01-19 17:18:55 +00:00
|
|
|
},
|
|
|
|
new GameAction("instant game and watch", "Instant Mr. G&W Enter or Exit")
|
|
|
|
{
|
|
|
|
function = delegate { var e = eventCaller.currentEntity; WorkingDough.instance.InstantGANDWEnterOrExit(e["toggle"]); },
|
|
|
|
parameters = new List<Param>()
|
|
|
|
{
|
2024-01-15 02:04:10 +00:00
|
|
|
new Param("toggle", false, "Exit", "Toggle if Mr. Game & Watch should exit or enter the scene.")
|
2023-01-19 17:18:55 +00:00
|
|
|
},
|
|
|
|
defaultLength = 0.5f,
|
2023-01-22 19:22:39 +00:00
|
|
|
priority = 0
|
2023-01-19 17:18:55 +00:00
|
|
|
},
|
2023-06-13 22:47:52 +00:00
|
|
|
new GameAction("disableBG", "Toggle Background")
|
|
|
|
{
|
2023-06-28 04:51:53 +00:00
|
|
|
function = delegate { WorkingDough.instance.DisableBG(eventCaller.currentEntity["ship"]); },
|
|
|
|
defaultLength = 0.5f,
|
|
|
|
parameters = new List<Param>()
|
|
|
|
{
|
2024-01-15 02:04:10 +00:00
|
|
|
new Param("ship", false, "Spaceship Only", "Toggle if the only the spaceship should be toggled.")
|
2023-06-28 04:51:53 +00:00
|
|
|
}
|
2023-06-13 22:47:52 +00:00
|
|
|
}
|
2023-05-28 17:34:44 +00:00
|
|
|
},
|
|
|
|
new List<string>() {"rvl", "repeat"},
|
|
|
|
"rvldough", "en",
|
2024-03-29 02:35:07 +00:00
|
|
|
new List<string>() {},
|
|
|
|
chronologicalSortKey: 11
|
2023-05-28 17:34:44 +00:00
|
|
|
);
|
2023-01-19 17:18:55 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
namespace HeavenStudio.Games
|
|
|
|
{
|
2023-06-28 04:51:53 +00:00
|
|
|
using Jukebox;
|
2023-01-19 17:18:55 +00:00
|
|
|
using Scripts_WorkingDough;
|
2023-06-13 22:47:52 +00:00
|
|
|
|
2023-01-19 17:18:55 +00:00
|
|
|
public class WorkingDough : Minigame
|
|
|
|
{
|
|
|
|
[Header("Components")]
|
|
|
|
[SerializeField] GameObject doughDudesNPC; //Jump animations
|
|
|
|
public GameObject doughDudesPlayer; //Jump animations
|
|
|
|
[SerializeField] GameObject ballTransporterRightNPC; //Close and open animations
|
|
|
|
[SerializeField] GameObject ballTransporterLeftNPC; //Close and open animations
|
|
|
|
[SerializeField] GameObject ballTransporterRightPlayer; //Close and open animations
|
|
|
|
[SerializeField] GameObject ballTransporterLeftPlayer; //Close and open animations
|
|
|
|
[SerializeField] GameObject npcImpact;
|
2023-06-13 22:47:52 +00:00
|
|
|
public GameObject playerImpact;
|
2023-01-19 17:18:55 +00:00
|
|
|
[SerializeField] GameObject smallBallNPC;
|
|
|
|
[SerializeField] GameObject bigBallNPC;
|
|
|
|
[SerializeField] Transform ballHolder;
|
|
|
|
[SerializeField] SpriteRenderer arrowSRLeftNPC;
|
|
|
|
[SerializeField] SpriteRenderer arrowSRRightNPC;
|
|
|
|
[SerializeField] SpriteRenderer arrowSRLeftPlayer;
|
2023-06-13 22:47:52 +00:00
|
|
|
public SpriteRenderer arrowSRRightPlayer;
|
2023-01-19 17:18:55 +00:00
|
|
|
[SerializeField] GameObject NPCBallTransporters;
|
|
|
|
[SerializeField] GameObject PlayerBallTransporters;
|
|
|
|
[SerializeField] GameObject playerEnterSmallBall;
|
|
|
|
[SerializeField] GameObject playerEnterBigBall;
|
2023-06-13 22:47:52 +00:00
|
|
|
public GameObject missImpact;
|
|
|
|
public Transform breakParticleHolder;
|
|
|
|
public GameObject breakParticleEffect;
|
|
|
|
public Animator backgroundAnimator;
|
2023-01-19 17:18:55 +00:00
|
|
|
[SerializeField] Animator conveyerAnimator;
|
|
|
|
[SerializeField] GameObject smallBGBall;
|
|
|
|
[SerializeField] GameObject bigBGBall;
|
|
|
|
[SerializeField] Animator spaceshipAnimator;
|
|
|
|
[SerializeField] GameObject spaceshipLights;
|
|
|
|
[SerializeField] Animator doughDudesHolderAnim;
|
|
|
|
[SerializeField] Animator gandwAnim;
|
|
|
|
|
2023-06-13 22:47:52 +00:00
|
|
|
[SerializeField] private GameObject[] bgObjects;
|
2023-06-28 04:51:53 +00:00
|
|
|
[SerializeField] private GameObject shipObject;
|
2023-06-13 22:47:52 +00:00
|
|
|
private bool bgDisabled;
|
|
|
|
|
2023-01-19 17:18:55 +00:00
|
|
|
[Header("Variables")]
|
|
|
|
float risingLength = 4f;
|
2023-06-10 19:17:06 +00:00
|
|
|
double risingStartBeat;
|
2023-01-19 17:18:55 +00:00
|
|
|
float liftingLength = 4f;
|
2023-06-10 19:17:06 +00:00
|
|
|
double liftingStartBeat;
|
2023-01-19 17:18:55 +00:00
|
|
|
float gandMovingLength = 4f;
|
2023-06-10 19:17:06 +00:00
|
|
|
double gandMovingStartBeat;
|
2023-01-19 17:18:55 +00:00
|
|
|
public bool bigMode;
|
|
|
|
public bool bigModePlayer;
|
2023-06-13 22:47:52 +00:00
|
|
|
static List<double> passedTurns = new List<double>();
|
2023-01-19 17:18:55 +00:00
|
|
|
public bool spaceshipRisen = false;
|
|
|
|
public bool spaceshipRising = false;
|
|
|
|
bool liftingDoughDudes;
|
|
|
|
string liftingAnimName;
|
2023-01-20 15:48:30 +00:00
|
|
|
bool gandwHasEntered = true;
|
2023-01-19 17:18:55 +00:00
|
|
|
bool gandwMoving;
|
|
|
|
string gandwMovingAnimName;
|
|
|
|
|
|
|
|
[Header("Curves")]
|
2023-06-13 22:47:52 +00:00
|
|
|
[SerializeField] SuperCurveObject.Path[] ballBouncePaths;
|
|
|
|
new void OnDrawGizmos()
|
|
|
|
{
|
|
|
|
base.OnDrawGizmos();
|
|
|
|
foreach (SuperCurveObject.Path path in ballBouncePaths)
|
|
|
|
{
|
|
|
|
if (path.preview)
|
|
|
|
{
|
|
|
|
smallBallNPC.GetComponent<NPCDoughBall>().DrawEditorGizmo(path);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
public SuperCurveObject.Path GetPath(string name)
|
|
|
|
{
|
|
|
|
foreach (SuperCurveObject.Path path in ballBouncePaths)
|
|
|
|
{
|
|
|
|
if (path.name == name)
|
|
|
|
{
|
|
|
|
return path;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return default(SuperCurveObject.Path);
|
|
|
|
}
|
2023-01-19 17:18:55 +00:00
|
|
|
|
|
|
|
[Header("Resources")]
|
|
|
|
public Sprite whiteArrowSprite;
|
|
|
|
public Sprite redArrowSprite;
|
|
|
|
|
|
|
|
public static WorkingDough instance;
|
|
|
|
|
2023-10-29 19:44:47 +00:00
|
|
|
const int IA_AltPress = IAMAXCAT;
|
|
|
|
protected static bool IA_TouchNrmPress(out double dt)
|
|
|
|
{
|
|
|
|
return PlayerInput.GetTouchDown(InputController.ActionsTouch.Tap, out dt)
|
|
|
|
&& !instance.IsExpectingInputNow(InputAction_Alt);
|
|
|
|
}
|
|
|
|
|
|
|
|
protected static bool IA_PadAltPress(out double dt)
|
|
|
|
{
|
|
|
|
return PlayerInput.GetPadDown(InputController.ActionsPad.South, out dt);
|
|
|
|
}
|
|
|
|
protected static bool IA_BatonAltPress(out double dt)
|
|
|
|
{
|
|
|
|
return PlayerInput.GetSqueezeDown(out dt);
|
|
|
|
}
|
|
|
|
protected static bool IA_TouchAltPress(out double dt)
|
|
|
|
{
|
|
|
|
return PlayerInput.GetTouchDown(InputController.ActionsTouch.Tap, out dt)
|
|
|
|
&& instance.IsExpectingInputNow(InputAction_Alt);
|
|
|
|
}
|
|
|
|
|
|
|
|
public static PlayerInput.InputAction InputAction_Nrm =
|
|
|
|
new("RvlDoughAlt", new int[] { IAPressCat, IAPressCat, IAPressCat },
|
|
|
|
IA_PadBasicPress, IA_TouchNrmPress, IA_BatonBasicPress);
|
|
|
|
public static PlayerInput.InputAction InputAction_Alt =
|
|
|
|
new("RvlDoughAlt", new int[] { IA_AltPress, IA_AltPress, IA_AltPress },
|
|
|
|
IA_PadAltPress, IA_TouchAltPress, IA_BatonAltPress);
|
|
|
|
|
2023-01-19 17:18:55 +00:00
|
|
|
void Awake()
|
|
|
|
{
|
|
|
|
instance = this;
|
|
|
|
}
|
|
|
|
|
|
|
|
void Start()
|
|
|
|
{
|
|
|
|
conveyerAnimator.Play("ConveyerBelt", 0, 0);
|
|
|
|
doughDudesHolderAnim.Play("OnGround", 0, 0);
|
|
|
|
}
|
|
|
|
|
2023-06-28 04:51:53 +00:00
|
|
|
private bool shipOnly;
|
|
|
|
|
|
|
|
public void DisableBG(bool ship)
|
2023-06-13 22:47:52 +00:00
|
|
|
{
|
2023-06-28 04:51:53 +00:00
|
|
|
shipOnly = ship;
|
2023-06-13 22:47:52 +00:00
|
|
|
bgDisabled = !bgDisabled;
|
|
|
|
foreach (var bgObject in bgObjects)
|
|
|
|
{
|
2023-06-28 04:51:53 +00:00
|
|
|
bgObject.SetActive(!bgDisabled || shipOnly);
|
2023-06-13 22:47:52 +00:00
|
|
|
}
|
2023-06-28 04:51:53 +00:00
|
|
|
shipObject.SetActive(!bgDisabled && !shipOnly);
|
2023-06-13 22:47:52 +00:00
|
|
|
}
|
|
|
|
|
2023-07-12 16:49:32 +00:00
|
|
|
private List<RiqEntity> GetAllBallsInBetweenBeat(double beat, double endBeat)
|
2023-01-19 17:18:55 +00:00
|
|
|
{
|
2023-06-28 04:51:53 +00:00
|
|
|
List<RiqEntity> ballEvents = EventCaller.GetAllInGameManagerList("workingDough", new string[] { "small ball", "big ball" });
|
2024-01-15 19:22:26 +00:00
|
|
|
List<RiqEntity> tempEvents = ballEvents.FindAll(x => x.beat >= beat && x.beat < endBeat);
|
|
|
|
tempEvents.Sort((x, y) => x.beat.CompareTo(y.beat));
|
2023-06-28 04:51:53 +00:00
|
|
|
return tempEvents;
|
|
|
|
}
|
|
|
|
|
2023-07-12 16:49:32 +00:00
|
|
|
private RiqEntity GetLastIntervalBeforeBeat(double beat)
|
|
|
|
{
|
|
|
|
List<RiqEntity> intervalEvents = EventCaller.GetAllInGameManagerList("workingDough", new string[] { "beat intervals" });
|
|
|
|
if (intervalEvents.Count == 0) return null;
|
|
|
|
var tempEvents = intervalEvents.FindAll(x => x.beat <= beat);
|
|
|
|
tempEvents.Sort((x, y) => x.beat.CompareTo(y.beat));
|
|
|
|
return tempEvents[^1];
|
|
|
|
}
|
|
|
|
|
2023-06-28 04:51:53 +00:00
|
|
|
public void SetIntervalStart(double beat, double gameSwitchBeat, float interval = 8f, bool autoPassTurn = true)
|
|
|
|
{
|
|
|
|
List<RiqEntity> relevantBalls = GetAllBallsInBetweenBeat(beat, beat + interval);
|
|
|
|
bool hasBigBall = false;
|
|
|
|
foreach (var ball in relevantBalls)
|
|
|
|
{
|
|
|
|
bool isBig = ball.datamodel == "workingDough/big ball";
|
|
|
|
if (ball.beat >= gameSwitchBeat)
|
|
|
|
{
|
|
|
|
SpawnBall(ball.beat - 1, isBig, isBig && ball["hasGandw"]);
|
2023-07-12 16:49:32 +00:00
|
|
|
OnSpawnBall(ball.beat, isBig);
|
2023-06-28 04:51:53 +00:00
|
|
|
}
|
|
|
|
if (isBig) hasBigBall = true;
|
|
|
|
}
|
|
|
|
if (autoPassTurn)
|
|
|
|
{
|
2023-07-12 16:49:32 +00:00
|
|
|
PassTurn(beat + interval, interval, beat);
|
2023-06-28 04:51:53 +00:00
|
|
|
}
|
2023-09-11 22:28:04 +00:00
|
|
|
BeatAction.New(instance, new List<BeatAction.Action>()
|
2023-06-28 04:51:53 +00:00
|
|
|
{
|
|
|
|
new BeatAction.Action(beat - 1, delegate
|
|
|
|
{
|
|
|
|
bigMode = hasBigBall;
|
|
|
|
if (bigMode)
|
|
|
|
{
|
|
|
|
NPCBallTransporters.GetComponent<Animator>().Play("NPCGoBigMode", 0, 0);
|
|
|
|
}
|
2023-12-06 01:59:36 +00:00
|
|
|
if (!instance.ballTransporterLeftNPC.GetComponent<Animator>().IsPlayingAnimationNames("BallTransporterLeftOpened"))
|
2023-06-28 04:51:53 +00:00
|
|
|
{
|
|
|
|
instance.ballTransporterLeftNPC.GetComponent<Animator>().Play("BallTransporterLeftOpen", 0, 0);
|
|
|
|
instance.ballTransporterRightNPC.GetComponent<Animator>().Play("BallTransporterRightOpen", 0, 0);
|
|
|
|
if (instance.gandwHasEntered && !bgDisabled) instance.gandwAnim.Play("GANDWLeverUp", 0, 0);
|
|
|
|
}
|
|
|
|
}),
|
|
|
|
});
|
2023-01-19 17:18:55 +00:00
|
|
|
}
|
|
|
|
|
2023-06-13 22:47:52 +00:00
|
|
|
public static void PrePassTurn(double beat)
|
2023-01-19 17:18:55 +00:00
|
|
|
{
|
2023-06-13 22:47:52 +00:00
|
|
|
if (GameManager.instance.currentGame == "workingDough")
|
2023-01-19 17:18:55 +00:00
|
|
|
{
|
2023-06-28 04:51:53 +00:00
|
|
|
instance.PassTurnStandalone(beat);
|
2023-06-13 22:47:52 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
passedTurns.Add(beat);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-06-28 04:51:53 +00:00
|
|
|
private void PassTurnStandalone(double beat)
|
2023-06-13 22:47:52 +00:00
|
|
|
{
|
2023-07-12 16:49:32 +00:00
|
|
|
RiqEntity lastInterval = GetLastIntervalBeforeBeat(beat);
|
|
|
|
if (lastInterval == null) return;
|
|
|
|
PassTurn(beat, lastInterval.length, lastInterval.beat);
|
2023-06-28 04:51:53 +00:00
|
|
|
}
|
|
|
|
|
2023-07-12 16:49:32 +00:00
|
|
|
private void PassTurn(double beat, double length, double startBeat)
|
2023-06-28 04:51:53 +00:00
|
|
|
{
|
2023-09-11 22:28:04 +00:00
|
|
|
BeatAction.New(instance, new List<BeatAction.Action>()
|
2023-06-13 22:47:52 +00:00
|
|
|
{
|
2023-06-28 04:51:53 +00:00
|
|
|
new BeatAction.Action(beat - 1, delegate
|
2023-06-13 22:47:52 +00:00
|
|
|
{
|
2023-06-28 04:51:53 +00:00
|
|
|
ballTransporterRightPlayer.GetComponent<Animator>().Play("BallTransporterRightOpen", 0, 0);
|
|
|
|
ballTransporterLeftPlayer.GetComponent<Animator>().Play("BallTransporterLeftOpen", 0, 0);
|
2023-07-12 16:49:32 +00:00
|
|
|
var relevantBallEvents = GetAllBallsInBetweenBeat(startBeat, startBeat + length);
|
|
|
|
if (relevantBallEvents.Count > 0)
|
2023-06-13 22:47:52 +00:00
|
|
|
{
|
2023-06-28 04:51:53 +00:00
|
|
|
bool hasBig = false;
|
2023-07-12 16:49:32 +00:00
|
|
|
foreach (var ball in relevantBallEvents)
|
2023-06-13 22:47:52 +00:00
|
|
|
{
|
2023-07-12 16:49:32 +00:00
|
|
|
double relativeBeat = ball.beat - startBeat;
|
|
|
|
bool isBig = ball.datamodel == "workingDough/big ball";
|
|
|
|
SpawnPlayerBall(beat + relativeBeat - 1, isBig, isBig ? ball["hasGandw"] : false);
|
|
|
|
if (isBig) hasBig = true;
|
2023-06-13 22:47:52 +00:00
|
|
|
}
|
2023-06-28 04:51:53 +00:00
|
|
|
bigModePlayer = hasBig;
|
2023-06-13 22:47:52 +00:00
|
|
|
if (bigModePlayer)
|
|
|
|
{
|
2023-06-28 04:51:53 +00:00
|
|
|
PlayerBallTransporters.GetComponent<Animator>().Play("PlayerGoBigMode", 0, 0);
|
2023-06-13 22:47:52 +00:00
|
|
|
}
|
2023-06-28 04:51:53 +00:00
|
|
|
}
|
|
|
|
}),
|
2024-01-09 16:55:00 +00:00
|
|
|
new BeatAction.Action(beat, delegate
|
|
|
|
{
|
|
|
|
if (gandwHasEntered && !bgDisabled) gandwAnim.Play("MrGameAndWatchLeverDown", 0, 0);
|
|
|
|
}),
|
2023-06-28 04:51:53 +00:00
|
|
|
new BeatAction.Action(beat + 1, delegate
|
|
|
|
{
|
2023-07-12 16:49:32 +00:00
|
|
|
if (beat + 1 > GetLastIntervalBeforeBeat(beat + 1).beat + GetLastIntervalBeforeBeat(beat + 1).length)
|
2023-06-28 04:51:53 +00:00
|
|
|
{
|
|
|
|
ballTransporterLeftNPC.GetComponent<Animator>().Play("BallTransporterLeftClose", 0, 0);
|
|
|
|
ballTransporterRightNPC.GetComponent<Animator>().Play("BallTransporterRightClose", 0, 0);
|
|
|
|
}
|
|
|
|
if (bigMode)
|
|
|
|
{
|
|
|
|
NPCBallTransporters.GetComponent<Animator>().Play("NPCExitBigMode", 0, 0);
|
|
|
|
bigMode = false;
|
|
|
|
}
|
|
|
|
}),
|
|
|
|
//Close player transporters
|
|
|
|
new BeatAction.Action(beat + length + 1, delegate
|
|
|
|
{
|
|
|
|
ballTransporterLeftPlayer.GetComponent<Animator>().Play("BallTransporterLeftClose", 0, 0);
|
|
|
|
ballTransporterRightPlayer.GetComponent<Animator>().Play("BallTransporterRightClose", 0, 0);
|
|
|
|
if (bigModePlayer)
|
|
|
|
{
|
|
|
|
PlayerBallTransporters.GetComponent<Animator>().Play("PlayerExitBigMode", 0, 0);
|
|
|
|
bigModePlayer = false;
|
|
|
|
}
|
|
|
|
}),
|
|
|
|
});
|
2023-06-13 22:47:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public void SpawnBall(double beat, bool isBig, bool hasGandw)
|
|
|
|
{
|
2023-01-19 17:18:55 +00:00
|
|
|
var objectToSpawn = isBig ? bigBallNPC : smallBallNPC;
|
|
|
|
var spawnedBall = GameObject.Instantiate(objectToSpawn, ballHolder);
|
|
|
|
|
|
|
|
var ballComponent = spawnedBall.GetComponent<NPCDoughBall>();
|
|
|
|
spawnedBall.SetActive(true);
|
2023-06-13 22:47:52 +00:00
|
|
|
ballComponent.Init(beat, hasGandw);
|
2023-09-11 22:28:04 +00:00
|
|
|
BeatAction.New(instance, new List<BeatAction.Action>()
|
2023-01-19 17:18:55 +00:00
|
|
|
{
|
|
|
|
//Jump and play sound
|
2023-06-28 04:51:53 +00:00
|
|
|
new BeatAction.Action(beat, delegate { arrowSRLeftNPC.sprite = redArrowSprite; }),
|
2023-01-19 17:18:55 +00:00
|
|
|
new BeatAction.Action(beat + 0.1f, delegate { arrowSRLeftNPC.sprite = whiteArrowSprite; }),
|
2023-06-15 18:13:11 +00:00
|
|
|
new BeatAction.Action(beat + 1f, delegate { doughDudesNPC.GetComponent<Animator>().DoScaledAnimationAsync(isBig ? "BigDoughJump" :"SmallDoughJump", 0.5f); }),
|
2023-01-19 17:18:55 +00:00
|
|
|
new BeatAction.Action(beat + 1f, delegate { npcImpact.SetActive(true); }),
|
|
|
|
new BeatAction.Action(beat + 1.1f, delegate { npcImpact.SetActive(false); }),
|
|
|
|
new BeatAction.Action(beat + 1.9f, delegate { arrowSRRightNPC.sprite = redArrowSprite; }),
|
|
|
|
new BeatAction.Action(beat + 2f, delegate { arrowSRRightNPC.sprite = whiteArrowSprite; }),
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2023-07-12 16:49:32 +00:00
|
|
|
public void OnSpawnBall(double beat, bool isBig)
|
2023-01-22 19:22:39 +00:00
|
|
|
{
|
2023-06-28 04:51:53 +00:00
|
|
|
SoundByte.PlayOneShotGame(isBig ? "workingDough/hitBigOther" : "workingDough/hitSmallOther", beat);
|
|
|
|
SoundByte.PlayOneShotGame(isBig ? "workingDough/bigOther" : "workingDough/smallOther", beat);
|
2023-06-13 22:47:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public void SpawnPlayerBall(double beat, bool isBig, bool hasGandw)
|
2023-01-19 17:18:55 +00:00
|
|
|
{
|
|
|
|
var objectToSpawn = isBig ? playerEnterBigBall : playerEnterSmallBall;
|
|
|
|
var spawnedBall = GameObject.Instantiate(objectToSpawn, ballHolder);
|
|
|
|
|
|
|
|
var ballComponent = spawnedBall.GetComponent<PlayerEnterDoughBall>();
|
2023-06-13 22:47:52 +00:00
|
|
|
spawnedBall.SetActive(true);
|
|
|
|
ballComponent.Init(beat, isBig, hasGandw);
|
2023-01-19 17:18:55 +00:00
|
|
|
|
2023-09-11 22:28:04 +00:00
|
|
|
BeatAction.New(instance, new List<BeatAction.Action>()
|
2023-01-19 17:18:55 +00:00
|
|
|
{
|
|
|
|
new BeatAction.Action(beat, delegate { arrowSRLeftPlayer.sprite = redArrowSprite; }),
|
|
|
|
new BeatAction.Action(beat + 0.1f, delegate { arrowSRLeftPlayer.sprite = whiteArrowSprite; }),
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2023-06-28 04:51:53 +00:00
|
|
|
private struct QueuedInterval
|
|
|
|
{
|
|
|
|
public double beat;
|
|
|
|
public float interval;
|
|
|
|
public bool auto;
|
|
|
|
}
|
|
|
|
private static List<QueuedInterval> queuedIntervals = new();
|
|
|
|
|
|
|
|
public static void PreSetIntervalStart(double beat, float interval, bool auto)
|
2023-01-19 17:18:55 +00:00
|
|
|
{
|
|
|
|
if (GameManager.instance.currentGame == "workingDough")
|
|
|
|
{
|
2023-01-22 19:22:39 +00:00
|
|
|
// instance.ballTriggerSetInterval = false;
|
|
|
|
// beatInterval = interval;
|
2023-06-28 04:51:53 +00:00
|
|
|
instance.SetIntervalStart(beat, beat, interval, auto);
|
2023-01-19 17:18:55 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2023-06-28 04:51:53 +00:00
|
|
|
queuedIntervals.Add(new QueuedInterval
|
|
|
|
{
|
|
|
|
beat = beat,
|
|
|
|
interval = interval,
|
|
|
|
auto = auto
|
|
|
|
});
|
2023-01-19 17:18:55 +00:00
|
|
|
}
|
|
|
|
}
|
2023-06-13 22:47:52 +00:00
|
|
|
public override void OnGameSwitch(double beat)
|
2023-01-19 17:18:55 +00:00
|
|
|
{
|
2023-06-28 04:51:53 +00:00
|
|
|
if (Conductor.instance.isPlaying && !Conductor.instance.isPaused)
|
2023-01-19 17:18:55 +00:00
|
|
|
{
|
2023-06-28 04:51:53 +00:00
|
|
|
if (queuedIntervals.Count > 0)
|
2023-01-19 17:18:55 +00:00
|
|
|
{
|
2023-06-28 04:51:53 +00:00
|
|
|
foreach (var interval in queuedIntervals)
|
2023-01-19 17:18:55 +00:00
|
|
|
{
|
2023-06-28 04:51:53 +00:00
|
|
|
SetIntervalStart(interval.beat, beat, interval.interval, interval.auto);
|
2023-06-13 22:47:52 +00:00
|
|
|
}
|
2023-06-28 04:51:53 +00:00
|
|
|
queuedIntervals.Clear();
|
2023-01-19 17:18:55 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-01-15 19:22:26 +00:00
|
|
|
public override void OnPlay(double beat)
|
|
|
|
{
|
|
|
|
queuedIntervals.Clear();
|
|
|
|
passedTurns.Clear();
|
|
|
|
}
|
|
|
|
|
2023-06-28 04:51:53 +00:00
|
|
|
void Update()
|
|
|
|
{
|
2023-06-13 22:47:52 +00:00
|
|
|
if (spaceshipRising && !bgDisabled) spaceshipAnimator.DoScaledAnimation("RiseSpaceship", risingStartBeat, risingLength);
|
|
|
|
if (liftingDoughDudes && !bgDisabled) doughDudesHolderAnim.DoScaledAnimation(liftingAnimName, liftingStartBeat, liftingLength);
|
|
|
|
if (gandwMoving && !bgDisabled) gandwAnim.DoScaledAnimation(gandwMovingAnimName, gandMovingStartBeat, gandMovingLength);
|
|
|
|
if (passedTurns.Count > 0)
|
2023-01-19 17:18:55 +00:00
|
|
|
{
|
2023-06-13 22:47:52 +00:00
|
|
|
foreach (var passTurn in passedTurns)
|
2023-01-19 17:18:55 +00:00
|
|
|
{
|
2023-06-28 04:51:53 +00:00
|
|
|
PassTurnStandalone(passTurn);
|
2023-06-13 22:47:52 +00:00
|
|
|
}
|
|
|
|
passedTurns.Clear();
|
2023-01-19 17:18:55 +00:00
|
|
|
}
|
2023-10-29 19:44:47 +00:00
|
|
|
if (PlayerInput.GetIsAction(InputAction_Nrm) && !IsExpectingInputNow(InputAction_Nrm))
|
2023-01-19 17:18:55 +00:00
|
|
|
{
|
2023-06-15 18:13:11 +00:00
|
|
|
doughDudesPlayer.GetComponent<Animator>().DoScaledAnimationAsync("SmallDoughJump", 0.5f);
|
2023-06-13 22:47:52 +00:00
|
|
|
SoundByte.PlayOneShotGame("workingDough/smallPlayer");
|
2023-01-19 17:18:55 +00:00
|
|
|
}
|
2023-10-29 19:44:47 +00:00
|
|
|
else if (PlayerInput.GetIsAction(InputAction_Alt) && !IsExpectingInputNow(InputAction_Alt))
|
2023-01-19 17:18:55 +00:00
|
|
|
{
|
2023-06-15 18:13:11 +00:00
|
|
|
doughDudesPlayer.GetComponent<Animator>().DoScaledAnimationAsync("BigDoughJump", 0.5f);
|
2023-06-13 22:47:52 +00:00
|
|
|
SoundByte.PlayOneShotGame("workingDough/bigPlayer");
|
2023-01-19 17:18:55 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-06-13 22:47:52 +00:00
|
|
|
public void SpawnBGBall(double beat, bool isBig, bool hasGandw)
|
2023-01-19 17:18:55 +00:00
|
|
|
{
|
|
|
|
var objectToSpawn = isBig ? bigBGBall : smallBGBall;
|
|
|
|
var spawnedBall = GameObject.Instantiate(objectToSpawn, ballHolder);
|
|
|
|
|
|
|
|
var ballComponent = spawnedBall.GetComponent<BGBall>();
|
|
|
|
spawnedBall.SetActive(true);
|
2023-06-13 22:47:52 +00:00
|
|
|
ballComponent.Init(beat, hasGandw);
|
2023-09-11 22:28:04 +00:00
|
|
|
BeatAction.New(instance, new List<BeatAction.Action>()
|
2023-01-19 17:18:55 +00:00
|
|
|
{
|
2023-06-13 22:47:52 +00:00
|
|
|
new BeatAction.Action(beat + 9f, delegate { if (!spaceshipRisen && !bgDisabled) spaceshipAnimator.Play("AbsorbBall", 0, 0); }),
|
2023-01-19 17:18:55 +00:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
public void InstantElevation(bool isUp)
|
|
|
|
{
|
|
|
|
doughDudesHolderAnim.Play(isUp ? "InAir" : "OnGround", 0, 0);
|
|
|
|
}
|
|
|
|
|
2023-06-10 19:17:06 +00:00
|
|
|
public void Elevate(double beat, float length, bool isUp)
|
2023-01-19 17:18:55 +00:00
|
|
|
{
|
|
|
|
liftingAnimName = isUp ? "LiftUp" : "LiftDown";
|
|
|
|
liftingStartBeat = beat;
|
|
|
|
liftingLength = length;
|
|
|
|
liftingDoughDudes = true;
|
|
|
|
doughDudesHolderAnim.DoScaledAnimation(liftingAnimName, liftingStartBeat, liftingLength);
|
2023-09-11 22:28:04 +00:00
|
|
|
BeatAction.New(instance, new List<BeatAction.Action>()
|
2023-01-19 17:18:55 +00:00
|
|
|
{
|
|
|
|
new BeatAction.Action(beat + length - 0.1f, delegate { liftingDoughDudes = false; }),
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2023-06-10 19:17:06 +00:00
|
|
|
public void LaunchShip(double beat, float length)
|
2023-01-19 17:18:55 +00:00
|
|
|
{
|
2023-06-13 22:47:52 +00:00
|
|
|
if (bgDisabled) return;
|
2023-01-19 17:18:55 +00:00
|
|
|
spaceshipRisen = true;
|
|
|
|
if (!spaceshipLights.activeSelf)
|
|
|
|
{
|
|
|
|
spaceshipLights.SetActive(true);
|
|
|
|
spaceshipLights.GetComponent<Animator>().Play("SpaceshipLights", 0, 0);
|
|
|
|
}
|
|
|
|
spaceshipAnimator.Play("SpaceshipShake", 0, 0);
|
2023-09-11 22:28:04 +00:00
|
|
|
BeatAction.New(instance, new List<BeatAction.Action>()
|
2023-01-19 17:18:55 +00:00
|
|
|
{
|
|
|
|
new BeatAction.Action(beat + length, delegate { spaceshipAnimator.Play("SpaceshipLaunch", 0, 0); }),
|
2023-06-10 19:17:06 +00:00
|
|
|
new BeatAction.Action(beat + length, delegate { SoundByte.PlayOneShotGame("workingDough/LaunchRobot"); }),
|
2023-01-19 17:18:55 +00:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2023-06-10 19:17:06 +00:00
|
|
|
public void RiseUpShip(double beat, float length)
|
2023-06-13 22:47:52 +00:00
|
|
|
{
|
|
|
|
if (bgDisabled) return;
|
2023-01-19 17:18:55 +00:00
|
|
|
spaceshipRisen = true;
|
|
|
|
spaceshipRising = true;
|
|
|
|
risingLength = length;
|
|
|
|
risingStartBeat = beat;
|
|
|
|
if (!spaceshipLights.activeSelf)
|
|
|
|
{
|
|
|
|
spaceshipLights.SetActive(true);
|
|
|
|
spaceshipLights.GetComponent<Animator>().Play("SpaceshipLights", 0, 0);
|
|
|
|
}
|
|
|
|
spaceshipAnimator.DoScaledAnimation("RiseSpaceship", risingStartBeat, risingLength);
|
2023-09-11 22:28:04 +00:00
|
|
|
BeatAction.New(instance, new List<BeatAction.Action>()
|
2023-01-19 17:18:55 +00:00
|
|
|
{
|
|
|
|
new BeatAction.Action(beat + length - 0.1f, delegate { spaceshipRising = false; }),
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2023-06-10 19:17:06 +00:00
|
|
|
public void GANDWEnterOrExit(double beat, float length, bool shouldExit)
|
2023-01-19 17:18:55 +00:00
|
|
|
{
|
2023-06-13 22:47:52 +00:00
|
|
|
if (bgDisabled) return;
|
2023-01-19 17:18:55 +00:00
|
|
|
gandwMoving = true;
|
|
|
|
gandwHasEntered = false;
|
|
|
|
gandMovingLength = length;
|
|
|
|
gandMovingStartBeat = beat;
|
|
|
|
gandwMovingAnimName = shouldExit ? "GANDWLeave" : "GANDWEnter";
|
|
|
|
gandwAnim.DoScaledAnimation(gandwMovingAnimName, gandMovingStartBeat, gandMovingLength);
|
2023-09-11 22:28:04 +00:00
|
|
|
BeatAction.New(instance, new List<BeatAction.Action>()
|
2023-01-19 17:18:55 +00:00
|
|
|
{
|
|
|
|
new BeatAction.Action(beat + length - 0.1f, delegate { gandwMoving = false; }),
|
|
|
|
new BeatAction.Action(beat + length, delegate { gandwHasEntered = shouldExit ? false : true; }),
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
public void InstantGANDWEnterOrExit(bool shouldExit)
|
|
|
|
{
|
2023-06-13 22:47:52 +00:00
|
|
|
if (bgDisabled) return;
|
2023-01-19 17:18:55 +00:00
|
|
|
gandwAnim.Play(shouldExit ? "GANDWLeft" : "MrGameAndWatchLeverDown", 0, 0);
|
|
|
|
gandwHasEntered = shouldExit ? false : true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|