Fridge can store food
This commit is contained in:
@@ -0,0 +1,39 @@
|
||||
using System.Linq;
|
||||
using UnityEngine;
|
||||
|
||||
public class CashierDesk : BaseInteractableObject
|
||||
{
|
||||
[SerializeField]
|
||||
private ContainerSO _containerSO;
|
||||
|
||||
public override void Interact(Player player)
|
||||
{
|
||||
if (player.IsHoldContainerItem())
|
||||
{
|
||||
var playerContainer = player.GetContainerItem();
|
||||
var playerItemsList = playerContainer.GetItems();
|
||||
player.ClearContainerItem();
|
||||
if (playerItemsList.Any())
|
||||
{
|
||||
float finalPrice = 0;
|
||||
foreach (var item in playerItemsList)
|
||||
{
|
||||
finalPrice += item.Price;
|
||||
}
|
||||
|
||||
var transform = Instantiate(_containerSO.prefab, _playerArrivePoint);
|
||||
var containerItem = transform.GetComponent<ContainerItem>();
|
||||
if (containerItem == null)
|
||||
{
|
||||
Debug.LogError("Container Item is null");
|
||||
return;
|
||||
}
|
||||
player.Pay(finalPrice);
|
||||
containerItem.AddItems(playerItemsList);
|
||||
player.SetContainerItem(containerItem);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2b3df7729a1cd4e479add673fa0f9b76
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,12 +1,5 @@
|
||||
using UnityEngine;
|
||||
|
||||
public class FoodItem : MonoBehaviour
|
||||
public class FoodItem
|
||||
{
|
||||
[SerializeField]
|
||||
private SellableItemSO _foodObjectSO;
|
||||
|
||||
public SellableItemSO GetFoodObjectSO()
|
||||
{
|
||||
return _foodObjectSO;
|
||||
}
|
||||
public string Name { get; set; }
|
||||
public int Energy { get; set; }
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
using UnityEngine;
|
||||
|
||||
public class ShopingBasket : BaseInteractableObject
|
||||
public class ShopingContainer : BaseInteractableObject
|
||||
{
|
||||
[SerializeField]
|
||||
private ContainerSO _containerSO;
|
||||
|
||||
Reference in New Issue
Block a user