TO SQUASH: Changes.

This commit is contained in:
2026-07-18 23:30:43 -04:00
parent e0c95e192b
commit c7bc76ce98
32 changed files with 3123 additions and 192 deletions
@@ -1,5 +1,5 @@
fileFormatVersion: 2
guid: ae5479cb3e81a6773b311e88ba24952d
guid: 48872dd0fd9e46208b93aa56c37e8ba3
folderAsset: yes
DefaultImporter:
externalObjects: {}
+56
View File
@@ -0,0 +1,56 @@
using UnityEngine;
using System.Collections;
public class ScoreChecker : MonoBehaviour
{
public AudioSource winSound;
public AudioSource loseSound;
public Fader fadeOut;
// Start is called once before the first execution of Update after the MonoBehaviour is created
void Start()
{
}
// Update is called once per frame
void Update()
{
}
public void resetFader()
{
Invoke(nameof(checkScore), 0.5f);
}
private IEnumerator PlayAudioThenActivateGameObject(AudioSource audio, bool showGui)
{
audio.Play();
if (showGui) {
// Activate your GUI here
} else {
yield return new WaitUntil(() => audio.time >= audio.clip.length);
fadeOut.resetFader();
}
}
void checkScore()
{
int currentScore = PlayerPrefs.GetInt("CurrentScore");
AudioSource audio = null;
bool showGui = false;
if (GameSetup.IsHighScore(currentScore)) {
audio = winSound;
showGui = true;
} else {
audio = loseSound;
}
StartCoroutine(PlayAudioThenActivateGameObject(audio, showGui));
}
}
@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: c7d837793868a819eb438a6336078dd7
+66
View File
@@ -0,0 +1,66 @@
using UnityEngine;
public class GameSetup
{
public static void InitializeGame()
{
for (int i = 0; i < 8; i++) {
if (!PlayerPrefs.HasKey($"Score_{i}")) {
PlayerPrefs.SetInt($"Score_{i}", 0);
}
if (!PlayerPrefs.HasKey($"Level_{i}")) {
PlayerPrefs.SetInt($"Level_{i}", 0);
}
if (!PlayerPrefs.HasKey($"Name_{i}")) {
PlayerPrefs.SetString($"Name_{i}", "");
}
}
Debug.Log("Game Initialized");
}
public static void ZapScores()
{
for (int i = 0; i < 8; i++) {
PlayerPrefs.SetInt($"Score_{i}", 0);
PlayerPrefs.SetInt($"Level_{i}", 0);
PlayerPrefs.SetString($"Name_{i}", "");
}
Debug.Log("Scores Reset");
}
public static void InsertScore(int score, int level, string name)
{
for (int i = 0; i < 8; i++) {
int currentScore = PlayerPrefs.GetInt($"Score_{i}");
if (score > currentScore) {
// Shift lower scores down
for (int j = 7; j > i; j--) {
PlayerPrefs.SetInt($"Score_{j}", PlayerPrefs.GetInt($"Score_{j - 1}"));
PlayerPrefs.SetInt($"Level_{j}", PlayerPrefs.GetInt($"Level_{j - 1}"));
PlayerPrefs.SetString($"Name_{j}", PlayerPrefs.GetString($"Name_{j - 1}"));
}
// Insert new score
PlayerPrefs.SetInt($"Score_{i}", score);
PlayerPrefs.SetInt($"Level_{i}", level);
PlayerPrefs.SetString($"Name_{i}", name);
break;
}
}
Debug.Log($"Inserted Score: {score}, Level: {level}, Name: {name}");
}
public static bool IsHighScore(int score)
{
for (int i = 0; i < 8; i++) {
int currentScore = PlayerPrefs.GetInt($"Score_{i}");
if (score > currentScore) {
return true;
}
}
return false;
}
}
+2
View File
@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 9f9900f9b8d6afbc89d2d879d7b5783f
+1
View File
@@ -35,6 +35,7 @@ public class Intro : FadeCallback
}
music.Stop();
faderScript.Invoke("resetFader", 0.0f);
}
private IEnumerator PlayAudioThenActivateGameObject()
+4 -2
View File
@@ -5,7 +5,7 @@ public class IntroSkipper : MonoBehaviour
{
public Intro fadeIn;
public Fader fadeOut;
public Fader fadeOut = null;
// Start is called once before the first execution of Update after the MonoBehaviour is created
void Start()
@@ -24,7 +24,9 @@ public class IntroSkipper : MonoBehaviour
mouse != null && mouse.leftButton.wasPressedThisFrame)
{
fadeIn.forceStopAudioCoroutine();
fadeOut.resetFader();
if (fadeOut != null) {
fadeOut.resetFader();
}
}
}
}
+8
View File
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: eddef7e8d7ef07ad2a01247a9a68684c
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
+21
View File
@@ -0,0 +1,21 @@
using UnityEngine;
public class MainMenu : MonoBehaviour
{
// Start is called once before the first execution of Update after the MonoBehaviour is created
void Start()
{
}
void Awake()
{
GameSetup.InitializeGame();
}
// Update is called once per frame
void Update()
{
}
}
+2
View File
@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 3d0d9341818a50ef8b0e61be1b3d7f88
@@ -1,24 +0,0 @@
using UnityEngine;
public class SplashScreen : FadeCallback
{
public AudioSource yeah; // Reference to the AudioSource component for playing the sound effect
public Fader faderScript; // Reference to the Fader script for handling the fade effect
// Start is called once before the first execution of Update after the MonoBehaviour is created
void Start() { }
// Update is called once per frame
void Update() { }
public override void OnFadeStarted()
{
yeah.PlayDelayed(1.0f);
}
public override void OnFadeComplete()
{
faderScript.resetFader();
}
}
@@ -1,2 +0,0 @@
fileFormatVersion: 2
guid: 09d7151b5eeb9b9a0834eb4821a03f34