53 lines
1.8 KiB
C#
53 lines
1.8 KiB
C#
using UnityEngine;
|
|
|
|
public class CashierDesk : BaseInteractableObject
|
|
{
|
|
[SerializeField]
|
|
private ContainerSO _containerSO;
|
|
|
|
//_optionsList.Add("Hamburgers - 83$", new Eat(6, 10, 83));
|
|
//_optionsList.Add("Cheesburger - 94$", new Eat(6, 1, 94));
|
|
//_optionsList.Add("Astro chicken - 131$", new Eat(6, 1, 131));
|
|
//_optionsList.Add("Fries - 68$", new Eat(6, 1, 68));
|
|
//_optionsList.Add("Shakes - 108$", new Eat(6, 1, 108));
|
|
//_optionsList.Add("Colas - 73$", new Eat(6, 1, 73));
|
|
|
|
public override void Interact(Player player)
|
|
{
|
|
if (player.IsHoldContainerItem())
|
|
{
|
|
var playerContainer = player.GetContainerItem();
|
|
if (playerContainer.IsSalebleItems())
|
|
{
|
|
var playerItemsList = playerContainer.GetItems();
|
|
player.ClearContainerItem();
|
|
float finalPrice = 0;
|
|
foreach (SellableItemSO item in playerItemsList)
|
|
{
|
|
finalPrice += item.Price;
|
|
}
|
|
|
|
var transform = Instantiate(_containerSO.prefab, _interactionPoint);
|
|
var containerItem = transform.GetComponent<ContainerItem>();
|
|
if (containerItem == null)
|
|
{
|
|
Debug.LogError("Container Item is null");
|
|
return;
|
|
}
|
|
player.Pay(finalPrice);
|
|
foreach (var item in playerContainer.GetItems())
|
|
{
|
|
|
|
var foodItemSO = ScriptableObject.CreateInstance<FoodItemSO>();
|
|
foodItemSO.ItemName = item.ItemName;
|
|
foodItemSO.Energy = 0;
|
|
containerItem.AddItem(foodItemSO);
|
|
}
|
|
player.SetContainerItem(containerItem);
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
}
|