2025-02-17 14:09:17 -05:00
|
|
|
using UnityEngine;
|
|
|
|
|
|
|
|
|
|
public class PlayerLives : MonoBehaviour
|
|
|
|
|
{
|
|
|
|
|
public int maxLives = 3;
|
|
|
|
|
public int currentLives;
|
|
|
|
|
|
|
|
|
|
private void Start()
|
|
|
|
|
{
|
2025-02-17 18:23:05 -05:00
|
|
|
if (GameManager.gameMode == GameManager.GameMode.freeForAll)
|
2025-02-17 14:09:17 -05:00
|
|
|
{
|
|
|
|
|
currentLives = maxLives;
|
|
|
|
|
}
|
|
|
|
|
else //add more gamemodes and their lives here
|
|
|
|
|
{
|
|
|
|
|
currentLives = 0;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
public void PlayerDied()
|
|
|
|
|
{
|
2025-02-17 18:23:05 -05:00
|
|
|
if (GameManager.gameMode == GameManager.GameMode.freeForAll)
|
2025-02-17 14:09:17 -05:00
|
|
|
{
|
|
|
|
|
currentLives--;
|
|
|
|
|
if (currentLives <= 0)
|
|
|
|
|
{
|
|
|
|
|
//add Game over sequence;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
RespawnPlayer();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
private void RespawnPlayer()
|
|
|
|
|
{
|
|
|
|
|
RespawnOnTriggerEnter respawnScript = GetComponent<RespawnOnTriggerEnter>();
|
|
|
|
|
if (respawnScript != null)
|
|
|
|
|
{
|
|
|
|
|
transform.position = respawnScript.spawnPoint;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|