Player can hold shopping basket

This commit is contained in:
Vladimir Koshevarov
2023-03-05 13:37:50 +02:00
parent 5e4be5be1c
commit 905d159f4e
29 changed files with 2576 additions and 160 deletions
@@ -8,14 +8,14 @@ public class ColaFreezer : BaseInteractableObject
public override void Interact(Player player)
{
if (!player.HasFoodObject())
{
//player.BuyObject(_sellableItemSO);
// Spawn new object and set to player
var transform = Instantiate(_sellableItemSO.prefab, _playerArrivePoint);
var foodObject = transform.GetComponent<FoodObject>();
player.SetFoodObject(foodObject);
}
//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);
//}
}
}
+25 -25
View File
@@ -9,36 +9,36 @@ public class Fridge : BaseInteractableObject
[SerializeField]
private ItemActionsUI _actionsMenu;
private List<FoodObject> _foodObjects = new List<FoodObject>();
private List<FoodItem> _foodObjects = new List<FoodItem>();
public override void Interact(Player player)
{
_actionsMenu.Show(_containerSO.Name, $"Max items:{_containerSO.MaxCapacity} current items: {_containerSO.CurrentItemsCount}");
if (player.HasFoodObject())
{
if (_foodObjects.Count < _containerSO.MaxCapacity)
{
_foodObjects.Add(player.GetFoodObject());
player.ClearFoodObject();
Debug.Log($"Fridge have {_foodObjects.Count} pices of food");
}
else
Debug.Log($"Fridge is full");
}
else
{
//Eat menu
if (_foodObjects.Count > 0)
{
while (player.Stats[StatsId.Food].Value < player.Stats[StatsId.Food].MaxValue && _foodObjects.Count > 0)
{
_foodObjects.RemoveAt(0);
player.Eat();
}
}
}
_containerSO.CurrentItemsCount = _foodObjects.Count;
//if (player.IsHoldContainer())
//{
// if (_foodObjects.Count < _containerSO.MaxCapacity)
// {
// _foodObjects.Add(player.GetFoodObject());
// player.ClearFoodObject();
// Debug.Log($"Fridge have {_foodObjects.Count} pices of food");
// }
// else
// Debug.Log($"Fridge is full");
//}
//else
//{
// //Eat menu
// if (_foodObjects.Count > 0)
// {
// while (player.Stats[StatsId.Food].Value < player.Stats[StatsId.Food].MaxValue && _foodObjects.Count > 0)
// {
// _foodObjects.RemoveAt(0);
// player.Eat();
// }
// }
//}
//_containerSO.CurrentItemsCount = _foodObjects.Count;
}
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: bc223213aaee4f748bbcd9342e1d3aae
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,12 @@
using UnityEngine;
public class ContainerItem : MonoBehaviour
{
[SerializeField]
private ContainerSO _containerSO;
public ContainerSO GetContainerObjectSO()
{
return _containerSO;
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 8e6fa409eb749c54cab3871962e90678
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,12 @@
using UnityEngine;
public class FoodItem : MonoBehaviour
{
[SerializeField]
private SellableItemSO _foodObjectSO;
public SellableItemSO GetFoodObjectSO()
{
return _foodObjectSO;
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: ef8197297f5651a4082c2562c95e5cd5
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,12 @@
using UnityEngine;
public class SellableItem : MonoBehaviour
{
[SerializeField]
private SellableItemSO _foodObjectSO;
public SellableItemSO GetFoodObjectSO()
{
return _foodObjectSO;
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 329673eaf27345041afad67ebb166565
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,26 @@
using UnityEngine;
public class ShopingContainer : BaseInteractableObject
{
[SerializeField]
private ContainerSO _containerSO;
[SerializeField]
private ItemActionsUI _actionsMenu;
public override void Interact(Player player)
{
if (!player.IsHoldContainerItem())
{
var transform = Instantiate(_containerSO.prefab, _playerArrivePoint);
var containerItem = transform.GetComponent<ContainerItem>();
if (containerItem == null)
{
Debug.LogError("Container Item is null");
return;
}
player.SetContainerItem(containerItem);
}
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 47d747d0dea3a1144ac061eabd85e7b8
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant: