상점 UI 포션 MVP 패턴 추가

This commit is contained in:
Mingu Kim
2025-06-08 23:07:23 +09:00
parent 66ee4d6d2e
commit b125bc748a
4 changed files with 150 additions and 47 deletions

View File

@@ -14,10 +14,24 @@ namespace TON
[SerializeField] private TextMeshProUGUI title;
[SerializeField] private TextMeshProUGUI txtPrice;
[SerializeField] private Button buyButton;
public void Bind(ShopItemPresenter presenter)
{
presenter.Price.Subscribe(text => txtPrice.text = text.ToString()).AddTo(this);
presenter.PotionType.CombineLatest(presenter.Quantity, (type, quantity)=> $"{type} 포션 {quantity}개")
.Subscribe(text => title.text = text)
.AddTo(this);
presenter.BuyCommand.BindTo(buyButton).AddTo(this);
}
[ContextMenu("Bind")]
public void BindReference()
{
image = transform.Find("ItemLayout/ItemImage").GetComponent<Image>();
title = transform.Find("ItemLayout/Text (TMP)").GetComponent<TextMeshProUGUI>();
txtPrice = transform.Find("ItemLayout/Button/Text (TMP)").GetComponent<TextMeshProUGUI>();
buyButton = transform.Find("ItemLayout/Button").GetComponent<Button>();
}
}