diff --git a/Assets/Scenes/MainScene.unity b/Assets/Scenes/MainScene.unity index 64eb6d0..0c5b725 100644 --- a/Assets/Scenes/MainScene.unity +++ b/Assets/Scenes/MainScene.unity @@ -1638,8 +1638,8 @@ MonoBehaviour: m_TargetGraphic: {fileID: 2006577139} m_HandleRect: {fileID: 2006577138} m_Direction: 2 - m_Value: 0.9999998 - m_Size: 0.59324205 + m_Value: 1 + m_Size: 0.5932421 m_NumberOfSteps: 0 m_OnValueChanged: m_PersistentCalls: @@ -4906,7 +4906,7 @@ MonoBehaviour: m_Name: m_EditorClassIdentifier: menu: {fileID: 1395531174} - dayCountTextMeshProUGUI: {fileID: 1089918735} + dayCountTextMeshProUGUI: {fileID: 0} --- !u!212 &1278234715 SpriteRenderer: m_ObjectHideFlags: 0 @@ -4967,7 +4967,7 @@ Transform: m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 1278234712} m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} - m_LocalPosition: {x: -5.57, y: -2.97, z: -1} + m_LocalPosition: {x: -4.52, y: 3.09, z: -1} m_LocalScale: {x: 1, y: 1, z: 1} m_ConstrainProportionsScale: 0 m_Children: @@ -4996,7 +4996,7 @@ GameObject: m_Icon: {fileID: 0} m_NavMeshLayer: 0 m_StaticEditorFlags: 0 - m_IsActive: 1 + m_IsActive: 0 --- !u!114 &1291863650 MonoBehaviour: m_ObjectHideFlags: 0 @@ -6888,7 +6888,6 @@ MonoBehaviour: startItems: - {fileID: 11400000, guid: 008a8fdd2c3a95745acafee4087a855d, type: 2} - {fileID: 11400000, guid: 430db451ae959f34b8fba8d8b17276fd, type: 2} - - {fileID: 11400000, guid: ea1a26b19bc34a0ba29bad77253c7266, type: 2} --- !u!114 &1800469992 MonoBehaviour: m_ObjectHideFlags: 0 @@ -6906,7 +6905,6 @@ MonoBehaviour: - {fileID: 11400000, guid: d651d57ba97a4246a0094409e29fe56a, type: 2} - {fileID: 11400000, guid: 430db451ae959f34b8fba8d8b17276fd, type: 2} - {fileID: 11400000, guid: 008a8fdd2c3a95745acafee4087a855d, type: 2} - - {fileID: 11400000, guid: ea1a26b19bc34a0ba29bad77253c7266, type: 2} --- !u!1001 &1805366398 PrefabInstance: m_ObjectHideFlags: 0 diff --git a/Assets/Scripts/HoverManager.cs b/Assets/Scripts/HoverManager.cs index 1908452..4f4753c 100644 --- a/Assets/Scripts/HoverManager.cs +++ b/Assets/Scripts/HoverManager.cs @@ -6,23 +6,23 @@ public class HoverManager : MonoBehaviour { public TextMeshProUGUI descriptionText; public RectTransform descriptionHoverBackground; - public static Action onMouseHover; + public static Action onMouseHoverDescription; public static Action onMouseExit; private void OnEnable() { - onMouseHover += ShowDescription; + onMouseHoverDescription += ShowDescription; onMouseExit += HideDescription; } private void OnDisable() { - onMouseHover -= ShowDescription; + onMouseHoverDescription -= ShowDescription; onMouseExit -= HideDescription; } private void Start() { HideDescription(); } - + /** * Show the description Text at the mouse position */ diff --git a/Assets/Scripts/Inventory.cs b/Assets/Scripts/Inventory.cs index f297705..b6e5187 100644 --- a/Assets/Scripts/Inventory.cs +++ b/Assets/Scripts/Inventory.cs @@ -15,13 +15,13 @@ public class Inventory : ItemStorage { #endregion - public const int InventorySpace = 28; + private const int _InventorySpace = 28; /** * Adds the specified amount of items to the Inventory */ public override void AddItem(Item item, int amount) { - if(items.Count >= InventorySpace) { + if(items.Count >= _InventorySpace) { Debug.Log("Not enough inventory space!"); return; } diff --git a/Assets/Scripts/InventoryUI.cs b/Assets/Scripts/InventoryUI.cs index ffe6660..f4d37e4 100644 --- a/Assets/Scripts/InventoryUI.cs +++ b/Assets/Scripts/InventoryUI.cs @@ -35,7 +35,7 @@ public class InventoryUI : MonoBehaviour { private void ToggleInventory() { inventoryUI.SetActive(!inventoryUI.activeSelf); } - +//TODO: sell Items with right click and when shop is open /** * Is called when something in the Inventory UI should update */ diff --git a/Assets/Scripts/ItemStorage.cs b/Assets/Scripts/ItemStorage.cs index 3b023ba..99e5f02 100644 --- a/Assets/Scripts/ItemStorage.cs +++ b/Assets/Scripts/ItemStorage.cs @@ -35,7 +35,7 @@ public class ItemStorage : MonoBehaviour { * Removes the specified amount of items in the Item Storage */ public void RemoveItem(Item item, int amount) { - if(items[item] <= 0) { + if(items[item]-amount <= 0) { items.Remove(item); } else { items[item] -= amount; diff --git a/Assets/Scripts/ItemStorageSlot.cs b/Assets/Scripts/ItemStorageSlot.cs index f8c8f04..5aba5c4 100644 --- a/Assets/Scripts/ItemStorageSlot.cs +++ b/Assets/Scripts/ItemStorageSlot.cs @@ -13,23 +13,36 @@ public class ItemStorageSlot : MonoBehaviour, IPointerEnterHandler, IPointerExit private Item _item; - #region DescriptionHover + #region HoverOverItem public float timeToWait; public void OnPointerEnter(PointerEventData eventData) { StopAllCoroutines(); StartCoroutine(StartTimer()); + + ChangeItemSelectedSprite(true); } public void OnPointerExit(PointerEventData eventData) { StopAllCoroutines(); + ChangeItemSelectedSprite(false); HoverManager.onMouseExit(); } private void ShowMessage() { if(_item){ - HoverManager.onMouseHover(_item.description, Input.mousePosition); + HoverManager.onMouseHoverDescription(_item.description, Input.mousePosition); + } + } + + private void ChangeItemSelectedSprite(bool on) { + if(_item) { + if(on) { + icon.sprite = _item.selectedSprite; + } else { + icon.sprite = _item.defaultSprite; + } } } diff --git a/Assets/Scripts/Shop.cs b/Assets/Scripts/Shop.cs index 71c261a..072271a 100644 --- a/Assets/Scripts/Shop.cs +++ b/Assets/Scripts/Shop.cs @@ -1,4 +1,3 @@ -using System.Collections.Generic; using UnityEngine; public class Shop : ItemStorage { diff --git a/Assets/Scripts/ShopSlot.cs b/Assets/Scripts/ShopSlot.cs index 6c7855a..f18347e 100644 --- a/Assets/Scripts/ShopSlot.cs +++ b/Assets/Scripts/ShopSlot.cs @@ -19,10 +19,11 @@ public class ShopSlot : ItemStorageSlot { * Clears the Shop Slot */ public override void ClearSlot() { - base.ClearSlot(); nameText.text = ""; costText.text = ""; amountText.text = ""; + // _shop.RemoveItem(Item, 1); + base.ClearSlot(); } /** @@ -35,7 +36,6 @@ public class ShopSlot : ItemStorageSlot { _playerController.ChangeMoney(-Item.cost); Debug.Log("Buying Item: " + Item.displayName); - Debug.Log("money left: " + _playerController.Money); } else { Debug.Log("Not enough money to buy item."); } diff --git a/Assets/Scripts/ShopUI.cs b/Assets/Scripts/ShopUI.cs index 61a9050..c4e63f9 100644 --- a/Assets/Scripts/ShopUI.cs +++ b/Assets/Scripts/ShopUI.cs @@ -4,6 +4,8 @@ using UnityEngine; public class ShopUI : MonoBehaviour { public Transform itemsParent; public GameObject shopUI; + public bool shopIsOpen; + private Shop _shop; private ShopSlot[] _slots; @@ -14,6 +16,7 @@ public class ShopUI : MonoBehaviour { // Add all ShopSlot GameObjects to _slots and turn off the Shop UI _slots = itemsParent.GetComponentsInChildren(); + shopIsOpen = false; ToggleShop(); // Set the icon to not be a raycast target for the Description Hovering to work @@ -25,6 +28,7 @@ public class ShopUI : MonoBehaviour { private void Update() { // When "Shop" button is pressed turn on/off Shop UI if(Input.GetButtonDown("Shop")) { + shopIsOpen = true; ToggleShop(); } } diff --git a/Assets/ShopSlot.prefab b/Assets/ShopSlot.prefab index cde36d3..d589e1a 100644 --- a/Assets/ShopSlot.prefab +++ b/Assets/ShopSlot.prefab @@ -60,7 +60,7 @@ MonoBehaviour: m_EditorClassIdentifier: m_Material: {fileID: 0} m_Color: {r: 1, g: 1, b: 1, a: 1} - m_RaycastTarget: 1 + m_RaycastTarget: 0 m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0} m_Maskable: 1 m_OnCullStateChanged: @@ -136,7 +136,7 @@ MonoBehaviour: m_EditorClassIdentifier: m_Material: {fileID: 0} m_Color: {r: 1, g: 1, b: 1, a: 1} - m_RaycastTarget: 1 + m_RaycastTarget: 0 m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0} m_Maskable: 1 m_OnCullStateChanged: @@ -271,7 +271,7 @@ MonoBehaviour: m_EditorClassIdentifier: m_Material: {fileID: 0} m_Color: {r: 1, g: 1, b: 1, a: 1} - m_RaycastTarget: 1 + m_RaycastTarget: 0 m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0} m_Maskable: 1 m_OnCullStateChanged: @@ -406,7 +406,7 @@ MonoBehaviour: m_EditorClassIdentifier: m_Material: {fileID: 0} m_Color: {r: 1, g: 1, b: 1, a: 1} - m_RaycastTarget: 1 + m_RaycastTarget: 0 m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0} m_Maskable: 1 m_OnCullStateChanged: @@ -633,11 +633,10 @@ MonoBehaviour: m_Name: m_EditorClassIdentifier: icon: {fileID: 5121261191727116855} - item: {fileID: 0} - nameText: {fileID: 5121261192692990484} - costText: {fileID: 5121261192300927449} amountText: {fileID: 5121261192606669392} timeToWait: 0.5 + nameText: {fileID: 5121261192692990484} + costText: {fileID: 5121261192300927449} --- !u!61 &5121261193055935941 BoxCollider2D: m_ObjectHideFlags: 0