This commit is contained in:
RochesterX
2025-03-28 13:00:37 -04:00
parent 4c22943273
commit 451bf78249
13 changed files with 1767 additions and 1287 deletions

View File

@@ -7,6 +7,7 @@ public class GameManager : MonoBehaviour
{
public static GameManager Instance { get; private set; }
public int maxLives = 3;
public float time = 180f;
public delegate void GameEvent();
public event GameEvent StartGameEvent;
public event GameEvent EndGameEvent;
@@ -55,6 +56,7 @@ public class GameManager : MonoBehaviour
}
if (gameMode == GameMode.keepAway)
{
gameTimer.startTime = time;
gameTimer.StartTimer();
foreach (GameObject player in players)
{

View File

@@ -42,13 +42,23 @@ public class LeaderboardManager : MonoBehaviour
public void UpdateLeaderboard()
{
List<KeyValuePair<GameObject, float>> sortedList =
new List<KeyValuePair<GameObject, float>>(GameManager.playerHoldTimes);
List<KeyValuePair<GameObject, float>> sortedList = new List<KeyValuePair<GameObject, float>>(GameManager.playerHoldTimes);
sortedList.Sort((pair1, pair2) => pair2.Value.CompareTo(pair1.Value));
foreach (var player in sortedList)
{
Debug.Log(player.Key.name + " : " + player.Value);
}
// Less fancy sorting system
foreach (var player in sortedList)
{
playerIcons[player.Key].transform.SetSiblingIndex(sortedList.IndexOf(player));
}
//foreach (var key in GameManager.playerHoldTimes)
//{
// print(key.Key.name + " : " + key.Value);
// }
}
}

View File

@@ -21,7 +21,7 @@ public class LifeDisplayManager : MonoBehaviour
for (int i = 0; i < player.GetComponent<Damageable>().lives; i++)
{
GameObject life = Instantiate(lifePrefab, parent);
life.GetComponentInChildren<Image>().color = GameManager.playerColors[GameManager.players.IndexOf(player)];
life.transform.Find("LIFE").GetComponent<Image>().color = GameManager.playerColors[GameManager.players.IndexOf(player)];
lives.Add(life);
}
lifeDisplays.Add(player.GetComponent<Damageable>(), lives);

View File

@@ -40,7 +40,15 @@ public class MusicManager : MonoBehaviour
{
Destroy(child.gameObject);
}
StartCoroutine(PlayPlaylist(sceneToPlaylist[GetActiveSceneNotTitleScreen()]));
try
{
StartCoroutine(PlayPlaylist(sceneToPlaylist[GetActiveSceneNotTitleScreen()]));
}
catch (System.Exception)
{
print("No playlist found for this scene: " + GetActiveSceneNotTitleScreen());
}
}
public void StartPlaylist(string scene)

View File

@@ -6,6 +6,7 @@ public class UseItem : MonoBehaviour
private GameObject heldItem;
private bool isHoldingItem = false;
private float holdStartTime;
public float holdTime;
void Update()
{
@@ -14,7 +15,7 @@ public class UseItem : MonoBehaviour
heldItem.transform.position = transform.position + Vector3.up;
if (GameManager.gameMode == GameManager.GameMode.keepAway)
{
float holdTime = Time.time - holdStartTime;
holdTime += Time.deltaTime;
GameManager.Instance.UpdatePlayerHoldTime(gameObject, holdTime);
}
}