CapersProject/Assets/02.Scripts/Ui/Tycoon/TycoonResultUi.cs
2024-11-11 20:11:10 +09:00

82 lines
3.0 KiB
C#

using System;
using System.Collections.Generic;
using BlueWater.Tycoons;
using UnityEngine;
using Sirenix.OdinInspector;
using TMPro;
using Unity.VisualScripting;
using UnityEngine.SceneManagement;
using UnityEngine.UI;
using UnityEngine.UIElements;
namespace BlueWater.Uis
{
public class TycoonResultUi : MonoBehaviour
{
private Dictionary<string, int> selectedCard; //선택한 카드(key , 선택당한 갯수)
private float playTime; //플레이 시간
private int round;
[field: SerializeField, CLabel("카드프리펫")]
private GameObject Card;
private GameObject _panel;
[field: SerializeField, CLabel("카드목록(Cards)")]
private GameObject cards;
[field: SerializeField, CLabel("라운드수TextMesh")]
private TextMeshProUGUI roundTextMesh;
[field: SerializeField, CLabel("손님수TextMesh")]
private TextMeshProUGUI customerTextMesh;
[field: SerializeField, CLabel("골드TextMesh")]
private TextMeshProUGUI goldTextMesh;
[field: SerializeField, CLabel("시간TextMesh")]
private TextMeshProUGUI timeTextMesh;
public void Start()
{
_panel = transform.Find("Panel").gameObject;
}
public void Update()
{
playTime += Time.deltaTime; //플레이타임 측정 (일시정지나 메뉴얼보는 시간은 제외)
}
[Button("StartResult")]
public void StartResult()
{
_panel.SetActive(true);
roundTextMesh.text = $"Round : {TycoonManager.Instance.GetCurrentLevelData().Idx}";
goldTextMesh.text = $"Gold : {ES3.Load("EndGold", 0)}";
timeTextMesh.text = (int)playTime / 60 == 0 ? $"Time : {(int)playTime % 60}sec" : $"Time : {(int)playTime/60}min {(int)playTime%60}sec" ;
selectedCard = TycoonManager.Instance.CardDataSo.GetselectedCard(); //카드 정보 가져오기
//카드 정보 가져오기
foreach (var element in selectedCard)
{
GameObject newObject = Instantiate(Card, new Vector3(0, 0, 0), Quaternion.identity);
newObject.GetComponent<TycoonResultCard>().SetImage(TycoonManager.Instance.CardDataSo.GetDataByIdx(element.Key).Sprite);
newObject.GetComponent<TycoonResultCard>().SetText(TycoonManager.Instance.CardDataSo.GetDataByIdx(element.Key).ScriptText);
newObject.GetComponent<TycoonResultCard>().SetCount(element.Value);
newObject.name = element.Key;
newObject.transform.SetParent(cards.transform);
newObject.transform.localPosition = Vector3.zero;
newObject.transform.localRotation = Quaternion.identity;
newObject.transform.localScale = new Vector3(1.0f,1.0f,1.0f);
}
}
public void ButtonContinue()
{
SceneManager.LoadScene("00.TycoonTitle");
}
}
}