2026-04-22 계산대 프로토 타입
This commit is contained in:
35
Assets/02_Scripts/Shopping/CheckoutMachine.cs
Normal file
35
Assets/02_Scripts/Shopping/CheckoutMachine.cs
Normal file
@@ -0,0 +1,35 @@
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using VRShopping.Items;
|
||||
using VRShopping.UI;
|
||||
|
||||
namespace VRShopping.Interact
|
||||
{
|
||||
public class CheckoutMachine : MonoBehaviour
|
||||
{
|
||||
public int CheckoutSum { get; private set; }
|
||||
|
||||
[SerializeField] private Transform _rowContainer;
|
||||
[SerializeField] private CheckoutProductionRow _rowPrefab;
|
||||
|
||||
private readonly Dictionary<ItemData, CheckoutProductionRow> _rowByItem = new();
|
||||
|
||||
public void AddCheckoutProduction(ItemData itemData)
|
||||
{
|
||||
if (itemData == null) return;
|
||||
|
||||
if (_rowByItem.TryGetValue(itemData, out CheckoutProductionRow row))
|
||||
{
|
||||
row.Bind(itemData, row.Quantity + 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
row = Instantiate(_rowPrefab, _rowContainer);
|
||||
row.Bind(itemData, 1);
|
||||
_rowByItem[itemData] = row;
|
||||
}
|
||||
|
||||
CheckoutSum += itemData.FinalPrice;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user