This commit is contained in:
dhain 2022-05-19 16:41:05 +02:00
parent 470aeff3f3
commit d2c90c3b7f
3 changed files with 10 additions and 7 deletions

View file

@ -919,7 +919,7 @@ RectTransform:
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0.5, y: 0.5} m_AnchorMin: {x: 0.5, y: 0.5}
m_AnchorMax: {x: 0.5, y: 0.5} m_AnchorMax: {x: 0.5, y: 0.5}
m_AnchoredPosition: {x: -268, y: 152} m_AnchoredPosition: {x: -385, y: 50}
m_SizeDelta: {x: 100, y: 100} m_SizeDelta: {x: 100, y: 100}
m_Pivot: {x: 0.5, y: 0.5} m_Pivot: {x: 0.5, y: 0.5}
--- !u!114 &466567697 --- !u!114 &466567697
@ -2080,7 +2080,7 @@ RectTransform:
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0.5, y: 0.5} m_AnchorMin: {x: 0.5, y: 0.5}
m_AnchorMax: {x: 0.5, y: 0.5} m_AnchorMax: {x: 0.5, y: 0.5}
m_AnchoredPosition: {x: -156, y: 144} m_AnchoredPosition: {x: -388, y: 152}
m_SizeDelta: {x: 100, y: 100} m_SizeDelta: {x: 100, y: 100}
m_Pivot: {x: 0.5, y: 0.5} m_Pivot: {x: 0.5, y: 0.5}
--- !u!114 &1119271991 --- !u!114 &1119271991
@ -3008,7 +3008,7 @@ RectTransform:
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 1, y: 0} m_AnchorMin: {x: 1, y: 0}
m_AnchorMax: {x: 1, y: 0} m_AnchorMax: {x: 1, y: 0}
m_AnchoredPosition: {x: -348, y: 107} m_AnchoredPosition: {x: -413, y: 211}
m_SizeDelta: {x: 720, y: 430} m_SizeDelta: {x: 720, y: 430}
m_Pivot: {x: 0.5, y: 0.5} m_Pivot: {x: 0.5, y: 0.5}
--- !u!1001 &1701153146 --- !u!1001 &1701153146
@ -3235,7 +3235,6 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: b18feac5270242d4a85c78ce72972d56, type: 3} m_Script: {fileID: 11500000, guid: b18feac5270242d4a85c78ce72972d56, type: 3}
m_Name: m_Name:
m_EditorClassIdentifier: m_EditorClassIdentifier:
inventory: {fileID: 1800469991}
startMoney: 100 startMoney: 100
--- !u!4 &1800469990 --- !u!4 &1800469990
Transform: Transform:

View file

@ -29,6 +29,7 @@ public class Inventory : MonoBehaviour {
} }
public void tempAddItem(Item item) { public void tempAddItem(Item item) {
Debug.Log("AWSD");
AddItem(item, 1); AddItem(item, 1);
} }
@ -38,13 +39,15 @@ public class Inventory : MonoBehaviour {
return; return;
} }
Debug.Log("ASDADADWDASDWD");
if(!items.ContainsKey(item)) { if(!items.ContainsKey(item)) {
items.Add(item, amount); items.Add(item, amount);
} else { } else {
items[item] += amount; items[item] += amount;
} }
onItemChangedCallback?.Invoke(); onItemChangedCallback?.Invoke();
} }

View file

@ -20,7 +20,7 @@ public class PlayerController : MonoBehaviour {
#endregion #endregion
public Inventory inventory; private Inventory _inventory;
private int money; private int money;
private UsableItem selectedItem; private UsableItem selectedItem;
@ -29,13 +29,14 @@ public class PlayerController : MonoBehaviour {
// Start is called before the first frame update // Start is called before the first frame update
void Start() { void Start() {
money = startMoney; money = startMoney;
_inventory = Inventory.instance;
} }
// Update is called once per frame // Update is called once per frame
void Update() { } void Update() { }
public void SetSelectedItem(UsableItem item) { public void SetSelectedItem(UsableItem item) {
if(inventory.items.ContainsKey(item)) { if(_inventory.items.ContainsKey(item)) {
selectedItem = item; selectedItem = item;
Cursor.SetCursor(item.defaultSprite.texture, Vector2.zero, CursorMode.Auto); Cursor.SetCursor(item.defaultSprite.texture, Vector2.zero, CursorMode.Auto);
} else { } else {