feat: add core quiz game logic, scoreboard, team machine, player management, and debug view with supporting assets and scene.

This commit is contained in:
2025-11-20 22:10:38 +00:00
parent 63fcfa85f8
commit 04310e71b5
52 changed files with 12518 additions and 1163 deletions

View File

@@ -0,0 +1,54 @@
using UdonSharp;
using UnityEngine;
using UnityEngine.SocialPlatforms.Impl;
using UnityEngine.UI;
using VRC.SDKBase;
using VRC.Udon;
public class ScoreboardRowSpawner : Scoreboard
{
public GameObject rowPrefab;
public Transform rowContainer;
public override void UpdateScoreboard()
{
// Clear existing rows
foreach (Transform child in rowContainer)
{
Destroy(child.gameObject);
}
// Spawn new rows based on player data
VRCPlayerApi[] players = playerManager.GetCurrentPlayers();
foreach (VRCPlayerApi player in players)
{
GameObject newRow = Instantiate(rowPrefab, rowContainer);
Debug.Log("Spawning scoreboard row for player: " + player.displayName);
// Get all TMP_Text components from the children
TMPro.TMP_Text[] textComponents = newRow.GetComponentsInChildren<TMPro.TMP_Text>();
// Set the first TMP_Text to the player's display name
if (textComponents.Length > 0)
{
textComponents[0].text = player.displayName;
}
// Set the second TMP_Text to the player's score
if (textComponents.Length > 1)
{
textComponents[1].text = playerManager.GetScore(player.playerId).ToString();
}
// 3. Set the Background Color
// We get the Image component from the root of the prefab
Image backgroundComponent = newRow.GetComponent<Image>();
if (backgroundComponent != null)
{
backgroundComponent.color = playerManager.GetTeam(player.playerId) == "red" ?
new Color(1f, 0f, 0f, 0.5f) : playerManager.GetTeam(player.playerId) == "blue" ? new Color(0f, 0f, 1f, 0.5f) : new Color(0.5f, 0.5f, 0.5f, 0.5f);
}
}
}
}