TO SQUASH: Lots of UI.

This commit is contained in:
2026-08-25 22:24:07 -04:00
parent 71bb746e8a
commit dad4d10207
129 changed files with 5151 additions and 60107 deletions
+50 -6
View File
@@ -28,8 +28,6 @@ public class Player : MonoBehaviour
public AudioClip denied;
public AudioClip victory;
public MusicManager musicManager;
public Fader fader;
@@ -42,6 +40,8 @@ public class Player : MonoBehaviour
public GameObject verticalLaserPrefab;
public int level = 1;
public int lives = 8;
public int score = 0;
@@ -104,6 +104,10 @@ public class Player : MonoBehaviour
private bool killedByShark = false;
private float bonusTimer = bonusDecrementInterval;
private static float bonusDecrementInterval = 0.25f;
// Start is called once before the first execution of Update after the MonoBehaviour is created
void Start()
{
@@ -183,13 +187,31 @@ public class Player : MonoBehaviour
transform.position = new Vector3(clampedX, clampedY, transform.position.z);
}
// Handle bonus countdown and decrement.
if (bonus > 0 && percentCovered < 80)
{
bonusTimer -= Time.deltaTime;
if (bonusTimer <= 0.0f)
{
bonus -= 10;
if (bonus < 0)
{
bonus = 0;
}
bonusTimer = bonusDecrementInterval;
}
}
// Handle keyboard input for flipping, game over, and toggling laser/magnet modes.
if (Keyboard.current != null)
// Disable keyboard input if the player has covered 80% or more of the area.
if (Keyboard.current != null && percentCovered < 80)
{
if (Keyboard.current.spaceKey.wasPressedThisFrame)
{
flipped = !flipped;
// transform.eulerAngles = new Vector3(0, 0, flipped ? 90 : 0);
audioSource.PlayOneShot(flip);
}
@@ -241,6 +263,13 @@ public class Player : MonoBehaviour
}
}
// Player has covered enough area to win the level.
if (percentCovered >= 80)
{
canFire = false;
}
// Check for game over or revival conditions.
if (gameOver)
{
@@ -322,7 +351,7 @@ public class Player : MonoBehaviour
private IEnumerator EndGame()
{
musicManager.pauseMusic();
musicManager.PauseMusic();
audioSource.PlayOneShot(defeat);
yield return new WaitForSeconds(1.3f);
fader.ResetFader();
@@ -523,6 +552,21 @@ public class Player : MonoBehaviour
public void OnWallSpawned(int areaPercentage)
{
canFire = true;
// TODO: Award points based on the area of the spawned wall.
percentCovered += areaPercentage;
score += areaPercentage * 10;
}
public void OnLevelEnd()
{
// Reset the player state for the next level.
canFire = true;
exploding = false;
laserActive = false;
magnetActive = false;
bonus = 3100;
level++;
multiplier = 1.0f;
flipped = false;
percentCovered = 0;
}
}