TO SQUASH: Added shooting bars.

This commit is contained in:
2026-08-05 01:23:47 -04:00
parent 2c7e02887c
commit c91a405227
30 changed files with 7987 additions and 98 deletions
+34 -2
View File
@@ -30,12 +30,18 @@ public class Player : MonoBehaviour
public Fader fader;
public GameObject horizontalBarrierPrefab;
public GameObject verticalBarrierPrefab;
private bool flipped = false;
private bool gameOver = false;
private AudioSource audioSource;
private bool canFire = true;
// Start is called once before the first execution of Update after the MonoBehaviour is created
void Start()
{
@@ -65,8 +71,8 @@ public class Player : MonoBehaviour
Vector3 mouseWorld = cam.ScreenToWorldPoint(new Vector3(mouseScreen.x, mouseScreen.y, screenZ));
Vector3 extents = playerBounds.extents;
float clampedX = Mathf.Clamp(mouseWorld.x, boardBounds.min.x + extents.x, boardBounds.max.x - extents.x);
float clampedY = Mathf.Clamp(mouseWorld.y, boardBounds.min.y + extents.y, boardBounds.max.y - extents.y);
float clampedX = Mathf.Clamp(mouseWorld.x, boardBounds.min.x + extents.x / 2.0f, boardBounds.max.x - extents.x / 2.0f);
float clampedY = Mathf.Clamp(mouseWorld.y, boardBounds.min.y + extents.y / 2.0f, boardBounds.max.y - extents.y / 2.0f);
transform.position = new Vector3(clampedX, clampedY, transform.position.z);
@@ -85,6 +91,21 @@ public class Player : MonoBehaviour
}
}
if (Mouse.current.leftButton.wasPressedThisFrame && canFire)
{
canFire = false;
audioSource.PlayOneShot(normalShoot);
if (flipped)
{
Instantiate(verticalBarrierPrefab, transform.position, Quaternion.identity);
}
else
{
Instantiate(horizontalBarrierPrefab, transform.position, Quaternion.identity);
}
}
if (gameOver)
{
StartCoroutine(EndGame());
@@ -126,4 +147,15 @@ public class Player : MonoBehaviour
yield return new WaitForSeconds(1.3f);
fader.ResetFader();
}
public void BarrierFinished()
{
canFire = true;
}
public void OnBarHit()
{
// TODO: Lose a life or end the game
canFire = true; // Allow firing again after bar hit
}
}