Merge branch 'release_1'

This commit is contained in:
minenice55 2023-07-22 23:21:59 -04:00
commit 5734c91db8
5 changed files with 247 additions and 219 deletions

View file

@ -317,7 +317,7 @@ SpriteRenderer:
m_Size: {x: 5.12, y: 5.12} m_Size: {x: 5.12, y: 5.12}
m_AdaptiveModeThreshold: 0.5 m_AdaptiveModeThreshold: 0.5
m_SpriteTileMode: 0 m_SpriteTileMode: 0
m_WasSpriteAssigned: 1 m_WasSpriteAssigned: 0
m_MaskInteraction: 0 m_MaskInteraction: 0
m_SpriteSortPoint: 0 m_SpriteSortPoint: 0
--- !u!1 &646572621760847893 --- !u!1 &646572621760847893
@ -1408,7 +1408,7 @@ SpriteRenderer:
m_Size: {x: 5.12, y: 5.12} m_Size: {x: 5.12, y: 5.12}
m_AdaptiveModeThreshold: 0.5 m_AdaptiveModeThreshold: 0.5
m_SpriteTileMode: 0 m_SpriteTileMode: 0
m_WasSpriteAssigned: 1 m_WasSpriteAssigned: 0
m_MaskInteraction: 0 m_MaskInteraction: 0
m_SpriteSortPoint: 0 m_SpriteSortPoint: 0
--- !u!1 &2618106657828263176 --- !u!1 &2618106657828263176
@ -4191,19 +4191,16 @@ MonoBehaviour:
alienSpeakCount: 0 alienSpeakCount: 0
translatorSpeakCount: 0 translatorSpeakCount: 0
hasMissed: 0 hasMissed: 0
alien: {fileID: 7783123803599722790} alien: {fileID: 1725356918350344904}
translator: {fileID: 179726693367595051} translator: {fileID: 2669316826032871973}
dummyHolder: {fileID: 0}
missionControl: {fileID: 1703073459706337243} missionControl: {fileID: 1703073459706337243}
liveBar: {fileID: 6386057715023792916} liveBar: {fileID: 6529724687638495651}
alienTextbox: {fileID: 4232889953588772276} alienTextbox: {fileID: 4232889953588772276}
alienText: {fileID: 8658955634054422971} alienText: {fileID: 8658955634054422971}
translateTextbox: {fileID: 2397353702484880984} translateTextbox: {fileID: 2397353702484880984}
translateText: {fileID: 115920198331035770} translateText: {fileID: 115920198331035770}
translateFailTextbox: {fileID: 224928759238017390} translateFailTextbox: {fileID: 224928759238017390}
translateFailText: {fileID: 907427456758261759} translateFailText: {fileID: 907427456758261759}
intervalStarted: 0
beatInterval: 4
noHitOnce: 0 noHitOnce: 0
isSpeaking: 0 isSpeaking: 0
lookAtLength: 1 lookAtLength: 1

View file

@ -2,9 +2,11 @@ using System;
using System.Text; using System.Text;
using System.Collections.Generic; using System.Collections.Generic;
using UnityEngine; using UnityEngine;
using UnityEngine.UI;
using HeavenStudio.Util; using HeavenStudio.Util;
using TMPro; using TMPro;
using Jukebox;
using UnityEngine.Assertions.Must;
using UnityEngine.UIElements;
namespace HeavenStudio.Games.Loaders namespace HeavenStudio.Games.Loaders
{ {
@ -17,10 +19,11 @@ namespace HeavenStudio.Games.Loaders
{ {
new GameAction("beat intervals", "Start Interval") new GameAction("beat intervals", "Start Interval")
{ {
function = delegate { var e = eventCaller.currentEntity; FirstContact.instance.SetIntervalStart(e.beat, e.length, e["dialogue"]); }, preFunction = delegate { var e = eventCaller.currentEntity; FirstContact.PreInterval(e.beat, e.length, e["dialogue"], e["auto"]); },
parameters = new List<Param>() parameters = new List<Param>()
{ {
new Param("dialogue", "REPLACE THIS", "Mistranslation Dialogue", "The line to use when messing up the translation") new Param("dialogue", "REPLACE THIS", "Mistranslation Dialogue", "The line to use when messing up the translation"),
new Param("auto", true, "Auto Pass Turn")
}, },
defaultLength = 4f, defaultLength = 4f,
resizable = true, resizable = true,
@ -28,19 +31,18 @@ namespace HeavenStudio.Games.Loaders
}, },
new GameAction("alien speak", "Bob Speak") new GameAction("alien speak", "Bob Speak")
{ {
function = delegate { var e = eventCaller.currentEntity; FirstContact.instance.AlienSpeak(e.beat, e["dialogue"], e["spaceNum"]); },
defaultLength = 0.5f, defaultLength = 0.5f,
parameters = new List<Param>() parameters = new List<Param>()
{ {
new Param("spaceNum", new EntityTypes.Integer(0, 12, 0), "Amount of spaces", "Spaces to add before the untranslated icon"), new Param("spaceNum", new EntityTypes.Integer(0, 12, 0), "Amount of spaces", "Spaces to add before the untranslated icon"),
new Param("dotdotdot", false, "Has ellipses?", "Will the man symbol be proceeded by a <...>?"),
new Param("dialogue", "", "Dialogue", "What should this sound translate to?") new Param("dialogue", "", "Dialogue", "What should this sound translate to?")
}, },
priority = 1 priority = 1
}, },
new GameAction("alien turnover", "Pass Turn") new GameAction("alien turnover", "Pass Turn")
{ {
function = delegate { FirstContact.instance.AlienTurnOver(eventCaller.currentEntity.beat, eventCaller.currentEntity.length); }, function = delegate { FirstContact.instance.PassTurnStandalone(eventCaller.currentEntity.beat); },
resizable = true
}, },
new GameAction("alien success", "Success") new GameAction("alien success", "Success")
{ {
@ -92,23 +94,21 @@ namespace HeavenStudio.Games
const string MID_MSG_MISS = "<color=\"red\"> ..? </color>"; const string MID_MSG_MISS = "<color=\"red\"> ..? </color>";
const string MSG_ALIEN = "<sprite name=\"AlienIcn\">"; const string MSG_ALIEN = "<sprite name=\"AlienIcn\">";
const string MSG_MAN = "<sprite name=\"ManIcn\">"; const string MSG_MAN = "<sprite name=\"ManIcn\">";
const string MSG_MAN_DDD = "...<sprite name=\"ManIcn\">";
// I should add a DonkTroll sprite 🫰🫰🫰🫰🫰 // I should add a DonkTroll sprite 🫰🫰🫰🫰🫰
public static FirstContact instance { get; private set; } public static FirstContact instance { get; private set; }
[Header("Properties")] //[Header("Properties")]
public int alienSpeakCount; private bool hasMissed;
public int translatorSpeakCount;
public bool hasMissed;
private double lastReportedBeat = 0; private double lastReportedBeat = 0;
[Header("Components")] [Header("Components")]
[SerializeField] GameObject alien; [SerializeField] Animator alien;
[SerializeField] GameObject translator; [SerializeField] Animator translator;
//[SerializeField] GameObject alienSpeech; //[SerializeField] GameObject alienSpeech;
[SerializeField] GameObject dummyHolder;
[SerializeField] GameObject missionControl; [SerializeField] GameObject missionControl;
[SerializeField] GameObject liveBar; [SerializeField] Animator liveBar;
[SerializeField] GameObject alienTextbox; [SerializeField] GameObject alienTextbox;
[SerializeField] TMP_Text alienText; [SerializeField] TMP_Text alienText;
@ -119,9 +119,6 @@ namespace HeavenStudio.Games
[Header("Variables")] [Header("Variables")]
int currentVoicelineIndex = -1; int currentVoicelineIndex = -1;
public bool intervalStarted;
double intervalStartBeat;
public float beatInterval = 4f;
public bool noHitOnce, isSpeaking; public bool noHitOnce, isSpeaking;
//public int version; //public int version;
public float lookAtLength = 1f; public float lookAtLength = 1f;
@ -133,14 +130,14 @@ namespace HeavenStudio.Games
string respDiagBuffer = ""; string respDiagBuffer = "";
List<string> callDiagList = new List<string>(); List<string> callDiagList = new List<string>();
int callDiagIndex = 0; int callDiagIndex = 0;
private struct QueuedInterval
static List<QueuedSecondContactInput> queuedInputs = new List<QueuedSecondContactInput>();
struct QueuedSecondContactInput
{ {
public double beatAwayFromStart; public double beat;
public string dialogue; public float interval;
public bool autoPassTurn;
public string outDialogue;
} }
private static List<QueuedInterval> queuedIntervals = new List<QueuedInterval>();
//public enum VersionOfContact //public enum VersionOfContact
//{ //{
@ -163,10 +160,6 @@ namespace HeavenStudio.Games
void OnDestroy() void OnDestroy()
{ {
if (!Conductor.instance.isPlaying || Conductor.instance.isPaused)
{
if (queuedInputs.Count > 0) queuedInputs.Clear();
}
foreach (var evt in scheduledInputs) foreach (var evt in scheduledInputs)
{ {
evt.Disable(); evt.Disable();
@ -190,18 +183,57 @@ namespace HeavenStudio.Games
translateFailTextbox.SetActive(false); translateFailTextbox.SetActive(false);
} }
public void SetIntervalStart(double beat, float interval, string outDialogue) private List<RiqEntity> GetAllSpeaksInBetweenBeat(double beat, double endBeat)
{ {
translator.GetComponent<Animator>().Play("translator_lookAtAlien", 0, 0); List<RiqEntity> speakEvents = EventCaller.GetAllInGameManagerList("firstContact", new string[] { "alien speak" });
if (!intervalStarted) List<RiqEntity> tempEvents = new();
foreach (var entity in speakEvents)
{ {
//alienSpeakCount = 0; if (entity.beat >= beat && entity.beat < endBeat)
//translatorSpeakCount = 0; {
intervalStarted = true; tempEvents.Add(entity);
}
}
return tempEvents;
} }
intervalStartBeat = beat; private RiqEntity GetLastIntervalBeforeBeat(double beat)
beatInterval = interval; {
List<RiqEntity> intervalEvents = EventCaller.GetAllInGameManagerList("firstContact", 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];
}
public static void PreInterval(double beat, float interval, string outDialogue, bool autoPassTurn)
{
if (GameManager.instance.currentGame == "firstContact")
{
instance.SetIntervalStart(beat, interval, outDialogue, beat, autoPassTurn);
}
else
{
queuedIntervals.Add(new QueuedInterval
{
beat = beat,
interval = interval,
outDialogue = outDialogue,
autoPassTurn = autoPassTurn
});
}
}
private void SetIntervalStart(double beat, float interval, string outDialogue, double gameSwitchBeat, bool autoPassTurn)
{
List<RiqEntity> relevantSpeakEvents = GetAllSpeaksInBetweenBeat(beat, beat + interval);
relevantSpeakEvents.Sort((x, y) => x.beat.CompareTo(y.beat));
List<BeatAction.Action> queuedSpeaks = new()
{
new BeatAction.Action(beat, delegate
{
translator.Play("translator_lookAtAlien", 0, 0);
onOutDialogue = outDialogue; onOutDialogue = outDialogue;
callDiagBuffer = ""; callDiagBuffer = "";
@ -216,21 +248,50 @@ namespace HeavenStudio.Games
alienTextbox.SetActive(false); alienTextbox.SetActive(false);
translateTextbox.SetActive(false); translateTextbox.SetActive(false);
translateFailTextbox.SetActive(false); translateFailTextbox.SetActive(false);
if (autoPassTurn)
{
AlienTurnOver(beat + interval, beat, beat + interval);
}
})
};
for (int i = 0; i < relevantSpeakEvents.Count; i++)
{
RiqEntity speakEventToCheck = relevantSpeakEvents[i];
if (speakEventToCheck.beat >= gameSwitchBeat)
{
queuedSpeaks.Add(new BeatAction.Action(speakEventToCheck.beat, delegate
{
AlienSpeak(speakEventToCheck.beat, speakEventToCheck["spaceNum"], speakEventToCheck["dotdotdot"]);
}));
}
else
{
AlienSpeakInactive(speakEventToCheck["spaceNum"]);
}
}
BeatAction.New(gameObject, queuedSpeaks);
}
public override void OnGameSwitch(double beat)
{
if (Conductor.instance.isPlaying && !Conductor.instance.isPaused)
{
if (queuedIntervals.Count > 0)
{
foreach (var interval in queuedIntervals)
{
SetIntervalStart(interval.beat, interval.interval, interval.outDialogue, beat, interval.autoPassTurn);
}
queuedIntervals.Clear();
}
}
} }
private void Update() private void Update()
{ {
if (!Conductor.instance.isPlaying || Conductor.instance.isPaused)
{
if (queuedInputs.Count > 0) queuedInputs.Clear();
}
if (!Conductor.instance.isPlaying && !Conductor.instance.isPaused && intervalStarted)
{
intervalStarted = false;
}
if (Conductor.instance.ReportBeat(ref lastReportedBeat, offset: liveBarBeatOffset)) if (Conductor.instance.ReportBeat(ref lastReportedBeat, offset: liveBarBeatOffset))
{ {
liveBar.GetComponent<Animator>().Play("liveBar", 0, 0); liveBar.Play("liveBar", 0, 0);
} }
else if (Conductor.instance.songPositionInBeatsAsDouble < lastReportedBeat) else if (Conductor.instance.songPositionInBeatsAsDouble < lastReportedBeat)
{ {
@ -239,7 +300,7 @@ namespace HeavenStudio.Games
if (PlayerInput.Pressed(true) && !IsExpectingInputNow(InputType.STANDARD_DOWN | InputType.DIRECTION_DOWN)) if (PlayerInput.Pressed(true) && !IsExpectingInputNow(InputType.STANDARD_DOWN | InputType.DIRECTION_DOWN))
{ {
translator.GetComponent<Animator>().DoScaledAnimationAsync("translator_eh", 0.5f); translator.DoScaledAnimationAsync("translator_eh", 0.5f);
if (isSpeaking) if (isSpeaking)
{ {
if (callDiagIndex == 0) if (callDiagIndex == 0)
@ -273,42 +334,47 @@ namespace HeavenStudio.Games
switch (alienLookAt) switch (alienLookAt)
{ {
case 0: case 0:
alien.GetComponent<Animator>().Play("alien_lookAt", 0, 0); alien.Play("alien_lookAt", 0, 0);
break; break;
case 1: case 1:
alien.GetComponent<Animator>().Play("alien_idle", 0, 0); alien.Play("alien_idle", 0, 0);
break; break;
} }
switch (translatorLookAt) switch (translatorLookAt)
{ {
case 0: case 0:
translator.GetComponent<Animator>().Play("translator_lookAtAlien", 0, 0); translator.Play("translator_lookAtAlien", 0, 0);
break; break;
case 1: case 1:
translator.GetComponent<Animator>().Play("translator_idle", 0, 0); translator.Play("translator_idle", 0, 0);
break; break;
} }
} }
public void AlienSpeak(double beat, string dialogue, int spaceNum) private void AlienSpeak(double beat, int spaceNum, bool hasDDD)
{ {
queuedInputs.Add(new QueuedSecondContactInput()
{
beatAwayFromStart = beat - intervalStartBeat,
dialogue = dialogue
});
int voiceline = UnityEngine.Random.Range(1, 11); int voiceline = UnityEngine.Random.Range(1, 11);
if (voiceline == currentVoicelineIndex) voiceline++; if (voiceline == currentVoicelineIndex) voiceline++;
if (voiceline > 10) voiceline = 1; if (voiceline > 10) voiceline = 1;
currentVoicelineIndex = voiceline; currentVoicelineIndex = voiceline;
SoundByte.PlayOneShotGame("firstContact/Bob" + voiceline, beat, SoundByte.GetPitchFromCents(UnityEngine.Random.Range(-100, 0), false)); SoundByte.PlayOneShotGame("firstContact/Bob" + voiceline, beat, SoundByte.GetPitchFromCents(UnityEngine.Random.Range(-100, 0), false));
SoundByte.PlayOneShotGame("firstContact/BobB"); SoundByte.PlayOneShotGame("firstContact/BobB");
alien.GetComponent<Animator>().DoScaledAnimationAsync("alien_talk", 0.5f); alien.DoScaledAnimationAsync("alien_talk", 0.5f);
if (UnityEngine.Random.Range(0, 5) == 0) translator.GetComponent<Animator>().DoScaledAnimationAsync("translator_lookAtAlien_nod", 0.5f); if (UnityEngine.Random.Range(0, 5) == 0) translator.DoScaledAnimationAsync("translator_lookAtAlien_nod", 0.5f);
callDiagList.Add(dialogue);
alienTextbox.SetActive(true);
for (int i = 0; i < spaceNum * 2; i++)
{
callDiagBuffer += " ";
}
callDiagBuffer += hasDDD ? MSG_MAN_DDD : MSG_MAN;
UpdateAlienTextbox();
}
private void AlienSpeakInactive(int spaceNum)
{
alienTextbox.SetActive(true); alienTextbox.SetActive(true);
for (int i = 0; i < spaceNum * 2; i++) for (int i = 0; i < spaceNum * 2; i++)
{ {
@ -318,28 +384,38 @@ namespace HeavenStudio.Games
UpdateAlienTextbox(); UpdateAlienTextbox();
} }
public void AlienTurnOver(double beat, float length) public void PassTurnStandalone(double beat)
{ {
if (queuedInputs.Count == 0) return; RiqEntity lastInterval = GetLastIntervalBeforeBeat(beat);
if (lastInterval == null) return;
AlienTurnOver(beat, lastInterval.beat, lastInterval.beat + lastInterval.length);
}
private void AlienTurnOver(double beat, double intervalBeat, double endBeat)
{
var inputs = GetAllSpeaksInBetweenBeat(intervalBeat, endBeat);
inputs.Sort((x, y) => x.beat.CompareTo(y.beat));
for (int i = 0; i < inputs.Count; i++)
{
var input = inputs[i];
double relativeBeat = input.beat - intervalBeat;
ScheduleInput(beat, 1 + relativeBeat, InputType.STANDARD_DOWN | InputType.DIRECTION_DOWN, AlienTapping, AlienOnMiss, AlienEmpty);
callDiagList.Add(input["dialogue"]);
}
BeatAction.New(gameObject, new List<BeatAction.Action>()
{
new BeatAction.Action(beat, delegate
{
isSpeaking = true;
SoundByte.PlayOneShotGame("firstContact/turnover"); SoundByte.PlayOneShotGame("firstContact/turnover");
alienTextbox.SetActive(false); alienTextbox.SetActive(false);
alien.GetComponent<Animator>().Play("alien_point", 0, 0); alien.Play("alien_point", 0, 0);
}),
isSpeaking = true; new BeatAction.Action(beat + 0.5f, delegate
intervalStarted = false;
BeatAction.New(alien, new List<BeatAction.Action>()
{ {
new BeatAction.Action(beat + 0.5f, delegate { alien.GetComponent<Animator>().Play("alien_idle", 0, 0); }) alien.Play("alien_idle", 0, 0);
})
}); });
if (!isSpeaking)
{
translator.GetComponent<Animator>().Play("translator_idle", 0, 0);
}
foreach (var input in queuedInputs)
{
ScheduleInput(beat, length + input.beatAwayFromStart, InputType.STANDARD_DOWN | InputType.DIRECTION_DOWN, AlienTapping, AlienOnMiss, AlienEmpty);
}
queuedInputs.Clear();
} }
public void AlienSuccess(double beat) public void AlienSuccess(double beat)
@ -372,14 +448,13 @@ namespace HeavenStudio.Games
MultiSound.Play(sound.ToArray()); MultiSound.Play(sound.ToArray());
BeatAction.New(alien, new List<BeatAction.Action>() BeatAction.New(gameObject, new List<BeatAction.Action>()
{ {
new BeatAction.Action(beat, delegate { alien.GetComponent<Animator>().Play(animString, 0, 0); }), new BeatAction.Action(beat, delegate { alien.Play(animString, 0, 0); }),
new BeatAction.Action(beat + .5f, delegate { alien.GetComponent<Animator>().Play(animString, 0, 0); }), new BeatAction.Action(beat + .5f, delegate { alien.Play(animString, 0, 0); }),
new BeatAction.Action(beat + 1, delegate { alienTextbox.SetActive(false); translateTextbox.SetActive(false); translateFailTextbox.SetActive(false); }) new BeatAction.Action(beat + 1, delegate { alienTextbox.SetActive(false); translateTextbox.SetActive(false); translateFailTextbox.SetActive(false); })
}); });
intervalStarted = false;
isSpeaking = false; isSpeaking = false;
hasMissed = false; hasMissed = false;
noHitOnce = false; noHitOnce = false;
@ -430,8 +505,8 @@ namespace HeavenStudio.Games
} }
missionControl.GetComponentInParent<Animator>().Play(textToPut, 0, 0); missionControl.GetComponentInParent<Animator>().Play(textToPut, 0, 0);
alien.GetComponentInParent<Animator>().Play("alien_idle", 0, 0); alien.Play("alien_idle", 0, 0);
translator.GetComponent<Animator>().Play("translator_idle", 0, 0); translator.Play("translator_idle", 0, 0);
if (!stay) if (!stay)
{ {
@ -444,16 +519,13 @@ namespace HeavenStudio.Games
{ {
missionControl.SetActive(true); missionControl.SetActive(true);
} }
alienSpeakCount = 0;
translatorSpeakCount = 0;
isSpeaking = false; isSpeaking = false;
} }
void FailContact() void FailContact()
{ {
SoundByte.PlayOneShotGame("firstContact/failContact"); SoundByte.PlayOneShotGame("firstContact/failContact");
translator.GetComponent<Animator>().DoScaledAnimationAsync("translator_speak", 0.5f); translator.DoScaledAnimationAsync("translator_speak", 0.5f);
if (!hasMissed && callDiagIndex == 0) if (!hasMissed && callDiagIndex == 0)
{ {
translateFailTextbox.SetActive(true); translateFailTextbox.SetActive(true);
@ -467,7 +539,7 @@ namespace HeavenStudio.Games
void TrailingContact() void TrailingContact()
{ {
SoundByte.PlayOneShotGame("firstContact/slightlyFail"); SoundByte.PlayOneShotGame("firstContact/slightlyFail");
translator.GetComponent<Animator>().Play("translator_eh", 0, 0); translator.Play("translator_eh", 0, 0);
if (!hasMissed) if (!hasMissed)
{ {
respDiagBuffer += MID_MSG_MISS; respDiagBuffer += MID_MSG_MISS;
@ -495,13 +567,13 @@ namespace HeavenStudio.Games
if (state >= 1f || state <= -1f) if (state >= 1f || state <= -1f)
{ {
SoundByte.PlayOneShotGame("firstContact/ALIEN_PLAYER_A", -1, SoundByte.GetPitchFromSemiTones(UnityEngine.Random.Range(-3, 3), false)); SoundByte.PlayOneShotGame("firstContact/ALIEN_PLAYER_A", -1, SoundByte.GetPitchFromSemiTones(UnityEngine.Random.Range(-3, 3), false));
translator.GetComponent<Animator>().DoScaledAnimationAsync("translator_speak", 0.5f); translator.DoScaledAnimationAsync("translator_speak", 0.5f);
if (callDiagIndex == 0) return; if (callDiagIndex == 0) return;
TrailingContact(); TrailingContact();
return; return;
} }
translator.GetComponent<Animator>().DoScaledAnimationAsync("translator_speak", 0.5f); translator.DoScaledAnimationAsync("translator_speak", 0.5f);
SoundByte.PlayOneShotGame("firstContact/ALIEN_PLAYER_A", -1, SoundByte.GetPitchFromSemiTones(UnityEngine.Random.Range(-3, 3), false)); SoundByte.PlayOneShotGame("firstContact/ALIEN_PLAYER_A", -1, SoundByte.GetPitchFromSemiTones(UnityEngine.Random.Range(-3, 3), false));
SoundByte.PlayOneShotGame("firstContact/ALIEN_PLAYER_B"); SoundByte.PlayOneShotGame("firstContact/ALIEN_PLAYER_B");
if (hasMissed) if (hasMissed)
@ -533,7 +605,7 @@ namespace HeavenStudio.Games
hasMissed = true; hasMissed = true;
} }
alien.GetComponent<Animator>().Play("alien_noHit", 0, 0); alien.Play("alien_noHit", 0, 0);
} }
public void AlienEmpty(PlayerActionEvent caller) { } //OnEmpty public void AlienEmpty(PlayerActionEvent caller) { } //OnEmpty

View file

@ -171,8 +171,6 @@ namespace HeavenStudio.Games
public GameObject DroppedHairsHolder; public GameObject DroppedHairsHolder;
[Header("Variables")] [Header("Variables")]
private double passTurnBeat;
private double passTurnEndBeat = 2;
private static List<QueuedPeek> queuedPeeks = new List<QueuedPeek>(); private static List<QueuedPeek> queuedPeeks = new List<QueuedPeek>();
[Header("Sprites")] [Header("Sprites")]

View file

@ -356,8 +356,6 @@ namespace HeavenStudio.Games
} }
public static Rockers instance; public static Rockers instance;
public static CallAndResponseHandler crHandlerInstance;
[Header("Rockers")] [Header("Rockers")]
public RockersRocker JJ; public RockersRocker JJ;
public RockersRocker Soshi; public RockersRocker Soshi;
@ -392,10 +390,6 @@ namespace HeavenStudio.Games
private void Awake() private void Awake()
{ {
instance = this; instance = this;
if (crHandlerInstance == null)
{
crHandlerInstance = new CallAndResponseHandler();
}
var tempEvents = EventCaller.GetAllInGameManagerList("rockers", new string[] { "prepare" }); var tempEvents = EventCaller.GetAllInGameManagerList("rockers", new string[] { "prepare" });
foreach (var tempEvent in tempEvents) foreach (var tempEvent in tempEvents)
{ {
@ -470,6 +464,15 @@ namespace HeavenStudio.Games
return tempEvents; return tempEvents;
} }
private RiqEntity GetLastIntervalBeforeBeat(double beat)
{
List<RiqEntity> intervalEvents = EventCaller.GetAllInGameManagerList("rockers", new string[] { "intervalStart" });
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];
}
private List<RiqEntity> GrabAllTogetherEvents(double beat) private List<RiqEntity> GrabAllTogetherEvents(double beat)
{ {
var tempEvents = EventCaller.GetAllInGameManagerList("rockers", new string[] { "riffTogether", "riffTogetherEnd" }); var tempEvents = EventCaller.GetAllInGameManagerList("rockers", new string[] { "riffTogether", "riffTogetherEnd" });
@ -536,11 +539,6 @@ namespace HeavenStudio.Games
} }
} }
public override void OnPlay(double beat)
{
crHandlerInstance = null;
}
private void OnDestroy() private void OnDestroy()
{ {
if (queuedCameraEvents.Count > 0) queuedCameraEvents.Clear(); if (queuedCameraEvents.Count > 0) queuedCameraEvents.Clear();
@ -741,7 +739,7 @@ namespace HeavenStudio.Games
public void TogetherPrepare(double beat, bool cmon, bool muteSound, float muteBeat, float goToMiddleBeat, bool moveCamera) public void TogetherPrepare(double beat, bool cmon, bool muteSound, float muteBeat, float goToMiddleBeat, bool moveCamera)
{ {
List<RiqEntity> togetherEvents = GrabAllTogetherEvents(beat); List<RiqEntity> togetherEvents = GrabAllTogetherEvents(beat);
if (togetherEvents.Count == 0 || crHandlerInstance.IntervalIsActive()) return; if (togetherEvents.Count == 0) return;
if (!muteSound) SoundByte.PlayOneShotGame(cmon ? "rockers/Cmon" : "rockers/LastOne"); if (!muteSound) SoundByte.PlayOneShotGame(cmon ? "rockers/Cmon" : "rockers/LastOne");
List<BeatAction.Action> actions = new List<BeatAction.Action>(); List<BeatAction.Action> actions = new List<BeatAction.Action>();
if (moveCamera) if (moveCamera)
@ -841,9 +839,6 @@ namespace HeavenStudio.Games
public void StartInterval(double beat, float length, double gameSwitchBeat, bool autoPassTurn, bool moveCamera) public void StartInterval(double beat, float length, double gameSwitchBeat, bool autoPassTurn, bool moveCamera)
{ {
CallAndResponseHandler newHandler = new();
crHandlerInstance = newHandler;
crHandlerInstance.StartInterval(beat, length);
List<RiqEntity> relevantInputs = GrabAllInputsBetween(beat, beat + length); List<RiqEntity> relevantInputs = GrabAllInputsBetween(beat, beat + length);
List<double> riffUsedBeats = new List<double>(); List<double> riffUsedBeats = new List<double>();
List<double> bendUsedBeats = new(); List<double> bendUsedBeats = new();
@ -854,21 +849,6 @@ namespace HeavenStudio.Games
RiqEntity foundEvent = riffEvents.Find(x => x.beat == input.beat); RiqEntity foundEvent = riffEvents.Find(x => x.beat == input.beat);
if ((foundEvent == null || (riffUsedBeats.Count > 0 && riffUsedBeats.Contains((float)foundEvent.beat))) && riffEvents.Count > 1) continue; if ((foundEvent == null || (riffUsedBeats.Count > 0 && riffUsedBeats.Contains((float)foundEvent.beat))) && riffEvents.Count > 1) continue;
riffUsedBeats.Add(input.beat); riffUsedBeats.Add(input.beat);
if (input["respond"])
{
crHandlerInstance.AddEvent(input.beat, input.length, "riff", new List<CallAndResponseHandler.CallAndResponseEventParam>()
{
new CallAndResponseHandler.CallAndResponseEventParam("gleeClub", input["gcS"]),
new CallAndResponseHandler.CallAndResponseEventParam("1", input["1S"]),
new CallAndResponseHandler.CallAndResponseEventParam("2", input["2S"]),
new CallAndResponseHandler.CallAndResponseEventParam("3", input["3S"]),
new CallAndResponseHandler.CallAndResponseEventParam("4", input["4S"]),
new CallAndResponseHandler.CallAndResponseEventParam("5", input["5S"]),
new CallAndResponseHandler.CallAndResponseEventParam("6", input["6S"]),
new CallAndResponseHandler.CallAndResponseEventParam("sample", input["sampleS"]),
new CallAndResponseHandler.CallAndResponseEventParam("sampleTones", input["pitchSampleS"])
});
}
if (input.beat >= gameSwitchBeat) if (input.beat >= gameSwitchBeat)
{ {
BeatAction.New(instance.gameObject, new List<BeatAction.Action>() BeatAction.New(instance.gameObject, new List<BeatAction.Action>()
@ -889,18 +869,11 @@ namespace HeavenStudio.Games
else else
{ {
if (riffEvents.Count == 0) continue; if (riffEvents.Count == 0) continue;
RiqEntity foundEvent = bendEvents.Find(x => x.beat == beat); RiqEntity foundEvent = bendEvents.Find(x => x.beat == input.beat);
if ((foundEvent == null || (bendUsedBeats.Count > 0 && bendUsedBeats.Contains((float)foundEvent.beat))) && bendEvents.Count > 1) continue; if ((foundEvent == null || (bendUsedBeats.Count > 0 && bendUsedBeats.Contains((float)foundEvent.beat))) && bendEvents.Count > 1) continue;
RiqEntity riffEventToCheck = riffEvents.Find(x => beat >= x.beat && beat < x.beat + x.length); RiqEntity riffEventToCheck = riffEvents.Find(x => input.beat >= x.beat && input.beat < x.beat + x.length);
if (riffEventToCheck == null) continue; if (riffEventToCheck == null) continue;
bendUsedBeats.Add(beat); bendUsedBeats.Add(beat);
if (input["respond"])
{
crHandlerInstance.AddEvent(input.beat, input.length, "bend", new List<CallAndResponseHandler.CallAndResponseEventParam>()
{
new CallAndResponseHandler.CallAndResponseEventParam("Pitch", input["1S"]),
});
}
if (input.beat >= gameSwitchBeat) if (input.beat >= gameSwitchBeat)
{ {
BeatAction.New(instance.gameObject, new List<BeatAction.Action>() BeatAction.New(instance.gameObject, new List<BeatAction.Action>()
@ -926,7 +899,7 @@ namespace HeavenStudio.Games
} }
}), }),
}); });
if (autoPassTurn) PassTurn(beat + length, moveCamera, newHandler); if (autoPassTurn) PassTurn(beat + length, moveCamera, beat, length);
} }
public void Riff(double beat, float length, int[] pitches, bool gleeClubJJ, int sampleJJ, int sampleTonesJJ, bool noRespond) public void Riff(double beat, float length, int[] pitches, bool gleeClubJJ, int sampleJJ, int sampleTonesJJ, bool noRespond)
@ -1004,12 +977,15 @@ namespace HeavenStudio.Games
private void StandalonePassTurn(double beat, bool moveCamera) private void StandalonePassTurn(double beat, bool moveCamera)
{ {
if (crHandlerInstance != null) PassTurn(beat, moveCamera, crHandlerInstance); RiqEntity lastInterval = GetLastIntervalBeforeBeat(beat);
if (lastInterval == null) return;
PassTurn(beat, moveCamera, lastInterval.beat, lastInterval.length);
} }
private void PassTurn(double beat, bool moveCamera, CallAndResponseHandler handler) private void PassTurn(double beat, bool moveCamera, double intervalStartBeat, float intervalLength)
{ {
if (crHandlerInstance.queuedEvents.Count > 0) var relevantInputs = GrabAllInputsBetween(intervalStartBeat, intervalStartBeat + intervalLength);
if (relevantInputs.Count > 0)
{ {
BeatAction.New(instance.gameObject, new List<BeatAction.Action>() BeatAction.New(instance.gameObject, new List<BeatAction.Action>()
{ {
@ -1024,25 +1000,38 @@ namespace HeavenStudio.Games
}), }),
new BeatAction.Action(beat -0.25, delegate new BeatAction.Action(beat -0.25, delegate
{ {
List<CallAndResponseHandler.CallAndResponseEvent> crEvents = handler.queuedEvents; List<double> riffUsedBeats = new List<double>();
List<double> bendUsedBeats = new();
foreach (var crEvent in relevantInputs)
{
if (!crEvent["respond"]) continue;
double relativeBeat = crEvent.beat - intervalStartBeat;
if (crEvent.datamodel == "rockers/riff")
{
RiqEntity foundEvent = riffEvents.Find(x => x.beat == crEvent.beat);
if ((foundEvent == null || (riffUsedBeats.Count > 0 && riffUsedBeats.Contains((float)foundEvent.beat))) && riffEvents.Count > 1) continue;
riffUsedBeats.Add(crEvent.beat);
foreach (var crEvent in crEvents)
{
if (crEvent.tag == "riff")
{
RockersInput riffComp = Instantiate(rockerInputRef, transform); RockersInput riffComp = Instantiate(rockerInputRef, transform);
riffComp.Init(crEvent["gleeClub"], new int[6] { crEvent["1"], crEvent["2"], crEvent["3"], crEvent["4"], crEvent["5"], crEvent["6"] }, beat, crEvent.relativeBeat, riffComp.Init(crEvent["gcS"], new int[6] { crEvent["1S"], crEvent["2S"], crEvent["3S"], crEvent["4S"], crEvent["5S"], crEvent["6S"] }, beat, relativeBeat,
(PremadeSamples)crEvent["sample"], crEvent["sampleTones"]); (PremadeSamples)crEvent["sampleS"], crEvent["pitchSampleS"]);
ScheduleInput(beat, crEvent.relativeBeat + crEvent.length, InputType.STANDARD_DOWN, JustMute, MuteMiss, Empty); if (crEvent.length > 0.5f) ScheduleAutoplayInput(beat, relativeBeat + crEvent.length, InputType.STANDARD_DOWN, JustMute, MuteMiss, Empty);
else ScheduleInput(beat, relativeBeat + crEvent.length, InputType.STANDARD_DOWN, JustMute, MuteMiss, Empty);
} }
else if (crEvent.tag == "bend") else
{ {
if (riffEvents.Count == 0) continue;
RiqEntity foundEvent = bendEvents.Find(x => x.beat == crEvent.beat);
if ((foundEvent == null || (bendUsedBeats.Count > 0 && bendUsedBeats.Contains((float)foundEvent.beat))) && bendEvents.Count > 1) continue;
RiqEntity riffEventToCheck = riffEvents.Find(x => crEvent.beat >= x.beat && crEvent.beat < x.beat + x.length);
if (riffEventToCheck == null) continue;
bendUsedBeats.Add(beat);
RockerBendInput bendComp = Instantiate(rockerBendInputRef, transform); RockerBendInput bendComp = Instantiate(rockerBendInputRef, transform);
bendComp.Init(crEvent["Pitch"], beat, crEvent.relativeBeat); bendComp.Init(crEvent["1S"], beat, relativeBeat);
ScheduleInput(beat, crEvent.relativeBeat + crEvent.length, InputType.DIRECTION_UP, JustUnBend, UnBendMiss, Empty); ScheduleAutoplayInput(beat, relativeBeat + crEvent.length, InputType.DIRECTION_UP, JustUnBend, UnBendMiss, Empty);
} }
} }
handler.queuedEvents.Clear();
}), }),
new BeatAction.Action(beat, delegate new BeatAction.Action(beat, delegate
{ {

View file

@ -206,7 +206,6 @@ namespace HeavenStudio.Games
public Sprite redArrowSprite; public Sprite redArrowSprite;
public static WorkingDough instance; public static WorkingDough instance;
private static CallAndResponseHandler crHandlerInstance;
void Awake() void Awake()
{ {
@ -232,7 +231,7 @@ namespace HeavenStudio.Games
shipObject.SetActive(!bgDisabled && !shipOnly); shipObject.SetActive(!bgDisabled && !shipOnly);
} }
private static List<RiqEntity> GetAllBallsInBetweenBeat(double beat, double endBeat) private List<RiqEntity> GetAllBallsInBetweenBeat(double beat, double endBeat)
{ {
List<RiqEntity> ballEvents = EventCaller.GetAllInGameManagerList("workingDough", new string[] { "small ball", "big ball" }); List<RiqEntity> ballEvents = EventCaller.GetAllInGameManagerList("workingDough", new string[] { "small ball", "big ball" });
List<RiqEntity> tempEvents = new(); List<RiqEntity> tempEvents = new();
@ -247,11 +246,17 @@ namespace HeavenStudio.Games
return tempEvents; return tempEvents;
} }
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];
}
public void SetIntervalStart(double beat, double gameSwitchBeat, float interval = 8f, bool autoPassTurn = true) public void SetIntervalStart(double beat, double gameSwitchBeat, float interval = 8f, bool autoPassTurn = true)
{ {
CallAndResponseHandler newHandler = new();
crHandlerInstance = newHandler;
crHandlerInstance.StartInterval(beat, interval);
List<RiqEntity> relevantBalls = GetAllBallsInBetweenBeat(beat, beat + interval); List<RiqEntity> relevantBalls = GetAllBallsInBetweenBeat(beat, beat + interval);
bool hasBigBall = false; bool hasBigBall = false;
foreach (var ball in relevantBalls) foreach (var ball in relevantBalls)
@ -260,17 +265,14 @@ namespace HeavenStudio.Games
if (ball.beat >= gameSwitchBeat) if (ball.beat >= gameSwitchBeat)
{ {
SpawnBall(ball.beat - 1, isBig, isBig && ball["hasGandw"]); SpawnBall(ball.beat - 1, isBig, isBig && ball["hasGandw"]);
OnSpawnBall(ball.beat, isBig, isBig && ball["hasGandw"]); OnSpawnBall(ball.beat, isBig);
}
else
{
OnSpawnBallInactive(ball.beat, isBig, isBig && ball["hasGandw"]);
} }
if (isBig) hasBigBall = true; if (isBig) hasBigBall = true;
} }
Debug.Log(autoPassTurn);
if (autoPassTurn) if (autoPassTurn)
{ {
PassTurn(beat + interval, interval, newHandler); PassTurn(beat + interval, interval, beat);
} }
BeatAction.New(ballTransporterLeftNPC, new List<BeatAction.Action>() BeatAction.New(ballTransporterLeftNPC, new List<BeatAction.Action>()
{ {
@ -305,10 +307,12 @@ namespace HeavenStudio.Games
private void PassTurnStandalone(double beat) private void PassTurnStandalone(double beat)
{ {
if (crHandlerInstance != null) PassTurn(beat, crHandlerInstance.intervalLength, crHandlerInstance); RiqEntity lastInterval = GetLastIntervalBeforeBeat(beat);
if (lastInterval == null) return;
PassTurn(beat, lastInterval.length, lastInterval.beat);
} }
private void PassTurn(double beat, double length, CallAndResponseHandler crHandler) private void PassTurn(double beat, double length, double startBeat)
{ {
BeatAction.New(instance.gameObject, new List<BeatAction.Action>() BeatAction.New(instance.gameObject, new List<BeatAction.Action>()
{ {
@ -316,15 +320,17 @@ namespace HeavenStudio.Games
{ {
ballTransporterRightPlayer.GetComponent<Animator>().Play("BallTransporterRightOpen", 0, 0); ballTransporterRightPlayer.GetComponent<Animator>().Play("BallTransporterRightOpen", 0, 0);
ballTransporterLeftPlayer.GetComponent<Animator>().Play("BallTransporterLeftOpen", 0, 0); ballTransporterLeftPlayer.GetComponent<Animator>().Play("BallTransporterLeftOpen", 0, 0);
if (crHandler.queuedEvents.Count > 0) var relevantBallEvents = GetAllBallsInBetweenBeat(startBeat, startBeat + length);
if (relevantBallEvents.Count > 0)
{ {
bool hasBig = false; bool hasBig = false;
foreach (var ball in crHandler.queuedEvents) foreach (var ball in relevantBallEvents)
{ {
SpawnPlayerBall(beat + ball.relativeBeat - 1, ball.tag == "big", ball["hasGandw"]); double relativeBeat = ball.beat - startBeat;
if (ball.tag == "big") hasBig = true; bool isBig = ball.datamodel == "workingDough/big ball";
SpawnPlayerBall(beat + relativeBeat - 1, isBig, isBig ? ball["hasGandw"] : false);
if (isBig) hasBig = true;
} }
crHandler.queuedEvents.Clear();
bigModePlayer = hasBig; bigModePlayer = hasBig;
if (bigModePlayer) if (bigModePlayer)
{ {
@ -335,7 +341,7 @@ namespace HeavenStudio.Games
new BeatAction.Action(beat + 1, delegate new BeatAction.Action(beat + 1, delegate
{ {
if (gandwHasEntered && !bgDisabled) gandwAnim.Play("MrGameAndWatchLeverDown", 0, 0); if (gandwHasEntered && !bgDisabled) gandwAnim.Play("MrGameAndWatchLeverDown", 0, 0);
if (crHandlerInstance == null || !crHandlerInstance.IntervalIsActive()) if (beat + 1 > GetLastIntervalBeforeBeat(beat + 1).beat + GetLastIntervalBeforeBeat(beat + 1).length)
{ {
ballTransporterLeftNPC.GetComponent<Animator>().Play("BallTransporterLeftClose", 0, 0); ballTransporterLeftNPC.GetComponent<Animator>().Play("BallTransporterLeftClose", 0, 0);
ballTransporterRightNPC.GetComponent<Animator>().Play("BallTransporterRightClose", 0, 0); ballTransporterRightNPC.GetComponent<Animator>().Play("BallTransporterRightClose", 0, 0);
@ -381,24 +387,8 @@ namespace HeavenStudio.Games
}); });
} }
public static void OnSpawnBallInactive(double beat, bool isBig, bool hasGandw) public void OnSpawnBall(double beat, bool isBig)
{ {
if (crHandlerInstance == null)
{
crHandlerInstance = new CallAndResponseHandler();
}
crHandlerInstance.AddEvent(beat, 0, isBig ? "big" : "small", new List<CallAndResponseHandler.CallAndResponseEventParam>()
{
new CallAndResponseHandler.CallAndResponseEventParam("hasGandw", hasGandw)
});
}
public void OnSpawnBall(double beat, bool isBig, bool hasGandw)
{
crHandlerInstance.AddEvent(beat, 0, isBig ? "big" : "small", new List<CallAndResponseHandler.CallAndResponseEventParam>()
{
new CallAndResponseHandler.CallAndResponseEventParam("hasGandw", hasGandw)
});
SoundByte.PlayOneShotGame(isBig ? "workingDough/hitBigOther" : "workingDough/hitSmallOther", beat); SoundByte.PlayOneShotGame(isBig ? "workingDough/hitBigOther" : "workingDough/hitSmallOther", beat);
SoundByte.PlayOneShotGame(isBig ? "workingDough/bigOther" : "workingDough/smallOther", beat); SoundByte.PlayOneShotGame(isBig ? "workingDough/bigOther" : "workingDough/smallOther", beat);
} }
@ -445,19 +435,6 @@ namespace HeavenStudio.Games
}); });
} }
} }
void OnDestroy()
{
if (crHandlerInstance != null && !Conductor.instance.isPlaying)
{
crHandlerInstance = null;
}
foreach (var evt in scheduledInputs)
{
evt.Disable();
}
}
public override void OnGameSwitch(double beat) public override void OnGameSwitch(double beat)
{ {
if (Conductor.instance.isPlaying && !Conductor.instance.isPaused) if (Conductor.instance.isPlaying && !Conductor.instance.isPaused)
@ -473,11 +450,6 @@ namespace HeavenStudio.Games
} }
} }
public override void OnPlay(double beat)
{
crHandlerInstance = null;
}
void Update() void Update()
{ {
if (spaceshipRising && !bgDisabled) spaceshipAnimator.DoScaledAnimation("RiseSpaceship", risingStartBeat, risingLength); if (spaceshipRising && !bgDisabled) spaceshipAnimator.DoScaledAnimation("RiseSpaceship", risingStartBeat, risingLength);