using System.Collections; using System.Collections.Generic; using UnityEngine; using TMPro; using UnityEngine.UI; using System.IO; using AibisDream.FixSystem; using Cinemachine; using AibisDream.Framework; using Yarn.Unity; namespace AibisDream { public class ExpressionManager : MonoBehaviour { public GameObject expressView; public TMP_Text totalPointsText; public int totalPoints = 10; public TMP_Text driverSlotText; public TMP_Text logOutput; public Button matchButton; public Button applyAndTestButton; public GameObject matchResultsPanel; public GameObject driverButtonPrefab; public string currentUser = "UserA"; private int[] valuesCurrent = new int[5]; private DriverProfile currentDriver = null; private DriverDatabase db = new DriverDatabase(); private List currentResultButtons = new List(); void Start() { //CloseView(); FixSystemCenter.SystemDic.Register(this); var virtualCam = transform.Find("Expression Camera").GetComponent(); var virtualCam2 = transform.Find("Expression Deep Camera").GetComponent(); CameraKit.Instance.RegisterCamera(CameraEnum.Expression, virtualCam); CameraKit.Instance.RegisterCamera(CameraEnum.ExpressionDeep, virtualCam2); db.LoadFromCSV(Path.Combine(Application.streamingAssetsPath, "drivers.csv")); matchButton.onClick.AddListener(MatchDriver); applyAndTestButton.onClick.AddListener(ApplyAndTestDriver); UpdateUI(); } public void OpenView() { expressView.SetActive(true); } public void CloseView() { expressView.SetActive(false); } public void AdjustValue(int index, int delta) { if (delta > 0 && totalPoints <= 0) return; if (delta < 0 && valuesCurrent[index] <= 0) return; if (valuesCurrent[index] + delta > 5) return; valuesCurrent[index] += delta; totalPoints -= delta; CheckDriverStillValid(); UpdateUI(); } void UpdateUI() { totalPointsText.text = $"剩余点数: {totalPoints}"; } void MatchDriver() { currentResultButtons.ForEach(btn => Destroy(btn)); currentResultButtons.Clear(); var matches = db.MatchDrivers( valuesCurrent[0], valuesCurrent[1], valuesCurrent[2], valuesCurrent[3], valuesCurrent[4]); if (matches.Count > 0) { matchResultsPanel.SetActive(true); foreach (var driver in matches) { var btnObj = Instantiate(driverButtonPrefab, matchResultsPanel.transform); var text = btnObj.GetComponentInChildren(); if (text) text.text = driver.Name; var btn = btnObj.GetComponent