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 reporterShouldHeart;
private bool hitPose; private bool hitPose;
private bool shouldNotInput; private bool shouldNotInput;
private bool keepZoomOut;
private Sound kidsLaugh; private Sound kidsLaugh;
private int currentPose; private int currentPose;
private EasingFunction.Ease lastEase; private EasingFunction.Ease lastEase;
@ -156,14 +157,7 @@ namespace HeavenStudio.Games
void OnDestroy() void OnDestroy()
{ {
if (queuedPoses.Count > 0) queuedPoses.Clear(); if (queuedPoses.Count > 0) queuedPoses.Clear();
} Jukebox.KillLoop(kidsLaugh, 2f);
void OnGameSwitch(float beat)
{
shouldNotInput = false;
shouldBop = true;
lastCamPos = new Vector3(0, 0, -10);
currentCamPos = new Vector3(0, 0, -10);
} }
public override void OnTimeChange() public override void OnTimeChange()
@ -191,6 +185,7 @@ namespace HeavenStudio.Games
wrestlerAnim.Play("Idle", 0, 0); wrestlerAnim.Play("Idle", 0, 0);
reporterAnim.Play("IdleReporter", 0, 0); reporterAnim.Play("IdleReporter", 0, 0);
shouldNotInput = false; shouldNotInput = false;
shouldBop = true;
} }
void Update() void Update()
@ -199,15 +194,18 @@ namespace HeavenStudio.Games
if (cond.isPlaying && !cond.isPaused) 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 (UnityEngine.Random.Range(1, 18) == 1) if (isPlaying(wrestlerAnim, "Idle") && shouldBop)
{ {
wrestlerAnim.DoScaledAnimationAsync("BopPec"); if (UnityEngine.Random.Range(1, 18) == 1)
} {
else wrestlerAnim.DoScaledAnimationAsync("BopPec");
{ }
wrestlerAnim.DoScaledAnimationAsync("Bop"); else
{
wrestlerAnim.DoScaledAnimationAsync("Bop");
}
} }
} }
if (PlayerInput.Pressed() && !IsExpectingInputNow(InputType.STANDARD_DOWN) && !shouldNotInput) if (PlayerInput.Pressed() && !IsExpectingInputNow(InputType.STANDARD_DOWN) && !shouldNotInput)
@ -247,10 +245,15 @@ namespace HeavenStudio.Games
} }
float normalizedBeat = Conductor.instance.GetPositionFromBeat(currentZoomCamBeat, 2.5f); float normalizedBeat = Conductor.instance.GetPositionFromBeat(currentZoomCamBeat, 2.5f);
float normalizedShouldStopBeat = Conductor.instance.GetPositionFromBeat(currentZoomCamBeat, 3.99f);
if (normalizedBeat >= 0) 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); GameCamera.additionalPosition = new Vector3(currentCamPos.x, currentCamPos.y, currentCamPos.z + 10);
} }
@ -275,138 +278,7 @@ namespace HeavenStudio.Games
{ {
foreach (var p in queuedPoses) foreach (var p in queuedPoses)
{ {
if (p.newspaperBeats > 0) QueuePose(p.beat, p.keepZoomedOut, p.newspaperBeats);
{
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);
})
});
}
}
} }
queuedPoses.Clear(); queuedPoses.Clear();
} }
@ -539,125 +411,7 @@ namespace HeavenStudio.Games
}, forcePlay: true); }, forcePlay: true);
if (GameManager.instance.currentGame == "ringside") if (GameManager.instance.currentGame == "ringside")
{ {
if (newspaperBeats > 0) Ringside.instance.QueuePose(beat, keepZoomedOut, newspaperBeats);
{
Ringside.instance.reporterShouldHeart = true;
}
else
{
Ringside.instance.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; }),
});
if (!keepZoomedOut)
{
if (newspaperBeats > 0)
{
BeatAction.New(instance.gameObject, new List<BeatAction.Action>()
{
new BeatAction.Action(beat + 3f, delegate
{
Ringside.instance.blackVoid.color = Color.black;
Ringside.instance.newspaper.SetActive(true);
if (UnityEngine.Random.Range(1, 3) == 1)
{
Ringside.instance.newspaper.GetComponent<Animator>().Play("NewspaperEnter", 0, 0);
}
else
{
Ringside.instance.newspaper.GetComponent<Animator>().Play("NewspaperEnterRight", 0, 0);
}
if (!Ringside.instance.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);
}
else
{
Ringside.instance.wrestlerNewspaperAnim.Play($"Pose{Ringside.instance.currentPose}Newspaper", 0, 0);
Ringside.instance.reporterNewspaperAnim.Play("HeartReporterNewspaper", 0, 0);
Ringside.instance.hitPose = false;
}
}),
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);
})
});
}
else
{
BeatAction.New(instance.gameObject, new List<BeatAction.Action>()
{
new BeatAction.Action(beat + 3.99, delegate
{
Ringside.instance.lastCamPos = new Vector3(0, 0, -10);
Ringside.instance.currentCamPos = new Vector3(0, 0, -10);
})
});
}
}
else
{
BeatAction.New(instance.gameObject, new List<BeatAction.Action>()
{
new BeatAction.Action(beat + 2.5f, delegate
{
Ringside.instance.lastCamPos = Ringside.instance.currentCamPos;
})
});
if (newspaperBeats > 0)
{
BeatAction.New(instance.gameObject, new List<BeatAction.Action>()
{
new BeatAction.Action(beat + 3f, delegate
{
Ringside.instance.blackVoid.color = Color.black;
Ringside.instance.newspaper.SetActive(true);
if (UnityEngine.Random.Range(1, 3) == 1)
{
Ringside.instance.newspaper.GetComponent<Animator>().Play("NewspaperEnter", 0, 0);
}
else
{
Ringside.instance.newspaper.GetComponent<Animator>().Play("NewspaperEnterRight", 0, 0);
}
if (!Ringside.instance.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);
}
else
{
Ringside.instance.wrestlerNewspaperAnim.Play($"Pose{Ringside.instance.currentPose}Newspaper", 0, 0);
Ringside.instance.reporterNewspaperAnim.Play("HeartReporterNewspaper", 0, 0);
Ringside.instance.hitPose = false;
}
}),
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);
})
});
}
}
} }
else else
{ {
@ -665,9 +419,134 @@ namespace HeavenStudio.Games
} }
} }
public void QueuePose(float beat, bool keepZoomedOut, float newspaperBeats)
{
if (newspaperBeats > 0)
{
reporterShouldHeart = true;
}
else
{
reporterShouldHeart = false;
}
BeatAction.New(instance.gameObject, new List<BeatAction.Action>()
{
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)
{
if (newspaperBeats > 0)
{
BeatAction.New(instance.gameObject, new List<BeatAction.Action>()
{
new BeatAction.Action(beat + 3f, delegate
{
keepZoomOut = true;
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 = true;
}
}),
new BeatAction.Action(beat + 3f + newspaperBeats, delegate
{
blackVoid.color = new Color(1f, 1f, 1f, 0);
newspaper.SetActive(false);
lastCamPos = new Vector3(0, 0, -10);
Jukebox.KillLoop(kidsLaugh, 0.25f);
keepZoomOut = false;
})
});
}
else
{
BeatAction.New(instance.gameObject, new List<BeatAction.Action>()
{
new BeatAction.Action(beat + 3.99f, delegate
{
lastCamPos = new Vector3(0, 0, -10);
keepZoomOut = false;
}),
});
}
}
else
{
BeatAction.New(instance.gameObject, new List<BeatAction.Action>()
{
new BeatAction.Action(beat + 2.5f, delegate
{
lastCamPos = currentCamPos;
keepZoomOut = true;
})
});
if (newspaperBeats > 0)
{
BeatAction.New(instance.gameObject, new List<BeatAction.Action>()
{
new BeatAction.Action(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 = true;
}
}),
new BeatAction.Action(beat + 3f + newspaperBeats, delegate
{
blackVoid.color = new Color(1f, 1f, 1f, 0);
newspaper.SetActive(false);
Jukebox.KillLoop(kidsLaugh, 0.25f);
})
});
}
}
}
private void UpdateCameraZoom() private void UpdateCameraZoom()
{ {
if (currentZoomIndex < allCameraEvents.Count && currentZoomIndex >= 0) if (currentZoomIndex < allCameraEvents.Count && currentZoomIndex >= 0)
{ {
currentZoomCamBeat = allCameraEvents[currentZoomIndex].beat; currentZoomCamBeat = allCameraEvents[currentZoomIndex].beat;