put cola in basket
This commit is contained in:
@@ -11,7 +11,7 @@ GameObject:
|
||||
- component: {fileID: 2680879424619819010}
|
||||
- component: {fileID: 7774043156322841003}
|
||||
- component: {fileID: 2250778480304515286}
|
||||
- component: {fileID: 1996526453472525189}
|
||||
- component: {fileID: 2024399116333554914}
|
||||
m_Layer: 0
|
||||
m_Name: Cola
|
||||
m_TagString: Untagged
|
||||
@@ -85,7 +85,7 @@ MeshRenderer:
|
||||
m_SortingLayer: 0
|
||||
m_SortingOrder: 0
|
||||
m_AdditionalVertexStreams: {fileID: 0}
|
||||
--- !u!114 &1996526453472525189
|
||||
--- !u!114 &2024399116333554914
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
@@ -94,7 +94,7 @@ MonoBehaviour:
|
||||
m_GameObject: {fileID: 7642835775543905443}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: ef8197297f5651a4082c2562c95e5cd5, type: 3}
|
||||
m_Script: {fileID: 11500000, guid: 329673eaf27345041afad67ebb166565, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
_foodObjectSO: {fileID: 11400000, guid: a4db4c329bb512349bf5373c80e7b84a, type: 2}
|
||||
_sellableItemSO: {fileID: 11400000, guid: a4db4c329bb512349bf5373c80e7b84a, type: 2}
|
||||
|
||||
@@ -8,14 +8,14 @@ public class ColaFreezer : BaseInteractableObject
|
||||
|
||||
public override void Interact(Player player)
|
||||
{
|
||||
//if (!player.IsHoldContainer())
|
||||
//{
|
||||
// //player.BuyObject(_sellableItemSO);
|
||||
// // Spawn new object and set to player
|
||||
// var transform = Instantiate(_sellableItemSO.prefab, _playerArrivePoint);
|
||||
// var foodObject = transform.GetComponent<FoodItem>();
|
||||
// player.SetFoodObject(foodObject);
|
||||
//}
|
||||
if (player.IsHoldContainerItem())
|
||||
{
|
||||
var transform = Instantiate(_sellableItemSO.prefab, player.GetContainerItem().transform);
|
||||
var sellableItem = transform.GetComponent<SellableItem>();
|
||||
|
||||
var container = player.GetContainerItem();
|
||||
container.AddItem(sellableItem);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class ContainerItem : MonoBehaviour
|
||||
@@ -5,8 +6,30 @@ public class ContainerItem : MonoBehaviour
|
||||
[SerializeField]
|
||||
private ContainerSO _containerSO;
|
||||
|
||||
|
||||
private List<SellableItem> _items;
|
||||
|
||||
private void Start()
|
||||
{
|
||||
_items = new List<SellableItem>();
|
||||
}
|
||||
|
||||
public ContainerSO GetContainerObjectSO()
|
||||
{
|
||||
return _containerSO;
|
||||
}
|
||||
|
||||
public void AddItem(SellableItem item)
|
||||
{
|
||||
if (_containerSO.CurrentItemsCount < _containerSO.MaxCapacity)
|
||||
{
|
||||
Debug.Log($"Player put to container a {item.GetSellableItemSO().objectName}");
|
||||
_items.Add(item);
|
||||
_containerSO.CurrentItemsCount = _items.Count;
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.Log("Container is full");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,10 +3,10 @@ using UnityEngine;
|
||||
public class SellableItem : MonoBehaviour
|
||||
{
|
||||
[SerializeField]
|
||||
private SellableItemSO _foodObjectSO;
|
||||
private SellableItemSO _sellableItemSO;
|
||||
|
||||
public SellableItemSO GetFoodObjectSO()
|
||||
public SellableItemSO GetSellableItemSO()
|
||||
{
|
||||
return _foodObjectSO;
|
||||
return _sellableItemSO;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user