change multiple scene system to dynamic indoor scene
This commit is contained in:
@@ -0,0 +1,65 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using UnityEngine;
|
||||
|
||||
public class ContainerItem : MonoBehaviour
|
||||
{
|
||||
[SerializeField]
|
||||
private ContainerSO _containerSO;
|
||||
public event EventHandler OnItemsChange;
|
||||
|
||||
private List<BaseItemSO> _items = new List<BaseItemSO>();
|
||||
|
||||
public ContainerSO GetContainerObjectSO()
|
||||
{
|
||||
return _containerSO;
|
||||
}
|
||||
|
||||
public void AddItem(BaseItemSO item)
|
||||
{
|
||||
if (_items.Count < _containerSO.MaxCapacity)
|
||||
{
|
||||
Debug.Log($"Player put to container a {item.ItemName}");
|
||||
_items.Add(item);
|
||||
OnItemsChange?.Invoke(this,EventArgs.Empty);
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.Log("Container is full");
|
||||
}
|
||||
}
|
||||
|
||||
public void Remove(BaseItemSO item)
|
||||
{
|
||||
if (_items.Count>0)
|
||||
{
|
||||
Debug.Log($"Player remove {item.ItemName} from container");
|
||||
_items.Remove(item);
|
||||
OnItemsChange?.Invoke(this, EventArgs.Empty);
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.Log("Container is emplty");
|
||||
}
|
||||
}
|
||||
|
||||
public List<BaseItemSO> GetItems()
|
||||
{
|
||||
return _items;
|
||||
}
|
||||
|
||||
public bool IsSalebleItems()
|
||||
{
|
||||
return _items.Any(x => x is SellableItemSO);
|
||||
}
|
||||
|
||||
public void AddItems(List<BaseItemSO> playerItemsList)
|
||||
{
|
||||
foreach (var item in playerItemsList)
|
||||
{
|
||||
AddItem(item);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8e6fa409eb749c54cab3871962e90678
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,4 @@
|
||||
public class FoodItemSO : BaseItemSO
|
||||
{
|
||||
public int Energy { get; set; }
|
||||
}
|
||||
@@ -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 _sellableItemSO;
|
||||
|
||||
public SellableItemSO GetSellableItemSO()
|
||||
{
|
||||
return _sellableItemSO;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 329673eaf27345041afad67ebb166565
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user