Ringside: Fixed the camera sometimes being zoomed out on game switch, fixed the newspaper having the miss pose when it shouldn't and fixed the kids laughter playing endlessly. (Generally cleaned up code too) (#260)

* Update Ringside.cs

* make unwanted ringside inputs score misses

update game icons

* Camera doesn't zoom out when it shouldn't

* Fixed the camera fr this time

---------

Co-authored-by: minenice55 <star.elementa@gmail.com>
This commit is contained in:
Rapandrasmus 2023-02-05 20:48:41 +01:00 committed by GitHub
parent 7374066639
commit 3a1820c5b9

View file

@ -141,6 +141,7 @@ namespace HeavenStudio.Games
private bool reporterShouldHeart;
private bool hitPose;
private bool shouldNotInput;
private bool keepZoomOut;
private Sound kidsLaugh;
private int currentPose;
private EasingFunction.Ease lastEase;
@ -156,14 +157,7 @@ namespace HeavenStudio.Games
void OnDestroy()
{
if (queuedPoses.Count > 0) queuedPoses.Clear();
}
void OnGameSwitch(float beat)
{
shouldNotInput = false;
shouldBop = true;
lastCamPos = new Vector3(0, 0, -10);
currentCamPos = new Vector3(0, 0, -10);
Jukebox.KillLoop(kidsLaugh, 2f);
}
public override void OnTimeChange()
@ -191,6 +185,7 @@ namespace HeavenStudio.Games
wrestlerAnim.Play("Idle", 0, 0);
reporterAnim.Play("IdleReporter", 0, 0);
shouldNotInput = false;
shouldBop = true;
}
void Update()
@ -199,7 +194,9 @@ namespace HeavenStudio.Games
if (cond.isPlaying && !cond.isPaused)
{
if (cond.ReportBeat(ref bop.lastReportedBeat, bop.startBeat % 1) && isPlaying(wrestlerAnim, "Idle") && shouldBop)
if (cond.ReportBeat(ref bop.lastReportedBeat, bop.startBeat % 1))
{
if (isPlaying(wrestlerAnim, "Idle") && shouldBop)
{
if (UnityEngine.Random.Range(1, 18) == 1)
{
@ -210,6 +207,7 @@ namespace HeavenStudio.Games
wrestlerAnim.DoScaledAnimationAsync("Bop");
}
}
}
if (PlayerInput.Pressed() && !IsExpectingInputNow(InputType.STANDARD_DOWN) && !shouldNotInput)
{
Ringside.instance.ScoreMiss(0.5);
@ -247,10 +245,15 @@ namespace HeavenStudio.Games
}
float normalizedBeat = Conductor.instance.GetPositionFromBeat(currentZoomCamBeat, 2.5f);
float normalizedShouldStopBeat = Conductor.instance.GetPositionFromBeat(currentZoomCamBeat, 3.99f);
if (normalizedBeat >= 0)
{
if (normalizedBeat > 1)
if (normalizedShouldStopBeat > 1 && !keepZoomOut)
{
GameCamera.additionalPosition = new Vector3(0, 0, 0);
}
else if (normalizedBeat > 1)
{
GameCamera.additionalPosition = new Vector3(currentCamPos.x, currentCamPos.y, currentCamPos.z + 10);
}
@ -275,138 +278,7 @@ namespace HeavenStudio.Games
{
foreach (var p in queuedPoses)
{
if (p.newspaperBeats > 0)
{
reporterShouldHeart = true;
}
else
{
reporterShouldHeart = false;
}
if (cond.songPositionInBeats - 0.05f > p.beat)
{
BeatAction.New(instance.gameObject, new List<BeatAction.Action>()
{
new BeatAction.Action(p.beat, delegate { wrestlerAnim.Play("PreparePoseIdle", 0, 0); }),
});
}
else
{
BeatAction.New(instance.gameObject, new List<BeatAction.Action>()
{
new BeatAction.Action(p.beat, delegate {wrestlerAnim.DoScaledAnimationAsync("PreparePose", 0.25f); }),
});
}
BeatAction.New(instance.gameObject, new List<BeatAction.Action>()
{
new BeatAction.Action(p.beat, delegate {audienceAnim.DoScaledAnimationAsync("PoseAudience", 0.25f); }),
new BeatAction.Action(p.beat, delegate {shouldBop = false; }),
new BeatAction.Action(p.beat + 1, delegate { PoseCheck(p.beat); }),
new BeatAction.Action(p.beat + 3.99f, delegate { wrestlerAnim.Play("Idle", 0, 0); }),
new BeatAction.Action(p.beat + 3.99f, delegate { reporterAnim.Play("IdleReporter", 0, 0); }),
new BeatAction.Action(p.beat + 3.99f, delegate { shouldNotInput = false; }),
new BeatAction.Action(p.beat + 3.99f, delegate {shouldBop = true; }),
});
if (!p.keepZoomedOut)
{
if (p.newspaperBeats > 0)
{
BeatAction.New(instance.gameObject, new List<BeatAction.Action>()
{
new BeatAction.Action(p.beat + 3f, delegate
{
blackVoid.color = Color.black;
newspaper.SetActive(true);
if (UnityEngine.Random.Range(1, 3) == 1)
{
newspaper.GetComponent<Animator>().Play("NewspaperEnter", 0, 0);
}
else
{
newspaper.GetComponent<Animator>().Play("NewspaperEnterRight", 0, 0);
}
if (hitPose)
{
wrestlerNewspaperAnim.Play($"Miss{UnityEngine.Random.Range(1, 7)}Newspaper", 0, 0);
reporterNewspaperAnim.Play("IdleReporterNewspaper", 0, 0);
kidsLaugh = Jukebox.PlayOneShotGame("ringside/kidslaugh", -1, 1, 1, true);
}
else
{
wrestlerNewspaperAnim.Play($"Pose{currentPose}Newspaper", 0, 0);
reporterNewspaperAnim.Play("HeartReporterNewspaper", 0, 0);
hitPose = false;
}
}),
new BeatAction.Action(p.beat + 3f + p.newspaperBeats, delegate
{
blackVoid.color = new Color(1f, 1f, 1f, 0);
newspaper.SetActive(false);
lastCamPos = new Vector3(0, 0, -10);
currentCamPos = new Vector3(0, 0, -10);
Jukebox.KillLoop(kidsLaugh, 0.25f);
})
});
}
else
{
BeatAction.New(instance.gameObject, new List<BeatAction.Action>()
{
new BeatAction.Action(p.beat + 3.99, delegate
{
lastCamPos = new Vector3(0, 0, -10);
currentCamPos = new Vector3(0, 0, -10);
})
});
}
}
else
{
BeatAction.New(instance.gameObject, new List<BeatAction.Action>()
{
new BeatAction.Action(p.beat + 2.5f, delegate
{
lastCamPos = currentCamPos;
})
});
if (p.newspaperBeats > 0)
{
BeatAction.New(instance.gameObject, new List<BeatAction.Action>()
{
new BeatAction.Action(p.beat + 3f, delegate
{
blackVoid.color = Color.black;
newspaper.SetActive(true);
if (UnityEngine.Random.Range(1, 3) == 1)
{
newspaper.GetComponent<Animator>().Play("NewspaperEnter", 0, 0);
}
else
{
newspaper.GetComponent<Animator>().Play("NewspaperEnterRight", 0, 0);
}
if (hitPose)
{
wrestlerNewspaperAnim.Play($"Miss{UnityEngine.Random.Range(1, 7)}Newspaper", 0, 0);
reporterNewspaperAnim.Play("IdleReporterNewspaper", 0, 0);
kidsLaugh = Jukebox.PlayOneShotGame("ringside/kidslaugh", -1, 1, 1, true);
}
else
{
wrestlerNewspaperAnim.Play($"Pose{currentPose}Newspaper", 0, 0);
reporterNewspaperAnim.Play("HeartReporterNewspaper", 0, 0);
hitPose = false;
}
}),
new BeatAction.Action(p.beat + 3f + p.newspaperBeats, delegate
{
blackVoid.color = new Color(1f, 1f, 1f, 0);
newspaper.SetActive(false);
Jukebox.KillLoop(kidsLaugh, 0.25f);
})
});
}
}
QueuePose(p.beat, p.keepZoomedOut, p.newspaperBeats);
}
queuedPoses.Clear();
}
@ -539,24 +411,34 @@ namespace HeavenStudio.Games
}, forcePlay: true);
if (GameManager.instance.currentGame == "ringside")
{
if (newspaperBeats > 0)
{
Ringside.instance.reporterShouldHeart = true;
Ringside.instance.QueuePose(beat, keepZoomedOut, newspaperBeats);
}
else
{
Ringside.instance.reporterShouldHeart = false;
queuedPoses.Add(new QueuedPose { beat = beat, keepZoomedOut = keepZoomedOut, newspaperBeats = newspaperBeats});
}
}
public void QueuePose(float beat, bool keepZoomedOut, float newspaperBeats)
{
if (newspaperBeats > 0)
{
reporterShouldHeart = true;
}
else
{
reporterShouldHeart = false;
}
Ringside.instance.PoseCheck(beat);
BeatAction.New(instance.gameObject, new List<BeatAction.Action>()
{
new BeatAction.Action(beat, delegate { Ringside.instance.audienceAnim.DoScaledAnimationAsync("PoseAudience", 0.25f); }),
new BeatAction.Action(beat, delegate { Ringside.instance.wrestlerAnim.DoScaledAnimationAsync("PreparePose", 0.25f); }),
new BeatAction.Action(beat, delegate { Ringside.instance.shouldBop = false; }),
new BeatAction.Action(beat + 3.99f, delegate { Ringside.instance.wrestlerAnim.Play("Idle", 0, 0); }),
new BeatAction.Action(beat + 3.99f, delegate { Ringside.instance.reporterAnim.Play("IdleReporter", 0, 0); }),
new BeatAction.Action(beat + 3.99f, delegate { Ringside.instance.shouldNotInput = false; }),
new BeatAction.Action(beat + 3.99f, delegate { Ringside.instance.shouldBop = true; }),
new BeatAction.Action(beat, delegate {audienceAnim.DoScaledAnimationAsync("PoseAudience", 0.25f); }),
new BeatAction.Action(beat, delegate {wrestlerAnim.DoScaledAnimationAsync("PreparePose", 0.25f); }),
new BeatAction.Action(beat, delegate {shouldBop = false; }),
new BeatAction.Action(beat + 1, delegate { PoseCheck(beat); }),
new BeatAction.Action(beat + 3.99f, delegate { wrestlerAnim.Play("Idle", 0, 0); }),
new BeatAction.Action(beat + 3.99f, delegate { reporterAnim.Play("IdleReporter", 0, 0); }),
new BeatAction.Action(beat + 3.99f, delegate { shouldNotInput = false; }),
new BeatAction.Action(beat + 3.99f, delegate { shouldBop = true; }),
});
if (!keepZoomedOut)
{
@ -566,36 +448,37 @@ namespace HeavenStudio.Games
{
new BeatAction.Action(beat + 3f, delegate
{
Ringside.instance.blackVoid.color = Color.black;
Ringside.instance.newspaper.SetActive(true);
keepZoomOut = true;
blackVoid.color = Color.black;
newspaper.SetActive(true);
if (UnityEngine.Random.Range(1, 3) == 1)
{
Ringside.instance.newspaper.GetComponent<Animator>().Play("NewspaperEnter", 0, 0);
newspaper.GetComponent<Animator>().Play("NewspaperEnter", 0, 0);
}
else
{
Ringside.instance.newspaper.GetComponent<Animator>().Play("NewspaperEnterRight", 0, 0);
newspaper.GetComponent<Animator>().Play("NewspaperEnterRight", 0, 0);
}
if (!Ringside.instance.hitPose)
if (!hitPose)
{
Ringside.instance.wrestlerNewspaperAnim.Play($"Miss{UnityEngine.Random.Range(1, 7)}Newspaper", 0, 0);
Ringside.instance.reporterNewspaperAnim.Play("IdleReporterNewspaper", 0, 0);
Ringside.instance.kidsLaugh = Jukebox.PlayOneShotGame("ringside/kidslaugh", -1, 1, 1, true);
wrestlerNewspaperAnim.Play($"Miss{UnityEngine.Random.Range(1, 7)}Newspaper", 0, 0);
reporterNewspaperAnim.Play("IdleReporterNewspaper", 0, 0);
kidsLaugh = Jukebox.PlayOneShotGame("ringside/kidslaugh", -1, 1, 1, true);
}
else
{
Ringside.instance.wrestlerNewspaperAnim.Play($"Pose{Ringside.instance.currentPose}Newspaper", 0, 0);
Ringside.instance.reporterNewspaperAnim.Play("HeartReporterNewspaper", 0, 0);
Ringside.instance.hitPose = false;
wrestlerNewspaperAnim.Play($"Pose{currentPose}Newspaper", 0, 0);
reporterNewspaperAnim.Play("HeartReporterNewspaper", 0, 0);
hitPose = true;
}
}),
new BeatAction.Action(beat + 3f + newspaperBeats, delegate
{
Jukebox.KillLoop(Ringside.instance.kidsLaugh, 0.25f);
Ringside.instance.blackVoid.color = new Color(1f, 1f, 1f, 0);
Ringside.instance.newspaper.SetActive(false);
Ringside.instance.lastCamPos = new Vector3(0, 0, -10);
Ringside.instance.currentCamPos = new Vector3(0, 0, -10);
blackVoid.color = new Color(1f, 1f, 1f, 0);
newspaper.SetActive(false);
lastCamPos = new Vector3(0, 0, -10);
Jukebox.KillLoop(kidsLaugh, 0.25f);
keepZoomOut = false;
})
});
}
@ -603,12 +486,13 @@ namespace HeavenStudio.Games
{
BeatAction.New(instance.gameObject, new List<BeatAction.Action>()
{
new BeatAction.Action(beat + 3.99, delegate
new BeatAction.Action(beat + 3.99f, delegate
{
Ringside.instance.lastCamPos = new Vector3(0, 0, -10);
Ringside.instance.currentCamPos = new Vector3(0, 0, -10);
})
lastCamPos = new Vector3(0, 0, -10);
keepZoomOut = false;
}),
});
}
}
else
@ -617,7 +501,8 @@ namespace HeavenStudio.Games
{
new BeatAction.Action(beat + 2.5f, delegate
{
Ringside.instance.lastCamPos = Ringside.instance.currentCamPos;
lastCamPos = currentCamPos;
keepZoomOut = true;
})
});
if (newspaperBeats > 0)
@ -626,48 +511,42 @@ namespace HeavenStudio.Games
{
new BeatAction.Action(beat + 3f, delegate
{
Ringside.instance.blackVoid.color = Color.black;
Ringside.instance.newspaper.SetActive(true);
blackVoid.color = Color.black;
newspaper.SetActive(true);
if (UnityEngine.Random.Range(1, 3) == 1)
{
Ringside.instance.newspaper.GetComponent<Animator>().Play("NewspaperEnter", 0, 0);
newspaper.GetComponent<Animator>().Play("NewspaperEnter", 0, 0);
}
else
{
Ringside.instance.newspaper.GetComponent<Animator>().Play("NewspaperEnterRight", 0, 0);
newspaper.GetComponent<Animator>().Play("NewspaperEnterRight", 0, 0);
}
if (!Ringside.instance.hitPose)
if (!hitPose)
{
Ringside.instance.wrestlerNewspaperAnim.Play($"Miss{UnityEngine.Random.Range(1, 7)}Newspaper", 0, 0);
Ringside.instance.reporterNewspaperAnim.Play("IdleReporterNewspaper", 0, 0);
Ringside.instance.kidsLaugh = Jukebox.PlayOneShotGame("ringside/kidslaugh", -1, 1, 1, true);
wrestlerNewspaperAnim.Play($"Miss{UnityEngine.Random.Range(1, 7)}Newspaper", 0, 0);
reporterNewspaperAnim.Play("IdleReporterNewspaper", 0, 0);
kidsLaugh = Jukebox.PlayOneShotGame("ringside/kidslaugh", -1, 1, 1, true);
}
else
{
Ringside.instance.wrestlerNewspaperAnim.Play($"Pose{Ringside.instance.currentPose}Newspaper", 0, 0);
Ringside.instance.reporterNewspaperAnim.Play("HeartReporterNewspaper", 0, 0);
Ringside.instance.hitPose = false;
wrestlerNewspaperAnim.Play($"Pose{currentPose}Newspaper", 0, 0);
reporterNewspaperAnim.Play("HeartReporterNewspaper", 0, 0);
hitPose = true;
}
}),
new BeatAction.Action(beat + 3f + newspaperBeats, delegate
{
Ringside.instance.blackVoid.color = new Color(1f, 1f, 1f, 0);
Ringside.instance.newspaper.SetActive(false);
Jukebox.KillLoop(Ringside.instance.kidsLaugh, 0.25f);
blackVoid.color = new Color(1f, 1f, 1f, 0);
newspaper.SetActive(false);
Jukebox.KillLoop(kidsLaugh, 0.25f);
})
});
}
}
}
else
{
queuedPoses.Add(new QueuedPose { beat = beat, keepZoomedOut = keepZoomedOut, newspaperBeats = newspaperBeats});
}
}
private void UpdateCameraZoom()
{
if (currentZoomIndex < allCameraEvents.Count && currentZoomIndex >= 0)
{
currentZoomCamBeat = allCameraEvents[currentZoomIndex].beat;