CapersProject/Assets/02.Scripts/Ui/Tycoon/TycoonResultUi.cs

86 lines
3.3 KiB
C#
Raw Normal View History

2024-11-07 12:02:00 +00:00
using System;
using System.Collections.Generic;
using BlueWater.Tycoons;
using UnityEngine;
using Sirenix.OdinInspector;
2024-11-11 09:50:41 +00:00
using TMPro;
2024-11-07 12:02:00 +00:00
using Unity.VisualScripting;
2024-11-11 09:50:41 +00:00
using UnityEngine.UI;
2024-11-07 12:02:00 +00:00
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;
2024-11-11 09:50:41 +00:00
[field: SerializeField, CLabel("스크롤렉트")]
private ScrollRect cardScrollRect;
[field: SerializeField, CLabel("라운드수TextMesh")]
private TextMeshProUGUI roundTextMesh;
[field: SerializeField, CLabel("손님수TextMesh")]
private TextMeshProUGUI customerTextMesh;
[field: SerializeField, CLabel("골드TextMesh")]
private TextMeshProUGUI goldTextMesh;
2024-11-07 12:02:00 +00:00
2024-11-11 09:50:41 +00:00
[field: SerializeField, CLabel("시간TextMesh")]
private TextMeshProUGUI timeTextMesh;
2024-11-07 12:02:00 +00:00
public void Start()
{
_panel = transform.Find("Panel").gameObject;
}
public void Update()
{
playTime += Time.deltaTime; //플레이타임 측정 (일시정지나 메뉴얼보는 시간은 제외)
}
[Button("StartResult")]
public void StartResult()
{
_panel.SetActive(true);
2024-11-11 09:50:41 +00:00
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" ;
2024-11-07 12:02:00 +00:00
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;
2024-11-11 09:50:41 +00:00
newObject.transform.SetParent(cards.transform);
2024-11-07 12:02:00 +00:00
newObject.transform.localPosition = Vector3.zero;
newObject.transform.localRotation = Quaternion.identity;
2024-11-11 09:50:41 +00:00
newObject.transform.localScale = new Vector3(1.0f,1.0f,1.0f);
2024-11-07 12:02:00 +00:00
}
2024-11-11 09:50:41 +00:00
// float newHeight = (selectedCard.Count / 5.0f - 2) * 250;
//
// var sizeDelta = cardScrollRect.content.sizeDelta;
// sizeDelta.y = newHeight;
// cardScrollRect.content.sizeDelta = sizeDelta;
2024-11-07 12:02:00 +00:00
}
}
}