ProjectDDD/Assets/_DDD/_Scripts/Restaurant/Ui/RestaurantSettlementUi/SettlementViewModel.cs
2025-09-02 21:34:18 +09:00

64 lines
2.1 KiB
C#

using System;
using TMPro;
using UnityEngine;
namespace DDD.Restaurant
{
public class SettlementViewModel : SimpleViewModel
{
public RestaurantSettlementData SettlementData;
public RestaurantSettlementState SettlementState;
private string _totalRevenue;
public string TotalRevenue
{
get => _totalRevenue;
private set => SetField(ref _totalRevenue, value);
}
private string _normalCustomers;
public string NormalCustomers
{
get => _normalCustomers;
private set => SetField(ref _normalCustomers, value);
}
private string _specialCustomers;
public string SpecialCustomers
{
get => _specialCustomers;
private set => SetField(ref _specialCustomers, value);
}
public Action OnCompletedSettlement;
public override void Initialize()
{
SettlementData = RestaurantData.Instance.SettlementData;
SettlementState = RestaurantState.Instance.SettlementState;
}
public override void Cleanup()
{
}
public void UpdateSettlement(Transform parent)
{
TotalRevenue = $"총 수익 : {SettlementState.TotalRevenue.ToGold()}";
NormalCustomers = $"일반 손님 수 : {SettlementState.NormalCustomers}";
SpecialCustomers = $"스폐셜 손님 수 : {SettlementState.SpecialCustomers}";
Utils.DestroyAllChildren(parent);
int count = 0;
foreach (var soldCookingCount in SettlementState.SoldCookingCounts)
{
count++;
var instance = Instantiate(SettlementData.TextPrefab, parent);
var textMeshProUGUI = instance.GetComponent<TextMeshProUGUI>();
var cookingName = LocalizationManager.Instance.GetName(soldCookingCount.Key);
textMeshProUGUI.text = $"판매된 메뉴{count} : {cookingName} {soldCookingCount.Value}";
}
}
}
}