Inventory and minigame tweaks

This commit is contained in:
joonasp 2022-04-04 18:57:40 +03:00
parent e671f77c77
commit c13d671975
7 changed files with 67 additions and 11 deletions

View File

@ -248,3 +248,4 @@ MonoBehaviour:
canStack: 1
itemName: Red Mushroom
itemDescription:
prefab: {fileID: 4385080170328260021}

View File

@ -248,3 +248,4 @@ MonoBehaviour:
canStack: 1
itemName: Brown Mushroom
itemDescription:
prefab: {fileID: 5440707293445505367}

View File

@ -318,6 +318,7 @@ MonoBehaviour:
canStack: 1
itemName: Magic essence
itemDescription:
prefab: {fileID: 3467985268477833302}
--- !u!1 &5463776654730074005
GameObject:
m_ObjectHideFlags: 0

View File

@ -92,7 +92,7 @@ public class InventoryItem : MonoBehaviour
if (Count == 0)
{
//Destroys this gameobject if the count is 0 or lower
Destroy(this);
Destroy(gameObject);
return true;
}
UpdateText();
@ -103,9 +103,10 @@ public class InventoryItem : MonoBehaviour
public void PopItem()
{
GameObject item = Instantiate(itemPrefab, transform.position + transform.forward, Quaternion.identity);
GameObject item = Instantiate(_itemData.prefab, transform.position + transform.forward, Quaternion.identity);
item.transform.localScale = new Vector3(1, 1, 1);
item.transform.localScale = Vector3.one;
item.transform.name = _itemData.name;
var colliderComponent = item.GetComponent<Collider>();
if (colliderComponent != null) colliderComponent.enabled = true;
@ -117,6 +118,9 @@ public class InventoryItem : MonoBehaviour
rigidbodyComponent.useGravity = true;
}
var xrGrabInteractableComponent = item.GetComponent<XRGrabInteractable>();
if (xrGrabInteractableComponent != null) xrGrabInteractableComponent.enabled = true;
ChangeCount(-1);
}

View File

@ -10,6 +10,7 @@ public class ItemData : MonoBehaviour
public bool canStack;
public string itemName;
public string itemDescription;
public GameObject prefab;
public override string ToString()
{

View File

@ -8,7 +8,7 @@ public class EssenceNodeController : MonoBehaviour
[SerializeField]
private AudioSource chime;
public Inventory playerInventory;
private Inventory playerInventory;
public bool isTouched;
private bool followPlayer = false;
@ -22,6 +22,7 @@ public class EssenceNodeController : MonoBehaviour
private void Awake()
{
nodeMaterial = GetComponent<Renderer>().material;
playerInventory = GameObject.Find("Inventory").GetComponent<Inventory>();
}
public void Touched()

View File

@ -156,6 +156,53 @@ MonoBehaviour:
rightDistance: 0.1
maxUp: 0.2
minDown: -0.2
--- !u!1 &112254268
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 112254270}
- component: {fileID: 112254269}
m_Layer: 0
m_Name: Inventory
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!114 &112254269
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 112254268}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 29f5f8aed8d641c3abc54850a6a876cc, type: 3}
m_Name:
m_EditorClassIdentifier:
additionalSlots: []
itemContainerPrefab: {fileID: 4641253255217536251, guid: b609e3c6adb2d2b4196415d93e789ddd,
type: 3}
--- !u!4 &112254270
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 112254268}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: -8.05, y: 1.336, z: -12.369}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 16
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!4 &407110722 stripped
Transform:
m_CorrespondingSourceObject: {fileID: 3475118261464492563, guid: 1f4d373a613d0466fbd8849470265852,
@ -510,22 +557,22 @@ PrefabInstance:
- target: {fileID: 1015801306266775024, guid: fe14b264b0f9cdf4cb9b3b8da9d57a51,
type: 3}
propertyPath: m_RootOrder
value: 1
value: 3
objectReference: {fileID: 0}
- target: {fileID: 1015801306266775024, guid: fe14b264b0f9cdf4cb9b3b8da9d57a51,
type: 3}
propertyPath: m_LocalPosition.x
value: -5.818
value: -6.234
objectReference: {fileID: 0}
- target: {fileID: 1015801306266775024, guid: fe14b264b0f9cdf4cb9b3b8da9d57a51,
type: 3}
propertyPath: m_LocalPosition.y
value: 1.212
value: 1.189
objectReference: {fileID: 0}
- target: {fileID: 1015801306266775024, guid: fe14b264b0f9cdf4cb9b3b8da9d57a51,
type: 3}
propertyPath: m_LocalPosition.z
value: -10.122
value: -10.103
objectReference: {fileID: 0}
- target: {fileID: 1015801306266775024, guid: fe14b264b0f9cdf4cb9b3b8da9d57a51,
type: 3}
@ -1098,7 +1145,7 @@ Transform:
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 13
m_RootOrder: 14
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &913183357
GameObject:
@ -1531,7 +1578,7 @@ PrefabInstance:
- target: {fileID: 7543052554475355072, guid: cb8b19b563b3d224897e3b3d94c353aa,
type: 3}
propertyPath: m_RootOrder
value: 3
value: 4
objectReference: {fileID: 0}
- target: {fileID: 7543052554475355072, guid: cb8b19b563b3d224897e3b3d94c353aa,
type: 3}
@ -2515,7 +2562,7 @@ PrefabInstance:
objectReference: {fileID: 0}
- target: {fileID: 431264, guid: 14a1089dfc8b2f949937da50bf38bc90, type: 3}
propertyPath: m_RootOrder
value: 10
value: 11
objectReference: {fileID: 0}
- target: {fileID: 431264, guid: 14a1089dfc8b2f949937da50bf38bc90, type: 3}
propertyPath: m_LocalPosition.x