This commit is contained in:
RochesterX
2025-03-07 16:50:04 -05:00
parent c7fede9552
commit 86a9494a9e
4 changed files with 1462 additions and 4 deletions

View File

@@ -12,6 +12,9 @@ public class GameManager : MonoBehaviour
public event GameEvent EndGameEvent;
public static List<GameObject> players = new List<GameObject>();
public static List<Color> playerColors = new List<Color>();
public float offset = 1f;
public bool gameOver = false;
private void Awake()
{
@@ -32,6 +35,8 @@ public class GameManager : MonoBehaviour
public void StartGame()
{
if (GameManager.players.Count == 0) return;
StartGameEvent?.Invoke();
print("Starting game with mode: " + gameMode + " and map: " + map);
if (gameMode == GameMode.freeForAll)
@@ -39,7 +44,7 @@ public class GameManager : MonoBehaviour
currentLives = maxLives;
foreach (GameObject player in players)
{
player.transform.position = spawnPosition;
player.transform.position = spawnPosition + (players.IndexOf(player) * Vector2.right * offset);
}
}
if (gameMode == GameMode.keepAway)
@@ -113,6 +118,7 @@ public class GameManager : MonoBehaviour
player.SetActive(false);
if (AlivePlayers().Count <= 1)
{
gameOver = true;
EndGameEvent?.Invoke();
print(AlivePlayers()[0].name + " is the winner");
FindFirstObjectByType<PlayerCameraMovement>().WinScene(AlivePlayers()[0]);

View File

@@ -70,7 +70,7 @@ public class PlayerMovement : MonoBehaviour
private void Update()
{
if (damageable.dying) return;
if (damageable.dying || GameManager.Instance.gameOver) return;
Jump();