Files
M-Gameton-06/Gameton-06/Assets/Gameton/Scripts/UI/ShopItemUI.cs

62 lines
1.6 KiB
C#

using System.Collections;
using System.Collections.Generic;
using TMPro;
using UniRx;
using UnityEngine;
using UnityEngine.UI;
namespace TON
{
// View
public class ShopItemUI : MonoBehaviour
{
[SerializeField] private Image image;
[SerializeField] private TextMeshProUGUI title;
[SerializeField] private TextMeshProUGUI txtPrice;
[SerializeField] private Button buyButton;
public void Bind(ShopItemPresenter presenter)
{
}
}
// Presenter
public class ShopItemPresenter
{
public ReactiveProperty<int> Price { get; set; }
public ReactiveProperty<string> PotionType { get; set; }
public ReactiveProperty<int> Quantity { get; set; }
public ReactiveCommand BuyCommand { get; set; }
private ShopItemModel _model;
public ShopItemPresenter(ShopPresenter shopPresenter, ShopItemModel model)
{
_model = model;
Price = new ReactiveProperty<int>(_model.Price);
PotionType = new ReactiveProperty<string>(_model.PotionType);
Quantity = new ReactiveProperty<int>(_model.Quantity);
BuyCommand = new ReactiveCommand();
BuyCommand.Subscribe(_ => shopPresenter.BuyPotion(this));
}
}
// Model
public class ShopItemModel
{
public int Price;
public string PotionType;
public int Quantity;
public ShopItemModel(int price, string postionType, int quantity)
{
Price = price;
PotionType = postionType;
Quantity = quantity;
}
}
}