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;
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!114 &11400000
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 0}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 570c5458f6b5110448188e51cb5becbb, type: 3}
|
||||
m_Name: PlasticBag
|
||||
m_EditorClassIdentifier:
|
||||
Name: Plastic bag
|
||||
MaxCapacity: 5
|
||||
prefab: {fileID: 1702364597089646122, guid: dac0081f9dadb1d4f9eacc9bcf9a06d0, type: 3}
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e3d520733a0700b4f8ec3baae6be6e76
|
||||
NativeFormatImporter:
|
||||
externalObjects: {}
|
||||
mainObjectFileID: 11400000
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -20,9 +20,9 @@ public class ContainerItemsUI : MonoBehaviour
|
||||
{
|
||||
if (Player.Instance.IsHoldContainerItem())
|
||||
{
|
||||
var playerContainer = Player.Instance.GetContainerItem();
|
||||
_container.gameObject.SetActive(true);
|
||||
|
||||
var playerContainer = Player.Instance.GetContainerItem();
|
||||
if (playerContainer.GetItems().Any())
|
||||
{
|
||||
foreach (Transform child in _itemsList)
|
||||
@@ -40,5 +40,9 @@ public class ContainerItemsUI : MonoBehaviour
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
_container.gameObject.SetActive(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user