Updated InventorySystem to be more flexible

This commit is contained in:
Mikolaj 2022-05-06 22:25:17 +02:00
parent 073d076628
commit daaa135ecf
32 changed files with 1721 additions and 4912 deletions

File diff suppressed because it is too large Load diff

View file

@ -1,452 +0,0 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Pool;
using TMPro;
// !! ========= NOTE ========= !!
// GetIndex_Id will return 0 as empty!
// So make sure you dont make any items with id 0 or below!
// !! ========= NOTE ========= !!
/*/
* Functions available here:
* -> GetIndex_Name
* -> GetIndex_Id
* -> GetIndex_ItemType
* -> GetIndex_SlotType
* -> GetIndex_ItemObject
* -> GetIndex_Slot
*
* -> SetIndex_Slot
* -> Set_Slot
* -> RemoveIndex_Slot
* -> RemoveIndex_Slotspecial
* -> Remove_Slot
* -> Remove_Slotspecial
*
* -> UpdateIndex_Slotsobject
* -> Update_Slotsobject
*
* -> Spawn_Object
* -> RemoveCurrent_Object
*
* -> setupSlot
*
* -> Debug_Slot
* -> Debug_Functions
/*/
public class SlotSystem : MonoBehaviour
{
// Used to make slots specific to what item it can accept
class slotInfo
{
public Item Item; // Most likely wont be needed
public Item.ItemTypeEnum ItemType;
public Item.SlotTypeEnum SlotType;
public slotInfo(Item.ItemTypeEnum inputItemType, Item.SlotTypeEnum inputSlotType)
{
ItemType = inputItemType;
SlotType = inputSlotType;
}
}
[Header("Pooling Setting")]
[Space(10)]
[Header("Spawn Setting")]
public GameObject parentObject; // Used to spawn object to specific parent
[Space(10)]
[Header("Slot Setting")]
public List<Item> slots;
public List<Item> slots_special;
public List<GameObject> slots_object;
private List<slotInfo> slotInfoArray = new List<slotInfo>(); // Used to check compatibility with items that are being stored
public int selectedSlot;
public int selectedSlot_special;
private GameObject currentGameObject = null; // Used to check stored current GameObject to destroy it later when not used or switching item
// TMP
public Item tmp_Item; // Tmp
// GetIndex_[Name] will return specific data from specified index slot
string GetIndex_Name(int index)
{
if (index <= 5)
{
if (slots[index] != null)
{
return slots[index].ItemName;
}
}
else if (selectedSlot_special < slots_special.Count)
{
if (slots_special[selectedSlot_special] != null && index == 6)
{
return slots_special[selectedSlot_special].ItemName;
}
}
return null;
}
uint GetIndex_Id(int index)
{
if (index <= 5)
{
if (slots[index] != null)
{
return slots[index].ItemID;
}
}
else if (selectedSlot_special < slots_special.Count)
{
if (slots_special[selectedSlot_special] != null && index == 6)
{
return slots_special[selectedSlot_special].ItemID;
}
}
return 0; // 0 will basically mean none
}
Item.ItemTypeEnum GetIndex_ItemType(int index)
{
if (index <= 5)
{
if (slots[index] != null)
{
return slots[index].ItemType;
}
}
else if (selectedSlot_special < slots_special.Count)
{
if (slots_special[selectedSlot_special] != null && index == 6)
{
return slots_special[selectedSlot_special].ItemType;
}
}
return Item.ItemTypeEnum.None;
}
Item.SlotTypeEnum GetIndex_SlotType(int index)
{
if (index <= 5)
{
if (slots[index] != null)
{
return slots[index].SlotType;
}
}
else if (selectedSlot_special < slots_special.Count)
{
if (slots_special[selectedSlot_special] != null && index == 6)
{
return slots_special[selectedSlot_special].SlotType;
}
}
return Item.SlotTypeEnum.None;
}
Object GetIndex_ItemObject(int index)
{
if (index <= 5)
{
if (slots[index] != null)
{
return slots[index].ItemObject;
}
}
else if (slots_special[selectedSlot_special] != null && index == 6)
{
return slots_special[selectedSlot_special].ItemObject;
}
return null;
}
Item GetIndex_Slot(int index)
{
if (index <= 5)
{
if (slots[index] != null)
{
return slots[index];
}
}
else if (slots_special[selectedSlot_special] != null && index == 6)
{
return slots_special[selectedSlot_special];
}
return null;
}
// SetIndex_[Name] will set specific data to specified index slot
bool SetIndex_Slot(int index, Item itemData)
{
if (slotInfoArray[index].GetType() == typeof(slotInfo))
{
slotInfo slotData = slotInfoArray[index];
if (slotData.ItemType == itemData.ItemType && slotData.SlotType == itemData.SlotType)
{
Item oldItem = slots[index];
Item newItem = itemData;
tmp_Item = oldItem; // [Insert] drop / remove function here
slots[index] = newItem;
return true;
}
}
return false;
}
// set_[Name] will check all indexes and if free, then place
bool Set_Slot(Item itemData)
{
for (int i = 0; i < slots.Count; i++)
{
if (slots[i] == null && slotInfoArray[i] != null)
{
slotInfo slotData = slotInfoArray[i];
if (slotData.ItemType == itemData.ItemType && slotData.SlotType == itemData.SlotType)
{
slots[i] = itemData;
return true;
}
}
}
if (slotInfoArray[6].ItemType == itemData.ItemType && slotInfoArray[6].SlotType == itemData.SlotType)
{
for (int i = 0; i < slots_special.Count; i++)
{
if (slots_special[i].ItemID == itemData.ItemID)
{
return false;
}
}
slots_special.Add(itemData);
return true;
}
return false;
}
// removeIndex_[Name] will remove specific index from slot
bool RemoveIndex_Slot(int index)
{
if (slots[index] != null)
{
slots[index] = null;
return true;
}
return false;
}
bool RemoveIndex_Slotspecial(int index)
{
try
{
slots_special.RemoveAt(index);
return true;
}
catch
{
return false;
}
}
// remove_[Name] will remove all items from slot
bool Remove_Slot()
{
try
{
for (int i = 0; i < slots.Count; i++)
{
slots[i] = null;
}
return true;
}
catch
{
return false;
}
}
bool Remove_Slotspecial()
{
try
{
slots_special.RemoveRange(0, slots_special.Count);
return true;
}
catch
{
return false;
}
}
// updateIndex_[Name] will update specified index text (might come more soon)
void UpdateIndex_Slotsobject(int index)
{
try
{
slots_object[index].transform.GetChild(3).gameObject.GetComponent<TMPro.TextMeshProUGUI>().text = GetIndex_Name(index);
slots_object[index].transform.GetChild(4).gameObject.GetComponent<TMPro.TextMeshProUGUI>().text = "Other";
}
catch
{
Debug.LogError("Couldn't update! Possible problem to this are 'index', 'GetChild' or 'GetComponent'");
}
}
// update_[Name] will update all index text (might come more soon)
void Update_Slotsobject()
{
try
{
for (int i = 0; i < slots_object.Count; i++)
{
slots_object[i].transform.GetChild(3).gameObject.GetComponent<TMPro.TextMeshProUGUI>().text = GetIndex_Name(i);
slots_object[i].transform.GetChild(4).gameObject.GetComponent<TMPro.TextMeshProUGUI>().text = "Other";
}
} catch
{
Debug.LogError("Couldn't update! Possible problem INSIDE for loop are 'index', 'GetChild' or 'GetComponent'");
}
}
// Spawn_[Name] will spawn object to the game world to a specific parentObject
bool SpawnIndex_Object(int index)
{
try
{
if (GetIndex_ItemObject(index) != null)
{
currentGameObject = Instantiate(GetIndex_ItemObject(index)) as GameObject; // Pooling System on unity is way too confusing.. Ill research about it more later.
currentGameObject.transform.SetParent(parentObject.transform, false);
return true;
}
return false;
}
catch
{
Debug.LogError("Prefab could not be instantiated");
return false;
}
}
// removeCurrent_[Name] will remove current object if spawned any
bool RemoveCurrent_Object()
{
try
{
if (currentGameObject != null)
{
Destroy(currentGameObject);
return true;
}
return false;
}
catch
{
Debug.LogError("currentGameObject could not be destroyed");
return false;
}
}
// Other
// Sets up slot types for different slot placement
void setupSlot()
{
Item.ItemTypeEnum EnumBasicItem = Item.ItemTypeEnum.BasicItem;
Item.ItemTypeEnum EnumSpecialItem = Item.ItemTypeEnum.SpecialItem;
Item.SlotTypeEnum EnumMelee = Item.SlotTypeEnum.Melee;
Item.SlotTypeEnum EnumSecondary = Item.SlotTypeEnum.Secondary;
Item.SlotTypeEnum EnumPrimary = Item.SlotTypeEnum.Primary;
Item.SlotTypeEnum EnumGrenede = Item.SlotTypeEnum.Grenede;
Item.SlotTypeEnum EnumPickprop = Item.SlotTypeEnum.Pickprop;
Item.SlotTypeEnum EnumEmpty = Item.SlotTypeEnum.Empty;
Item.SlotTypeEnum EnumSpecial = Item.SlotTypeEnum.Special;
slotInfoArray.Add(new slotInfo(EnumBasicItem, EnumMelee)); // 1
slotInfoArray.Add(new slotInfo(EnumBasicItem, EnumSecondary)); // 2
slotInfoArray.Add(new slotInfo(EnumBasicItem, EnumPrimary)); // 3
slotInfoArray.Add(new slotInfo(EnumBasicItem, EnumGrenede)); // 4
slotInfoArray.Add(new slotInfo(EnumBasicItem, EnumPickprop)); // 5
slotInfoArray.Add(new slotInfo(EnumBasicItem, EnumEmpty)); // 6
slotInfoArray.Add(new slotInfo(EnumSpecialItem, EnumSpecial)); // 7
}
// Debug slot
void Debug_Slot()
{
for (int i = 0; i < slots.Count; i++)
{
if (slots[i] != null)
{
Debug.Log("Slot_" + i + " = " + slots[i].ItemName);
}
else
{
Debug.Log("Slot_" + i + " = Empty");
}
}
for (int i = 0; i < slots_special.Count; i++)
{
if (slots_special[i] != null)
{
Debug.Log("Slot_" + i + " = " + slots_special[i].ItemName);
}
else
{
Debug.Log("Slot_" + i + " = Empty");
}
}
}
// Use this as refrence if you dont know how to use my functions
void Debug_Functions(int Type)
{
Item OLDITEM = tmp_Item;
if (Type == 0) // Using Set_[Name]
{
if (Set_Slot(tmp_Item))
{
Debug.Log(OLDITEM.ItemName + " Has been stored!");
tmp_Item = null;
}
else
{
Debug.Log(OLDITEM.ItemName + " Couldn't find free slot");
}
}
else if (Type == 1) // Using SetIndex_[Name]
{
if (SetIndex_Slot(selectedSlot, tmp_Item))
{
Debug.Log(OLDITEM.ItemName + " Has been stored and dropped old item from slot!");
}
else
{
Debug.Log(OLDITEM.ItemName + " Does not fit for this slot, try another one!");
}
}
}
// Start is called before the first frame update
void Start()
{
setupSlot(); // Must setup before using any other functions
Set_Slot(tmp_Item);
Update_Slotsobject();
SpawnIndex_Object(0);
//RemoveCurrent_Object();
}
// Update is called once per frame
void Update()
{
}
}

View file

@ -0,0 +1,629 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!1 &603143863941598699
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 603143863941598692}
- component: {fileID: 603143863941598694}
- component: {fileID: 603143863941598693}
m_Layer: 0
m_Name: MainBackground
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!224 &603143863941598692
RectTransform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 603143863941598699}
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 0.6149115, y: 0.6149115, z: 0.6149115}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 5555894905667710859}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0.5, y: 0.5}
m_AnchorMax: {x: 0.5, y: 0.5}
m_AnchoredPosition: {x: 11.139919, y: 0.28240192}
m_SizeDelta: {x: 290, y: 25}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!222 &603143863941598694
CanvasRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 603143863941598699}
m_CullTransparentMesh: 1
--- !u!114 &603143863941598693
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 603143863941598699}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Material: {fileID: 0}
m_Color: {r: 0.21568628, g: 0.21568628, b: 0.21568628, a: 1}
m_RaycastTarget: 1
m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0}
m_Maskable: 1
m_OnCullStateChanged:
m_PersistentCalls:
m_Calls: []
m_Sprite: {fileID: 0}
m_Type: 0
m_PreserveAspect: 0
m_FillCenter: 1
m_FillMethod: 4
m_FillAmount: 1
m_FillClockwise: 1
m_FillOrigin: 0
m_UseSpriteMesh: 0
m_PixelsPerUnitMultiplier: 1
--- !u!1 &603143864341689882
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 603143864341689883}
- component: {fileID: 603143864341689877}
- component: {fileID: 603143864341689876}
m_Layer: 5
m_Name: AmmoCount
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!224 &603143864341689883
RectTransform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 603143864341689882}
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 0.9999999, y: 0.9999999, z: 0.9999999}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 5555894905667710859}
m_RootOrder: 4
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 1, y: 0.5}
m_AnchorMax: {x: 1, y: 0.5}
m_AnchoredPosition: {x: -11.6, y: 0.28240192}
m_SizeDelta: {x: 50, y: 25}
m_Pivot: {x: 1, y: 0.5}
--- !u!222 &603143864341689877
CanvasRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 603143864341689882}
m_CullTransparentMesh: 1
--- !u!114 &603143864341689876
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 603143864341689882}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: f4688fdb7df04437aeb418b961361dc5, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Material: {fileID: 0}
m_Color: {r: 1, g: 1, b: 1, a: 1}
m_RaycastTarget: 1
m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0}
m_Maskable: 1
m_OnCullStateChanged:
m_PersistentCalls:
m_Calls: []
m_text: 8 + 00
m_isRightToLeft: 0
m_fontAsset: {fileID: 11400000, guid: 8f586378b4e144a9851e7b34d9b748ee, type: 2}
m_sharedMaterial: {fileID: 2180264, guid: 8f586378b4e144a9851e7b34d9b748ee, type: 2}
m_fontSharedMaterials: []
m_fontMaterial: {fileID: 0}
m_fontMaterials: []
m_fontColor32:
serializedVersion: 2
rgba: 4291611852
m_fontColor: {r: 0.8, g: 0.8, b: 0.8, a: 1}
m_enableVertexGradient: 0
m_colorMode: 3
m_fontColorGradient:
topLeft: {r: 1, g: 1, b: 1, a: 1}
topRight: {r: 1, g: 1, b: 1, a: 1}
bottomLeft: {r: 1, g: 1, b: 1, a: 1}
bottomRight: {r: 1, g: 1, b: 1, a: 1}
m_fontColorGradientPreset: {fileID: 0}
m_spriteAsset: {fileID: 0}
m_tintAllSprites: 0
m_StyleSheet: {fileID: 0}
m_TextStyleHashCode: -1183493901
m_overrideHtmlColors: 0
m_faceColor:
serializedVersion: 2
rgba: 4294967295
m_fontSize: 14.2
m_fontSizeBase: 14.2
m_fontWeight: 400
m_enableAutoSizing: 0
m_fontSizeMin: 18
m_fontSizeMax: 72
m_fontStyle: 0
m_HorizontalAlignment: 4
m_VerticalAlignment: 512
m_textAlignment: 65535
m_characterSpacing: 0
m_wordSpacing: 0
m_lineSpacing: 0
m_lineSpacingMax: 0
m_paragraphSpacing: 0
m_charWidthMaxAdj: 0
m_enableWordWrapping: 1
m_wordWrappingRatios: 0.4
m_overflowMode: 0
m_linkedTextComponent: {fileID: 0}
parentLinkedComponent: {fileID: 0}
m_enableKerning: 1
m_enableExtraPadding: 0
checkPaddingRequired: 0
m_isRichText: 1
m_parseCtrlCharacters: 1
m_isOrthographic: 1
m_isCullingEnabled: 0
m_horizontalMapping: 0
m_verticalMapping: 0
m_uvLineOffset: 0
m_geometrySortingOrder: 0
m_IsTextObjectScaleStatic: 0
m_VertexBufferAutoSizeReduction: 0
m_useMaxVisibleDescender: 1
m_pageToDisplay: 1
m_margin: {x: 0, y: 0, z: 0, w: 0}
m_isUsingLegacyAnimationComponent: 0
m_isVolumetricText: 0
m_hasFontAssetChanged: 0
m_baseMaterial: {fileID: 0}
m_maskOffset: {x: 0, y: 0, z: 0, w: 0}
--- !u!1 &603143864744078245
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 603143864744078246}
- component: {fileID: 603143864744078240}
- component: {fileID: 603143864744078247}
m_Layer: 5
m_Name: SlotNum
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!224 &603143864744078246
RectTransform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 603143864744078245}
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 0.9999999, y: 0.9999999, z: 0.9999999}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 5555894905667710859}
m_RootOrder: 2
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 1, y: 0.5}
m_AnchorMax: {x: 1, y: 0.5}
m_AnchoredPosition: {x: -178.6, y: 0.2824}
m_SizeDelta: {x: 22.0783, y: 14.8688}
m_Pivot: {x: 1, y: 0.5}
--- !u!222 &603143864744078240
CanvasRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 603143864744078245}
m_CullTransparentMesh: 1
--- !u!114 &603143864744078247
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 603143864744078245}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: f4688fdb7df04437aeb418b961361dc5, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Material: {fileID: 0}
m_Color: {r: 1, g: 1, b: 1, a: 1}
m_RaycastTarget: 1
m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0}
m_Maskable: 1
m_OnCullStateChanged:
m_PersistentCalls:
m_Calls: []
m_text: 1
m_isRightToLeft: 0
m_fontAsset: {fileID: 11400000, guid: 8f586378b4e144a9851e7b34d9b748ee, type: 2}
m_sharedMaterial: {fileID: 2180264, guid: 8f586378b4e144a9851e7b34d9b748ee, type: 2}
m_fontSharedMaterials: []
m_fontMaterial: {fileID: 0}
m_fontMaterials: []
m_fontColor32:
serializedVersion: 2
rgba: 4291611852
m_fontColor: {r: 0.8018868, g: 0.8018868, b: 0.8018868, a: 1}
m_enableVertexGradient: 0
m_colorMode: 3
m_fontColorGradient:
topLeft: {r: 1, g: 1, b: 1, a: 1}
topRight: {r: 1, g: 1, b: 1, a: 1}
bottomLeft: {r: 1, g: 1, b: 1, a: 1}
bottomRight: {r: 1, g: 1, b: 1, a: 1}
m_fontColorGradientPreset: {fileID: 0}
m_spriteAsset: {fileID: 0}
m_tintAllSprites: 0
m_StyleSheet: {fileID: 0}
m_TextStyleHashCode: -1183493901
m_overrideHtmlColors: 0
m_faceColor:
serializedVersion: 2
rgba: 4294967295
m_fontSize: 12.5
m_fontSizeBase: 12.5
m_fontWeight: 400
m_enableAutoSizing: 0
m_fontSizeMin: 18
m_fontSizeMax: 72
m_fontStyle: 0
m_HorizontalAlignment: 2
m_VerticalAlignment: 512
m_textAlignment: 65535
m_characterSpacing: 0
m_wordSpacing: 0
m_lineSpacing: 0
m_lineSpacingMax: 0
m_paragraphSpacing: 0
m_charWidthMaxAdj: 0
m_enableWordWrapping: 1
m_wordWrappingRatios: 0.4
m_overflowMode: 0
m_linkedTextComponent: {fileID: 0}
parentLinkedComponent: {fileID: 0}
m_enableKerning: 1
m_enableExtraPadding: 0
checkPaddingRequired: 0
m_isRichText: 1
m_parseCtrlCharacters: 1
m_isOrthographic: 1
m_isCullingEnabled: 0
m_horizontalMapping: 0
m_verticalMapping: 0
m_uvLineOffset: 0
m_geometrySortingOrder: 0
m_IsTextObjectScaleStatic: 0
m_VertexBufferAutoSizeReduction: 0
m_useMaxVisibleDescender: 1
m_pageToDisplay: 1
m_margin: {x: 0, y: 0, z: 0, w: 0}
m_isUsingLegacyAnimationComponent: 0
m_isVolumetricText: 0
m_hasFontAssetChanged: 0
m_baseMaterial: {fileID: 0}
m_maskOffset: {x: 0, y: 0, z: 0, w: 0}
--- !u!1 &603143865543642866
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 603143865543642867}
- component: {fileID: 603143865543642861}
- component: {fileID: 603143865543642860}
m_Layer: 5
m_Name: ItemName
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!224 &603143865543642867
RectTransform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 603143865543642866}
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 0.9999999, y: 0.9999999, z: 0.9999999}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 5555894905667710859}
m_RootOrder: 3
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 1, y: 0.5}
m_AnchorMax: {x: 1, y: 0.5}
m_AnchoredPosition: {x: -54.902847, y: 0.28240192}
m_SizeDelta: {x: 120, y: 25}
m_Pivot: {x: 1, y: 0.5}
--- !u!222 &603143865543642861
CanvasRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 603143865543642866}
m_CullTransparentMesh: 1
--- !u!114 &603143865543642860
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 603143865543642866}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: f4688fdb7df04437aeb418b961361dc5, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Material: {fileID: 0}
m_Color: {r: 1, g: 1, b: 1, a: 1}
m_RaycastTarget: 1
m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0}
m_Maskable: 1
m_OnCullStateChanged:
m_PersistentCalls:
m_Calls: []
m_text: Name
m_isRightToLeft: 0
m_fontAsset: {fileID: 11400000, guid: 8f586378b4e144a9851e7b34d9b748ee, type: 2}
m_sharedMaterial: {fileID: 2180264, guid: 8f586378b4e144a9851e7b34d9b748ee, type: 2}
m_fontSharedMaterials: []
m_fontMaterial: {fileID: 0}
m_fontMaterials: []
m_fontColor32:
serializedVersion: 2
rgba: 4291611852
m_fontColor: {r: 0.8, g: 0.8, b: 0.8, a: 1}
m_enableVertexGradient: 0
m_colorMode: 3
m_fontColorGradient:
topLeft: {r: 1, g: 1, b: 1, a: 1}
topRight: {r: 1, g: 1, b: 1, a: 1}
bottomLeft: {r: 1, g: 1, b: 1, a: 1}
bottomRight: {r: 1, g: 1, b: 1, a: 1}
m_fontColorGradientPreset: {fileID: 0}
m_spriteAsset: {fileID: 0}
m_tintAllSprites: 0
m_StyleSheet: {fileID: 0}
m_TextStyleHashCode: -1183493901
m_overrideHtmlColors: 0
m_faceColor:
serializedVersion: 2
rgba: 4294967295
m_fontSize: 14.2
m_fontSizeBase: 14.2
m_fontWeight: 400
m_enableAutoSizing: 0
m_fontSizeMin: 18
m_fontSizeMax: 72
m_fontStyle: 0
m_HorizontalAlignment: 1
m_VerticalAlignment: 512
m_textAlignment: 65535
m_characterSpacing: 0
m_wordSpacing: 0
m_lineSpacing: 0
m_lineSpacingMax: 0
m_paragraphSpacing: 0
m_charWidthMaxAdj: 0
m_enableWordWrapping: 1
m_wordWrappingRatios: 0.4
m_overflowMode: 0
m_linkedTextComponent: {fileID: 0}
parentLinkedComponent: {fileID: 0}
m_enableKerning: 1
m_enableExtraPadding: 0
checkPaddingRequired: 0
m_isRichText: 1
m_parseCtrlCharacters: 1
m_isOrthographic: 1
m_isCullingEnabled: 0
m_horizontalMapping: 0
m_verticalMapping: 0
m_uvLineOffset: 0
m_geometrySortingOrder: 0
m_IsTextObjectScaleStatic: 0
m_VertexBufferAutoSizeReduction: 0
m_useMaxVisibleDescender: 1
m_pageToDisplay: 1
m_margin: {x: 0, y: 0, z: 0, w: 0}
m_isUsingLegacyAnimationComponent: 0
m_isVolumetricText: 0
m_hasFontAssetChanged: 0
m_baseMaterial: {fileID: 0}
m_maskOffset: {x: 0, y: 0, z: 0, w: 0}
--- !u!1 &1653983621636357011
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 4549751069847374018}
- component: {fileID: 2487720833731257591}
- component: {fileID: 5307750421821480049}
m_Layer: 0
m_Name: SecondaryBackground
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!224 &4549751069847374018
RectTransform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1653983621636357011}
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 0.6149115, y: 0.6149115, z: 0.6149115}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 5555894905667710859}
m_RootOrder: 1
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0.5, y: 0.5}
m_AnchorMax: {x: 0.5, y: 0.5}
m_AnchoredPosition: {x: -89.09075, y: 0.28240192}
m_SizeDelta: {x: 36, y: 25}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!222 &2487720833731257591
CanvasRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1653983621636357011}
m_CullTransparentMesh: 1
--- !u!114 &5307750421821480049
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1653983621636357011}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Material: {fileID: 0}
m_Color: {r: 0.745283, g: 0.116011046, b: 0.116011046, a: 1}
m_RaycastTarget: 1
m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0}
m_Maskable: 1
m_OnCullStateChanged:
m_PersistentCalls:
m_Calls: []
m_Sprite: {fileID: 0}
m_Type: 0
m_PreserveAspect: 0
m_FillCenter: 1
m_FillMethod: 4
m_FillAmount: 1
m_FillClockwise: 1
m_FillOrigin: 0
m_UseSpriteMesh: 0
m_PixelsPerUnitMultiplier: 1
--- !u!1 &3349303436265952796
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 5555894905667710859}
- component: {fileID: 4393183806715141941}
- component: {fileID: 5686723314075951356}
m_Layer: 5
m_Name: Slot
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!224 &5555894905667710859
RectTransform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 3349303436265952796}
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children:
- {fileID: 603143863941598692}
- {fileID: 4549751069847374018}
- {fileID: 603143864744078246}
- {fileID: 603143865543642867}
- {fileID: 603143864341689883}
m_Father: {fileID: 0}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 1}
m_AnchorMax: {x: 0, y: 1}
m_AnchoredPosition: {x: 694.9501, y: -449.8375}
m_SizeDelta: {x: 210.09009, y: 0}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!222 &4393183806715141941
CanvasRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 3349303436265952796}
m_CullTransparentMesh: 1
--- !u!114 &5686723314075951356
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 3349303436265952796}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: b034f6998f291904db4f748038540cd6, type: 3}
m_Name:
m_EditorClassIdentifier:
slotId: 0
itemName:
ammoInMag: 0
inStorageAmmo: 0
slotIdDisplay: {fileID: 603143864744078247}
itemNameDisplay: {fileID: 603143865543642860}
ammoCountDisplay: {fileID: 603143864341689876}

View file

@ -1,5 +1,5 @@
fileFormatVersion: 2 fileFormatVersion: 2
guid: a6c9897145ea93b41abf3c531f857e3b guid: c043653a099f2824382980634a1da69b
PrefabImporter: PrefabImporter:
externalObjects: {} externalObjects: {}
userData: userData:

View file

@ -12,8 +12,9 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 5616ea767049f3f4abf778200fbf66cd, type: 3} m_Script: {fileID: 11500000, guid: 5616ea767049f3f4abf778200fbf66cd, type: 3}
m_Name: Empty m_Name: Empty
m_EditorClassIdentifier: m_EditorClassIdentifier:
ItemName: HOLSTERED ItemName: Holstered
ItemID: 6 ItemID: 6
ItemType: 0 ItemType: 0
SlotType: 5 SlotType: 5
UsedSpecialSlotNumber: 0
ItemObject: {fileID: 0} ItemObject: {fileID: 0}

View file

@ -12,8 +12,9 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 5616ea767049f3f4abf778200fbf66cd, type: 3} m_Script: {fileID: 11500000, guid: 5616ea767049f3f4abf778200fbf66cd, type: 3}
m_Name: Grenede m_Name: Grenede
m_EditorClassIdentifier: m_EditorClassIdentifier:
ItemName: GRENEDE ItemName: Granade
ItemID: 4 ItemID: 4
ItemType: 0 ItemType: 0
SlotType: 3 SlotType: 3
UsedSpecialSlotNumber: 0
ItemObject: {fileID: 0} ItemObject: {fileID: 0}

View file

@ -12,9 +12,10 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 5616ea767049f3f4abf778200fbf66cd, type: 3} m_Script: {fileID: 11500000, guid: 5616ea767049f3f4abf778200fbf66cd, type: 3}
m_Name: Melee m_Name: Melee
m_EditorClassIdentifier: m_EditorClassIdentifier:
ItemName: KNIFE ItemName: Crowbar
ItemID: 1 ItemID: 1
ItemType: 0 ItemType: 0
SlotType: 0 SlotType: 0
UsedSpecialSlotNumber: 0
ItemObject: {fileID: 2683428033455470680, guid: e4709fc7d46b73549bd76044d6991645, ItemObject: {fileID: 2683428033455470680, guid: e4709fc7d46b73549bd76044d6991645,
type: 3} type: 3}

View file

@ -12,8 +12,9 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 5616ea767049f3f4abf778200fbf66cd, type: 3} m_Script: {fileID: 11500000, guid: 5616ea767049f3f4abf778200fbf66cd, type: 3}
m_Name: Secondary m_Name: Secondary
m_EditorClassIdentifier: m_EditorClassIdentifier:
ItemName: DEAGLE ItemName: Deagle
ItemID: 2 ItemID: 2
ItemType: 0 ItemType: 0
SlotType: 1 SlotType: 1
UsedSpecialSlotNumber: 0
ItemObject: {fileID: 0} ItemObject: {fileID: 0}

View file

@ -12,8 +12,9 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 5616ea767049f3f4abf778200fbf66cd, type: 3} m_Script: {fileID: 11500000, guid: 5616ea767049f3f4abf778200fbf66cd, type: 3}
m_Name: Special m_Name: Special
m_EditorClassIdentifier: m_EditorClassIdentifier:
ItemName: FLARE ItemName: Flare
ItemID: 7 ItemID: 7
ItemType: 1 ItemType: 1
SlotType: 6 SlotType: 6
UsedSpecialSlotNumber: 0
ItemObject: {fileID: 0} ItemObject: {fileID: 0}

View file

@ -10,10 +10,11 @@ MonoBehaviour:
m_Enabled: 1 m_Enabled: 1
m_EditorHideFlags: 0 m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 5616ea767049f3f4abf778200fbf66cd, type: 3} m_Script: {fileID: 11500000, guid: 5616ea767049f3f4abf778200fbf66cd, type: 3}
m_Name: Proppick m_Name: nJoy_Prop_Wand
m_EditorClassIdentifier: m_EditorClassIdentifier:
ItemName: MAGNETO-STICK ItemName: nJoy Prop Wand
ItemID: 5 ItemID: 5
ItemType: 0 ItemType: 0
SlotType: 4 SlotType: 4
UsedSpecialSlotNumber: 0
ItemObject: {fileID: 0} ItemObject: {fileID: 0}

View file

@ -123,12 +123,6 @@ NavMeshSettings:
debug: debug:
m_Flags: 0 m_Flags: 0
m_NavMeshData: {fileID: 0} m_NavMeshData: {fileID: 0}
--- !u!4 &513282457 stripped
Transform:
m_CorrespondingSourceObject: {fileID: 4618792496510273084, guid: a6c9897145ea93b41abf3c531f857e3b,
type: 3}
m_PrefabInstance: {fileID: 4618792496064108453}
m_PrefabAsset: {fileID: 0}
--- !u!1 &532894885 --- !u!1 &532894885
GameObject: GameObject:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
@ -454,113 +448,15 @@ RectTransform:
m_LocalScale: {x: 0, y: 0, z: 0} m_LocalScale: {x: 0, y: 0, z: 0}
m_ConstrainProportionsScale: 0 m_ConstrainProportionsScale: 0
m_Children: m_Children:
- {fileID: 513282457} - {fileID: 1525258600}
m_Father: {fileID: 1174856041} m_Father: {fileID: 0}
m_RootOrder: 0 m_RootOrder: 3
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0} m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 0, y: 0} m_AnchorMax: {x: 0, y: 0}
m_AnchoredPosition: {x: 0, y: 0} m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: 0, y: 0} m_SizeDelta: {x: 0, y: 0}
m_Pivot: {x: 0, y: 0} m_Pivot: {x: 0, y: 0}
--- !u!1 &1174856037
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 1174856041}
- component: {fileID: 1174856040}
- component: {fileID: 1174856039}
- component: {fileID: 1174856038}
m_Layer: 0
m_Name: Cube
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!65 &1174856038
BoxCollider:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1174856037}
m_Material: {fileID: 0}
m_IsTrigger: 0
m_Enabled: 1
serializedVersion: 2
m_Size: {x: 1, y: 1, z: 1}
m_Center: {x: 0, y: 0, z: 0}
--- !u!23 &1174856039
MeshRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1174856037}
m_Enabled: 1
m_CastShadows: 1
m_ReceiveShadows: 1
m_DynamicOccludee: 1
m_StaticShadowCaster: 0
m_MotionVectors: 1
m_LightProbeUsage: 1
m_ReflectionProbeUsage: 1
m_RayTracingMode: 2
m_RayTraceProcedural: 0
m_RenderingLayerMask: 1
m_RendererPriority: 0
m_Materials:
- {fileID: 2100000, guid: 31321ba15b8f8eb4c954353edc038b1d, type: 2}
m_StaticBatchInfo:
firstSubMesh: 0
subMeshCount: 0
m_StaticBatchRoot: {fileID: 0}
m_ProbeAnchor: {fileID: 0}
m_LightProbeVolumeOverride: {fileID: 0}
m_ScaleInLightmap: 1
m_ReceiveGI: 1
m_PreserveUVs: 0
m_IgnoreNormalsForChartDetection: 0
m_ImportantGI: 0
m_StitchLightmapSeams: 1
m_SelectedEditorRenderState: 3
m_MinimumChartSize: 4
m_AutoUVMaxDistance: 0.5
m_AutoUVMaxAngle: 89
m_LightmapParameters: {fileID: 0}
m_SortingLayerID: 0
m_SortingLayer: 0
m_SortingOrder: 0
m_AdditionalVertexStreams: {fileID: 0}
--- !u!33 &1174856040
MeshFilter:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1174856037}
m_Mesh: {fileID: 10202, guid: 0000000000000000e000000000000000, type: 0}
--- !u!4 &1174856041
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1174856037}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: -4.2, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children:
- {fileID: 740122246}
m_Father: {fileID: 0}
m_RootOrder: 3
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &1484791041 --- !u!1 &1484791041
GameObject: GameObject:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
@ -648,93 +544,124 @@ MonoBehaviour:
type: 3} type: 3}
m_DeselectOnBackgroundClick: 1 m_DeselectOnBackgroundClick: 1
m_PointerBehavior: 0 m_PointerBehavior: 0
--- !u!1001 &4618792496064108453 --- !u!1 &1525258599
PrefabInstance: GameObject:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
serializedVersion: 2 m_CorrespondingSourceObject: {fileID: 0}
m_Modification: m_PrefabInstance: {fileID: 0}
m_TransformParent: {fileID: 740122246} m_PrefabAsset: {fileID: 0}
m_Modifications: serializedVersion: 6
- target: {fileID: 4618792495020702613, guid: a6c9897145ea93b41abf3c531f857e3b, m_Component:
- component: {fileID: 1525258600}
- component: {fileID: 1525258603}
- component: {fileID: 1525258602}
- component: {fileID: 1525258604}
m_Layer: 5
m_Name: Inventory
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!224 &1525258600
RectTransform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1525258599}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 740122246}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 1, y: 1}
m_AnchoredPosition: {x: -0.002380371, y: 0}
m_SizeDelta: {x: -0.0050049, y: 0}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!114 &1525258602
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1525258599}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: be20146989e64cf4ca34bf1d20a3786f, type: 3}
m_Name:
m_EditorClassIdentifier:
slotPrefab: {fileID: 3349303436265952796, guid: c043653a099f2824382980634a1da69b,
type: 3} type: 3}
propertyPath: parentObject inventories:
value: - specialSlotNumber: -1
objectReference: {fileID: 1174856037} items:
- target: {fileID: 4618792495020702613, guid: a6c9897145ea93b41abf3c531f857e3b, - slotId: 1
type: 3} item: {fileID: 11400000, guid: 343c8b75bba44e049ba08bae058b073b, type: 2}
propertyPath: maxNormalmSlots - slotId: 2
value: 6 item: {fileID: 11400000, guid: ada3fd94ae7151e42997797a34e7f32d, type: 2}
objectReference: {fileID: 0} - slotId: 3
- target: {fileID: 4618792495020702613, guid: a6c9897145ea93b41abf3c531f857e3b, item: {fileID: 11400000, guid: 3e0b52594036ed847b3a7746df83af71, type: 2}
type: 3} - slotId: 4
propertyPath: simplifyObject.Array.size item: {fileID: 11400000, guid: 6b66adde43575b34a8f8c450203f9536, type: 2}
value: 1 - slotId: 5
objectReference: {fileID: 0} item: {fileID: 11400000, guid: c9a677a526561bf49a949a369e976bda, type: 2}
- target: {fileID: 4618792495020702613, guid: a6c9897145ea93b41abf3c531f857e3b, - slotId: 6
type: 3} item: {fileID: 11400000, guid: 73373df3d121cea428a500fe345ba6a9, type: 2}
propertyPath: simplifyObject.Array.data[0] - specialSlotNumber: 7
value: items:
objectReference: {fileID: 2683428033455470680, guid: e4709fc7d46b73549bd76044d6991645, - slotId: 7.1
type: 3} item: {fileID: 11400000, guid: 8076a09eb2ef52e44aa3fe255654bc90, type: 2}
- target: {fileID: 4618792496510273084, guid: a6c9897145ea93b41abf3c531f857e3b, - slotId: 7.2
type: 3} item: {fileID: 11400000, guid: 8076a09eb2ef52e44aa3fe255654bc90, type: 2}
propertyPath: m_RootOrder - slotId: 7.3
value: 0 item: {fileID: 11400000, guid: 8076a09eb2ef52e44aa3fe255654bc90, type: 2}
objectReference: {fileID: 0} - specialSlotNumber: 8
- target: {fileID: 4618792496510273084, guid: a6c9897145ea93b41abf3c531f857e3b, items:
type: 3} - slotId: 8.1
propertyPath: m_LocalPosition.x item: {fileID: 11400000, guid: 8076a09eb2ef52e44aa3fe255654bc90, type: 2}
value: 0 - specialSlotNumber: 9
objectReference: {fileID: 0} items:
- target: {fileID: 4618792496510273084, guid: a6c9897145ea93b41abf3c531f857e3b, - slotId: 9.1
type: 3} item: {fileID: 11400000, guid: 8076a09eb2ef52e44aa3fe255654bc90, type: 2}
propertyPath: m_LocalPosition.y slotsUiObject: []
value: -90 slotInfoArray: []
objectReference: {fileID: 0} selectedSlot: 0
- target: {fileID: 4618792496510273084, guid: a6c9897145ea93b41abf3c531f857e3b, selectedSlot_special: 0
type: 3} tmp_Item: {fileID: 11400000, guid: 8076a09eb2ef52e44aa3fe255654bc90, type: 2}
propertyPath: m_LocalPosition.z --- !u!222 &1525258603
value: 0 CanvasRenderer:
objectReference: {fileID: 0} m_ObjectHideFlags: 0
- target: {fileID: 4618792496510273084, guid: a6c9897145ea93b41abf3c531f857e3b, m_CorrespondingSourceObject: {fileID: 0}
type: 3} m_PrefabInstance: {fileID: 0}
propertyPath: m_LocalRotation.w m_PrefabAsset: {fileID: 0}
value: 1 m_GameObject: {fileID: 1525258599}
objectReference: {fileID: 0} m_CullTransparentMesh: 1
- target: {fileID: 4618792496510273084, guid: a6c9897145ea93b41abf3c531f857e3b, --- !u!114 &1525258604
type: 3} MonoBehaviour:
propertyPath: m_LocalRotation.x m_ObjectHideFlags: 0
value: -0 m_CorrespondingSourceObject: {fileID: 0}
objectReference: {fileID: 0} m_PrefabInstance: {fileID: 0}
- target: {fileID: 4618792496510273084, guid: a6c9897145ea93b41abf3c531f857e3b, m_PrefabAsset: {fileID: 0}
type: 3} m_GameObject: {fileID: 1525258599}
propertyPath: m_LocalRotation.y m_Enabled: 1
value: -0 m_EditorHideFlags: 0
objectReference: {fileID: 0} m_Script: {fileID: 11500000, guid: 8a8695521f0d02e499659fee002a26c2, type: 3}
- target: {fileID: 4618792496510273084, guid: a6c9897145ea93b41abf3c531f857e3b, m_Name:
type: 3} m_EditorClassIdentifier:
propertyPath: m_LocalRotation.z m_Padding:
value: -0 m_Left: 0
objectReference: {fileID: 0} m_Right: 0
- target: {fileID: 4618792496510273084, guid: a6c9897145ea93b41abf3c531f857e3b, m_Top: 0
type: 3} m_Bottom: 0
propertyPath: m_LocalEulerAnglesHint.x m_ChildAlignment: 8
value: 0 m_StartCorner: 1
objectReference: {fileID: 0} m_StartAxis: 1
- target: {fileID: 4618792496510273084, guid: a6c9897145ea93b41abf3c531f857e3b, m_CellSize: {x: 200, y: 20}
type: 3} m_Spacing: {x: 5, y: 0}
propertyPath: m_LocalEulerAnglesHint.y m_Constraint: 0
value: 0 m_ConstraintCount: 2
objectReference: {fileID: 0}
- target: {fileID: 4618792496510273084, guid: a6c9897145ea93b41abf3c531f857e3b,
type: 3}
propertyPath: m_LocalEulerAnglesHint.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 4618792496510273085, guid: a6c9897145ea93b41abf3c531f857e3b,
type: 3}
propertyPath: m_Name
value: Inventory
objectReference: {fileID: 0}
m_RemovedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: a6c9897145ea93b41abf3c531f857e3b, type: 3}

View file

@ -0,0 +1,303 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!29 &1
OcclusionCullingSettings:
m_ObjectHideFlags: 0
serializedVersion: 2
m_OcclusionBakeSettings:
smallestOccluder: 5
smallestHole: 0.25
backfaceThreshold: 100
m_SceneGUID: 00000000000000000000000000000000
m_OcclusionCullingData: {fileID: 0}
--- !u!104 &2
RenderSettings:
m_ObjectHideFlags: 0
serializedVersion: 9
m_Fog: 0
m_FogColor: {r: 0.5, g: 0.5, b: 0.5, a: 1}
m_FogMode: 3
m_FogDensity: 0.01
m_LinearFogStart: 0
m_LinearFogEnd: 300
m_AmbientSkyColor: {r: 0.212, g: 0.227, b: 0.259, a: 1}
m_AmbientEquatorColor: {r: 0.114, g: 0.125, b: 0.133, a: 1}
m_AmbientGroundColor: {r: 0.047, g: 0.043, b: 0.035, a: 1}
m_AmbientIntensity: 1
m_AmbientMode: 0
m_SubtractiveShadowColor: {r: 0.42, g: 0.478, b: 0.627, a: 1}
m_SkyboxMaterial: {fileID: 10304, guid: 0000000000000000f000000000000000, type: 0}
m_HaloStrength: 0.5
m_FlareStrength: 1
m_FlareFadeSpeed: 3
m_HaloTexture: {fileID: 0}
m_SpotCookie: {fileID: 10001, guid: 0000000000000000e000000000000000, type: 0}
m_DefaultReflectionMode: 0
m_DefaultReflectionResolution: 128
m_ReflectionBounces: 1
m_ReflectionIntensity: 1
m_CustomReflection: {fileID: 0}
m_Sun: {fileID: 0}
m_IndirectSpecularColor: {r: 0, g: 0, b: 0, a: 1}
m_UseRadianceAmbientProbe: 0
--- !u!157 &3
LightmapSettings:
m_ObjectHideFlags: 0
serializedVersion: 12
m_GIWorkflowMode: 1
m_GISettings:
serializedVersion: 2
m_BounceScale: 1
m_IndirectOutputScale: 1
m_AlbedoBoost: 1
m_EnvironmentLightingMode: 0
m_EnableBakedLightmaps: 1
m_EnableRealtimeLightmaps: 0
m_LightmapEditorSettings:
serializedVersion: 12
m_Resolution: 2
m_BakeResolution: 40
m_AtlasSize: 1024
m_AO: 0
m_AOMaxDistance: 1
m_CompAOExponent: 1
m_CompAOExponentDirect: 0
m_ExtractAmbientOcclusion: 0
m_Padding: 2
m_LightmapParameters: {fileID: 0}
m_LightmapsBakeMode: 1
m_TextureCompression: 1
m_FinalGather: 0
m_FinalGatherFiltering: 1
m_FinalGatherRayCount: 256
m_ReflectionCompression: 2
m_MixedBakeMode: 2
m_BakeBackend: 1
m_PVRSampling: 1
m_PVRDirectSampleCount: 32
m_PVRSampleCount: 512
m_PVRBounces: 2
m_PVREnvironmentSampleCount: 256
m_PVREnvironmentReferencePointCount: 2048
m_PVRFilteringMode: 1
m_PVRDenoiserTypeDirect: 1
m_PVRDenoiserTypeIndirect: 1
m_PVRDenoiserTypeAO: 1
m_PVRFilterTypeDirect: 0
m_PVRFilterTypeIndirect: 0
m_PVRFilterTypeAO: 0
m_PVREnvironmentMIS: 1
m_PVRCulling: 1
m_PVRFilteringGaussRadiusDirect: 1
m_PVRFilteringGaussRadiusIndirect: 5
m_PVRFilteringGaussRadiusAO: 2
m_PVRFilteringAtrousPositionSigmaDirect: 0.5
m_PVRFilteringAtrousPositionSigmaIndirect: 2
m_PVRFilteringAtrousPositionSigmaAO: 1
m_ExportTrainingData: 0
m_TrainingDataDestination: TrainingData
m_LightProbeSampleCountMultiplier: 4
m_LightingDataAsset: {fileID: 0}
m_LightingSettings: {fileID: 0}
--- !u!196 &4
NavMeshSettings:
serializedVersion: 2
m_ObjectHideFlags: 0
m_BuildSettings:
serializedVersion: 2
agentTypeID: 0
agentRadius: 0.5
agentHeight: 2
agentSlope: 45
agentClimb: 0.4
ledgeDropHeight: 0
maxJumpAcrossDistance: 0
minRegionArea: 2
manualCellSize: 0
cellSize: 0.16666667
manualTileSize: 0
tileSize: 256
accuratePlacement: 0
maxJobWorkers: 0
preserveTilesOutsideBounds: 0
debug:
m_Flags: 0
m_NavMeshData: {fileID: 0}
--- !u!1 &981422316
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 981422318}
- component: {fileID: 981422317}
m_Layer: 0
m_Name: Directional Light
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!108 &981422317
Light:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 981422316}
m_Enabled: 1
serializedVersion: 10
m_Type: 1
m_Shape: 0
m_Color: {r: 1, g: 0.95686275, b: 0.8392157, a: 1}
m_Intensity: 1
m_Range: 10
m_SpotAngle: 30
m_InnerSpotAngle: 21.80208
m_CookieSize: 10
m_Shadows:
m_Type: 2
m_Resolution: -1
m_CustomResolution: -1
m_Strength: 1
m_Bias: 0.05
m_NormalBias: 0.4
m_NearPlane: 0.2
m_CullingMatrixOverride:
e00: 1
e01: 0
e02: 0
e03: 0
e10: 0
e11: 1
e12: 0
e13: 0
e20: 0
e21: 0
e22: 1
e23: 0
e30: 0
e31: 0
e32: 0
e33: 1
m_UseCullingMatrixOverride: 0
m_Cookie: {fileID: 0}
m_DrawHalo: 0
m_Flare: {fileID: 0}
m_RenderMode: 0
m_CullingMask:
serializedVersion: 2
m_Bits: 4294967295
m_RenderingLayerMask: 1
m_Lightmapping: 4
m_LightShadowCasterMode: 0
m_AreaSize: {x: 1, y: 1}
m_BounceIntensity: 1
m_ColorTemperature: 6570
m_UseColorTemperature: 0
m_BoundingSphereOverride: {x: 0, y: 0, z: 0, w: 0}
m_UseBoundingSphereOverride: 0
m_UseViewFrustumForShadowCasterCull: 1
m_ShadowRadius: 0
m_ShadowAngle: 0
--- !u!4 &981422318
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 981422316}
m_LocalRotation: {x: 0.40821788, y: -0.23456968, z: 0.10938163, w: 0.8754261}
m_LocalPosition: {x: 0, y: 3, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 1
m_LocalEulerAnglesHint: {x: 50, y: -30, z: 0}
--- !u!1 &1207649550
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 1207649553}
- component: {fileID: 1207649552}
- component: {fileID: 1207649551}
m_Layer: 0
m_Name: Main Camera
m_TagString: MainCamera
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!81 &1207649551
AudioListener:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1207649550}
m_Enabled: 1
--- !u!20 &1207649552
Camera:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1207649550}
m_Enabled: 1
serializedVersion: 2
m_ClearFlags: 1
m_BackGroundColor: {r: 0.19215687, g: 0.3019608, b: 0.4745098, a: 0}
m_projectionMatrixMode: 1
m_GateFitMode: 2
m_FOVAxisMode: 0
m_SensorSize: {x: 36, y: 24}
m_LensShift: {x: 0, y: 0}
m_FocalLength: 50
m_NormalizedViewPortRect:
serializedVersion: 2
x: 0
y: 0
width: 1
height: 1
near clip plane: 0.3
far clip plane: 1000
field of view: 60
orthographic: 0
orthographic size: 5
m_Depth: -1
m_CullingMask:
serializedVersion: 2
m_Bits: 4294967295
m_RenderingPath: -1
m_TargetTexture: {fileID: 0}
m_TargetDisplay: 0
m_TargetEye: 3
m_HDR: 1
m_AllowMSAA: 1
m_AllowDynamicResolution: 0
m_ForceIntoRT: 0
m_OcclusionCulling: 1
m_StereoConvergence: 10
m_StereoSeparation: 0.022
--- !u!4 &1207649553
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1207649550}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 1, z: -10}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}

View file

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: f9b2d6565dce8e5458eadd7bf22931b6
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -0,0 +1,27 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using TMPro;
public class InventorySlot : MonoBehaviour
{
public float slotId;
public string itemName;
public int ammoInMag;
public int inStorageAmmo;
[SerializeField]
private TMP_Text slotIdDisplay, itemNameDisplay, ammoCountDisplay;
// Start is called before the first frame update
void Start()
{
slotIdDisplay.text = slotId.ToString();
itemNameDisplay.text = itemName;
}
public void UpdateGunAmmo()
{
ammoCountDisplay.text = ammoInMag + " + " + inStorageAmmo;
}
}

View file

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: b034f6998f291904db4f748038540cd6
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -0,0 +1,605 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Pool;
using TMPro;
// !! ========= NOTE ========= !!
// GetIndex_Id will return 0 as empty!
// So make sure you dont make any items with id 0 or below!
// !! ========= NOTE ========= !!
/*/
* Functions available here:
* -> GetIndex_Name
* -> GetIndex_Id
* -> GetIndex_ItemType
* -> GetIndex_SlotType
* -> GetIndex_ItemObject
* -> GetIndex_Slot
*
* -> SetIndex_Slot
* -> Set_Slot
* -> RemoveIndex_Slot
* -> RemoveIndex_Slotspecial
* -> Remove_Slot
* -> Remove_Slotspecial
*
* -> UpdateIndex_Slotsobject
* -> Update_Slotsobject
*
* -> Spawn_Object
* -> RemoveCurrent_Object
*
* -> setupSlot
*
* -> Debug_Slot
* -> Debug_Functions
/*/
public class InventorySystem : MonoBehaviour
{
// Used to make slots specific to what item it can accept
[System.Serializable]
class slotInfo
{
public Item Item; // Most likely wont be needed
public int slotId; // slot Id without subslots
public Item.ItemTypeEnum ItemType;
public Item.SlotTypeEnum SlotType;
public slotInfo(Item.ItemTypeEnum inputItemType, Item.SlotTypeEnum inputSlotType, float slotId)
{
ItemType = inputItemType;
SlotType = inputSlotType;
}
}
[SerializeField]
private GameObject slotPrefab;
public List<Inventory> inventories;
public List<GameObject> slotsUiObject;
[SerializeField]
private List<slotInfo> slotInfoArray = new List<slotInfo>(); // Used to check compatibility with items that are being stored
public int selectedSlot;
public int selectedSlot_special;
private GameObject currentGameObject = null; // Used to check stored current GameObject to destroy it later when not used or switching item
[System.Serializable]
public class Items
{
public float slotId;
public Item item;
}
[System.Serializable]
public class Inventory
{
[Tooltip("set to -1 to have it as a common inventory")]
public int specialSlotNumber;
public List<Items> items;
}
// TMP
public Item tmp_Item; // Tmp
public class GetSlotData
{
public int index;
// GetIndex_[Name] will return specific data from specified index slot
public static string ItemName(float slotId, InventorySystem slotSystem)
{
for (int inventory = 0; inventory < slotSystem.inventories.Count; inventory++)
{
for (int slot = 0; slot < slotSystem.inventories[inventory].items.Count; slot++)
{
if (slotSystem.inventories[inventory].items[slot].slotId == slotId)
{
return slotSystem.inventories[inventory].items[slot].item.ItemName;
}
}
}
return null;
}
public static uint ItemId(float slotId, InventorySystem slotSystem)
{
for (int inventory = 0; inventory < slotSystem.inventories.Count; inventory++)
{
for (int slot = 0; slot < slotSystem.inventories[inventory].items.Count; slot++)
{
if (slotSystem.inventories[inventory].items[slot].slotId == slotId)
{
return slotSystem.inventories[inventory].items[slot].item.ItemID;
}
}
}
return 0; // 0 will basically mean none
}
public static Item.ItemTypeEnum ItemType(float slotId, InventorySystem slotSystem)
{
for (int inventory = 0; inventory < slotSystem.inventories.Count; inventory++)
{
for (int slot = 0; slot < slotSystem.inventories[inventory].items.Count; slot++)
{
if (slotSystem.inventories[inventory].items[slot].slotId == slotId)
{
return slotSystem.inventories[inventory].items[slot].item.ItemType;
}
}
}
return Item.ItemTypeEnum.None;
}
public static Item.SlotTypeEnum SlotType(float slotId, InventorySystem slotSystem)
{
for (int inventory = 0; inventory < slotSystem.inventories.Count; inventory++)
{
for (int slot = 0; slot < slotSystem.inventories[inventory].items.Count; slot++)
{
if (slotSystem.inventories[inventory].items[slot].slotId == slotId)
{
return slotSystem.inventories[inventory].items[slot].item.SlotType;
}
}
}
return Item.SlotTypeEnum.None;
}
public static Object ItemObject(float slotId, InventorySystem slotSystem)
{
for (int inventory = 0; inventory < slotSystem.inventories.Count; inventory++)
{
for (int slot = 0; slot < slotSystem.inventories[inventory].items.Count; slot++)
{
if (slotSystem.inventories[inventory].items[slot].slotId == slotId)
{
return slotSystem.inventories[inventory].items[slot].item.ItemObject;
}
}
}
return null;
}
public static Item ItemInSlot(float slotId, InventorySystem slotSystem)
{
for (int inventory = 0; inventory < slotSystem.inventories.Count; inventory++)
{
for (int slot = 0; slot < slotSystem.inventories[inventory].items.Count; slot++)
{
if (slotSystem.inventories[inventory].items[slot].slotId == slotId)
{
return slotSystem.inventories[inventory].items[slot].item;
}
}
}
return null;
}
}
public class InventoryUtilities
{
// SetIndex_[Name] will set specific data to specified index slot
public static bool SetSlotItem(float slotId, Item itemData, InventorySystem slotSystem)
{
for (int inventory = 0; inventory < slotSystem.inventories.Count; inventory++)
{
for (int slot = 0; slot < slotSystem.inventories[inventory].items.Count; slot++)
{
if (slotSystem.slotInfoArray[slot].GetType() == typeof(slotInfo))
{
slotInfo slotData = slotSystem.slotInfoArray[slot];
if (slotData.ItemType == itemData.ItemType && slotData.SlotType == itemData.SlotType && slotData.slotId == slotId)
{
Item oldItem = slotSystem.inventories[inventory].items[slot].item;
Item newItem = itemData;
slotSystem.tmp_Item = oldItem; // [Insert] drop / remove function here
slotSystem.inventories[inventory].items[slot].item = newItem;
return true;
}
}
}
}
return false;
}
// set_[Name] will check all indexes and if free, then place
public static bool Set_Slot(Item itemData, InventorySystem slotSystem)
{
for (int inventory = 0; inventory < slotSystem.inventories.Count; inventory++)
{
for (int slot = 0; slot < slotSystem.inventories[inventory].items.Count; slot++)
{
slotInfo slotData = slotSystem.slotInfoArray[inventory];
if (slotData.ItemType == itemData.ItemType && slotData.SlotType == itemData.SlotType)
{
slotSystem.inventories[inventory].items[slot].item = itemData;
return true;
}
}
}
return false;
}
// removeIndex_[Name] will remove specific index from slot
public static bool RemoveIndex_Item(float slotId, InventorySystem slotSystem)
{
for (int inventory = 0; inventory < slotSystem.inventories.Count; inventory++)
{
for (int slot = 0; slot < slotSystem.inventories[inventory].items.Count; slot++)
{
if (slotSystem.inventories[inventory].items[slot].item != null)
{
slotSystem.inventories[inventory].items[slot].item = null;
return true;
}
}
}
return false;
}
// remove_[Name] will remove all items from slot
public static bool Remove_Slot(InventorySystem slotSystem)
{
try
{
for (int i = 0; i < slotSystem.inventories.Count; i++)
{
slotSystem.inventories[i] = null;
}
return true;
}
catch
{
return false;
}
}
}
// updateIndex_[Name] will update specified index text (might come more soon)
void UpdateIndex_Slotsobject(float slotId)
{
try
{
//slots_object[index].transform.GetChild(3).gameObject.GetComponent<TMPro.TextMeshProUGUI>().text = GetSlotData.ItemName(index, this);
//slots_object[index].transform.GetChild(4).gameObject.GetComponent<TMPro.TextMeshProUGUI>().text = "Other";
}
catch
{
Debug.LogError("Couldn't update! Possible problem to this are 'index', 'GetChild' or 'GetComponent'");
}
}
// update_[Name] will update all index text (might come more soon)
public void Update_Slotsobject()
{
if (slotsUiObject == null)
{
foreach (GameObject slot in slotsUiObject)
{
Destroy(slot);
}
}
try
{
for (int inventory = 0; inventory < inventories.Count; inventory++)
{
var currentInventory = inventories[inventory];
switch (currentInventory.specialSlotNumber)
{
default:
for (int item = 0; item < inventories[inventory].items.Count; item++)
{
InventorySlot slotData;
GameObject slot;
var currentItem = inventories[inventory].items[item];
slot = Instantiate(slotPrefab);
slotData = slot.GetComponent<InventorySlot>();
slot.transform.SetParent(gameObject.transform, false);
slotData.slotId = currentItem.slotId;
slotData.itemName = currentItem.item.ItemName;
slotsUiObject.Add(slot);
switch (currentItem.slotId)
{
case 1:
slotInfoArray.Add(new slotInfo(Item.ItemTypeEnum.BasicItem, Item.SlotTypeEnum.Melee, 1));
break;
case 2:
slotInfoArray.Add(new slotInfo(Item.ItemTypeEnum.BasicItem, Item.SlotTypeEnum.Secondary, 2));
break;
case 3:
slotInfoArray.Add(new slotInfo(Item.ItemTypeEnum.BasicItem, Item.SlotTypeEnum.Primary, 3));
break;
case 4:
slotInfoArray.Add(new slotInfo(Item.ItemTypeEnum.BasicItem, Item.SlotTypeEnum.Grenede, 4));
break;
case 5:
slotInfoArray.Add(new slotInfo(Item.ItemTypeEnum.BasicItem, Item.SlotTypeEnum.Pickprop, 5));
break;
case 6:
slotInfoArray.Add(new slotInfo(Item.ItemTypeEnum.BasicItem, Item.SlotTypeEnum.Empty, 6));
break;
}
}
break;
case 7:
for (int item = 0; item < inventories[inventory].items.Count; item++)
{
InventorySlot slotData;
GameObject slot;
var currentItem = inventories[inventory].items[item];
slot = Instantiate(slotPrefab);
slot.transform.SetParent(gameObject.transform, false);
slotData = slot.GetComponent<InventorySlot>();
slotData.slotId = currentItem.slotId;
slotData.itemName = currentItem.item.ItemName;
slotsUiObject.Add(slot);
for (int i = 0; i < inventories[inventory].items.Count; i++)
{
slotInfoArray.Add(new slotInfo(Item.ItemTypeEnum.BasicItem, Item.SlotTypeEnum.Melee, currentItem.slotId));
}
}
break;
case 8:
for (int item = 0; item < inventories[inventory].items.Count; item++)
{
InventorySlot slotData;
GameObject slot;
var currentItem = inventories[inventory].items[item];
slot = Instantiate(slotPrefab);
slot.transform.SetParent(gameObject.transform, false);
slotData = slot.GetComponent<InventorySlot>();
slotData.slotId = currentItem.slotId;
slotData.itemName = currentItem.item.ItemName;
slotsUiObject.Add(slot);
for (int i = 0; i < inventories[inventory].items.Count; i++)
{
slotInfoArray.Add(new slotInfo(Item.ItemTypeEnum.BasicItem, Item.SlotTypeEnum.Melee, currentItem.slotId));
}
}
break;
case 9:
for (int item = 0; item < inventories[inventory].items.Count; item++)
{
InventorySlot slotData;
GameObject slot;
var currentItem = inventories[inventory].items[item];
slot = Instantiate(slotPrefab);
slot.transform.SetParent(gameObject.transform, false);
slotData = slot.GetComponent<InventorySlot>();
slotData.slotId = currentItem.slotId;
slotData.itemName = currentItem.item.ItemName;
slotsUiObject.Add(slot);
for (int i = 0; i < inventories[inventory].items.Count; i++)
{
slotInfoArray.Add(new slotInfo(Item.ItemTypeEnum.BasicItem, Item.SlotTypeEnum.Melee, currentItem.slotId));
}
}
break;
}
}
}
catch
{
Debug.LogError("Couldn't update! Possible problem INSIDE for loop are 'index', 'GetChild' or 'GetComponent'");
}
}
// Spawn_[Name] will spawn object to the game world to a specific parentObject
public bool SpawnIndex_Object(float slotId)
{
try
{
bool result = false;
if (GetSlotData.ItemObject(slotId, this) != null)
{
for (int inventory = 0; inventory < inventories.Count; inventory++)
{
for (int slot = 0; slot < inventories[inventory].items.Count; slot++)
{
if (inventories[inventory].items[slot].slotId == slotId)
{
Debug.Log("Found slot id of " + slotId + " in inventory " + inventory + " on slot " + slot);
currentGameObject = Instantiate(GetSlotData.ItemObject(slotId, this)) as GameObject; // Pooling System in unity is way too confusing.. Ill research about it more later.
currentGameObject.transform.SetParent(transform, false);
}
}
}
result = true;
}
return result;
}
catch
{
Debug.LogError("Prefab could not be instantiated");
return false;
}
}
// removeCurrent_[Name] will remove current object if spawned any
public bool RemoveCurrent_Object()
{
try
{
if (currentGameObject != null)
{
Destroy(currentGameObject);
return true;
}
return false;
}
catch
{
Debug.LogError("currentGameObject could not be destroyed");
return false;
}
}
// Other
// Sets up slot types for different slot placement
void setupSlot()
{
Item.ItemTypeEnum EnumBasicItem = Item.ItemTypeEnum.BasicItem;
Item.ItemTypeEnum EnumSpecialItem = Item.ItemTypeEnum.SpecialItem;
Item.SlotTypeEnum EnumMelee = Item.SlotTypeEnum.Melee;
Item.SlotTypeEnum EnumSecondary = Item.SlotTypeEnum.Secondary;
Item.SlotTypeEnum EnumPrimary = Item.SlotTypeEnum.Primary;
Item.SlotTypeEnum EnumGrenede = Item.SlotTypeEnum.Grenede;
Item.SlotTypeEnum EnumPickprop = Item.SlotTypeEnum.Pickprop;
Item.SlotTypeEnum EnumEmpty = Item.SlotTypeEnum.Empty;
Item.SlotTypeEnum EnumSpecial = Item.SlotTypeEnum.Special;
slotInfoArray.Add(new slotInfo(EnumBasicItem, EnumMelee, 1)); // 1
slotInfoArray.Add(new slotInfo(EnumBasicItem, EnumSecondary, 2)); // 2
slotInfoArray.Add(new slotInfo(EnumBasicItem, EnumPrimary, 3)); // 3
slotInfoArray.Add(new slotInfo(EnumBasicItem, EnumGrenede, 4)); // 4
slotInfoArray.Add(new slotInfo(EnumBasicItem, EnumPickprop, 5)); // 5
slotInfoArray.Add(new slotInfo(EnumBasicItem, EnumEmpty, 6)); // 6
slotInfoArray.Add(new slotInfo(EnumSpecialItem, EnumSpecial, 7)); // 7
slotInfoArray.Add(new slotInfo(EnumSpecialItem, EnumSpecial, 8)); // 7
slotInfoArray.Add(new slotInfo(EnumSpecialItem, EnumSpecial, 9)); // 7
}
// Debug slot
void Debug_Slot()
{
for (int iinventory = 0; iinventory < inventories.Count; iinventory++)
{
if (inventories[iinventory] != null)
{
Debug.Log("Slot_" + iinventory + " = " + inventories[iinventory].items.Count);
}
else
{
Debug.Log("Slot_" + iinventory + " = Empty");
}
}
}
// Use this as refrence if you dont know how to use my functions
void Debug_Functions(int Type)
{
Item OLDITEM = tmp_Item;
if (Type == 0) // Using Set_[Name]
{
if (InventoryUtilities.Set_Slot(tmp_Item, this))
{
Debug.Log(OLDITEM.ItemName + " Has been stored!");
tmp_Item = null;
}
else
{
Debug.Log(OLDITEM.ItemName + " Couldn't find free slot");
}
}
else if (Type == 1) // Using SetIndex_[Name]
{
if (InventoryUtilities.SetSlotItem(selectedSlot, tmp_Item, this))
{
Debug.Log(OLDITEM.ItemName + " Has been stored and dropped old item from slot!");
}
else
{
Debug.Log(OLDITEM.ItemName + " Does not fit for this slot, try another one!");
}
}
}
// Start is called before the first frame update
void Start()
{
//setupSlot(); // Must setup before using any other functions
//InventoryUtilities.Set_Slot(tmp_Item, this);
Update_Slotsobject();
SpawnIndex_Object(0);
//RemoveCurrent_Object();
Debug.Log(GetSlotData.ItemName(7.1f, this));
}
}

View file

@ -3,7 +3,7 @@ using System.Collections.Generic;
using UnityEngine; using UnityEngine;
// Rename it later if you wish to // Rename it later if you wish to
[CreateAssetMenu(fileName = "Item", menuName = "InventorySystem")] [CreateAssetMenu(fileName = "Item", menuName = "OpenCodeBox/Player/Item")]
public class Item : ScriptableObject public class Item : ScriptableObject
{ {
public enum ItemTypeEnum public enum ItemTypeEnum
@ -29,6 +29,7 @@ public class Item : ScriptableObject
public uint ItemID; public uint ItemID;
public ItemTypeEnum ItemType = new ItemTypeEnum(); public ItemTypeEnum ItemType = new ItemTypeEnum();
public SlotTypeEnum SlotType = new SlotTypeEnum(); public SlotTypeEnum SlotType = new SlotTypeEnum();
public int UsedSpecialSlotNumber; //used to determine which special slot to use when storing in inventory (in case it's a common item then set it to -1)
public Object ItemObject; public Object ItemObject;
} }