Merge branch 'dhain' into develop

# Conflicts:
#	Assets/Farming Asset Pack/Split Assets.meta
#	Assets/Scenes/MainScene.unity
This commit is contained in:
dhain 2022-06-03 09:31:35 +02:00
commit ccb25d4335
10 changed files with 40 additions and 27 deletions

View file

@ -1638,8 +1638,8 @@ MonoBehaviour:
m_TargetGraphic: {fileID: 2006577139} m_TargetGraphic: {fileID: 2006577139}
m_HandleRect: {fileID: 2006577138} m_HandleRect: {fileID: 2006577138}
m_Direction: 2 m_Direction: 2
m_Value: 0.9999998 m_Value: 1
m_Size: 0.59324205 m_Size: 0.5932421
m_NumberOfSteps: 0 m_NumberOfSteps: 0
m_OnValueChanged: m_OnValueChanged:
m_PersistentCalls: m_PersistentCalls:
@ -4906,7 +4906,7 @@ MonoBehaviour:
m_Name: m_Name:
m_EditorClassIdentifier: m_EditorClassIdentifier:
menu: {fileID: 1395531174} menu: {fileID: 1395531174}
dayCountTextMeshProUGUI: {fileID: 1089918735} dayCountTextMeshProUGUI: {fileID: 0}
--- !u!212 &1278234715 --- !u!212 &1278234715
SpriteRenderer: SpriteRenderer:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
@ -4967,7 +4967,7 @@ Transform:
m_PrefabAsset: {fileID: 0} m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1278234712} m_GameObject: {fileID: 1278234712}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} 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_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0 m_ConstrainProportionsScale: 0
m_Children: m_Children:
@ -4996,7 +4996,7 @@ GameObject:
m_Icon: {fileID: 0} m_Icon: {fileID: 0}
m_NavMeshLayer: 0 m_NavMeshLayer: 0
m_StaticEditorFlags: 0 m_StaticEditorFlags: 0
m_IsActive: 1 m_IsActive: 0
--- !u!114 &1291863650 --- !u!114 &1291863650
MonoBehaviour: MonoBehaviour:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
@ -6888,7 +6888,6 @@ MonoBehaviour:
startItems: startItems:
- {fileID: 11400000, guid: 008a8fdd2c3a95745acafee4087a855d, type: 2} - {fileID: 11400000, guid: 008a8fdd2c3a95745acafee4087a855d, type: 2}
- {fileID: 11400000, guid: 430db451ae959f34b8fba8d8b17276fd, type: 2} - {fileID: 11400000, guid: 430db451ae959f34b8fba8d8b17276fd, type: 2}
- {fileID: 11400000, guid: ea1a26b19bc34a0ba29bad77253c7266, type: 2}
--- !u!114 &1800469992 --- !u!114 &1800469992
MonoBehaviour: MonoBehaviour:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
@ -6906,7 +6905,6 @@ MonoBehaviour:
- {fileID: 11400000, guid: d651d57ba97a4246a0094409e29fe56a, type: 2} - {fileID: 11400000, guid: d651d57ba97a4246a0094409e29fe56a, type: 2}
- {fileID: 11400000, guid: 430db451ae959f34b8fba8d8b17276fd, type: 2} - {fileID: 11400000, guid: 430db451ae959f34b8fba8d8b17276fd, type: 2}
- {fileID: 11400000, guid: 008a8fdd2c3a95745acafee4087a855d, type: 2} - {fileID: 11400000, guid: 008a8fdd2c3a95745acafee4087a855d, type: 2}
- {fileID: 11400000, guid: ea1a26b19bc34a0ba29bad77253c7266, type: 2}
--- !u!1001 &1805366398 --- !u!1001 &1805366398
PrefabInstance: PrefabInstance:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0

View file

@ -6,16 +6,16 @@ public class HoverManager : MonoBehaviour {
public TextMeshProUGUI descriptionText; public TextMeshProUGUI descriptionText;
public RectTransform descriptionHoverBackground; public RectTransform descriptionHoverBackground;
public static Action<string, Vector2> onMouseHover; public static Action<string, Vector2> onMouseHoverDescription;
public static Action onMouseExit; public static Action onMouseExit;
private void OnEnable() { private void OnEnable() {
onMouseHover += ShowDescription; onMouseHoverDescription += ShowDescription;
onMouseExit += HideDescription; onMouseExit += HideDescription;
} }
private void OnDisable() { private void OnDisable() {
onMouseHover -= ShowDescription; onMouseHoverDescription -= ShowDescription;
onMouseExit -= HideDescription; onMouseExit -= HideDescription;
} }

View file

@ -15,13 +15,13 @@ public class Inventory : ItemStorage {
#endregion #endregion
public const int InventorySpace = 28; private const int _InventorySpace = 28;
/** /**
* Adds the specified amount of items to the Inventory * Adds the specified amount of items to the Inventory
*/ */
public override void AddItem(Item item, int amount) { public override void AddItem(Item item, int amount) {
if(items.Count >= InventorySpace) { if(items.Count >= _InventorySpace) {
Debug.Log("Not enough inventory space!"); Debug.Log("Not enough inventory space!");
return; return;
} }

View file

@ -35,7 +35,7 @@ public class InventoryUI : MonoBehaviour {
private void ToggleInventory() { private void ToggleInventory() {
inventoryUI.SetActive(!inventoryUI.activeSelf); 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 * Is called when something in the Inventory UI should update
*/ */

View file

@ -35,7 +35,7 @@ public class ItemStorage : MonoBehaviour {
* Removes the specified amount of items in the Item Storage * Removes the specified amount of items in the Item Storage
*/ */
public void RemoveItem(Item item, int amount) { public void RemoveItem(Item item, int amount) {
if(items[item] <= 0) { if(items[item]-amount <= 0) {
items.Remove(item); items.Remove(item);
} else { } else {
items[item] -= amount; items[item] -= amount;

View file

@ -13,23 +13,36 @@ public class ItemStorageSlot : MonoBehaviour, IPointerEnterHandler, IPointerExit
private Item _item; private Item _item;
#region DescriptionHover #region HoverOverItem
public float timeToWait; public float timeToWait;
public void OnPointerEnter(PointerEventData eventData) { public void OnPointerEnter(PointerEventData eventData) {
StopAllCoroutines(); StopAllCoroutines();
StartCoroutine(StartTimer()); StartCoroutine(StartTimer());
ChangeItemSelectedSprite(true);
} }
public void OnPointerExit(PointerEventData eventData) { public void OnPointerExit(PointerEventData eventData) {
StopAllCoroutines(); StopAllCoroutines();
ChangeItemSelectedSprite(false);
HoverManager.onMouseExit(); HoverManager.onMouseExit();
} }
private void ShowMessage() { private void ShowMessage() {
if(_item){ 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;
}
} }
} }

View file

@ -1,4 +1,3 @@
using System.Collections.Generic;
using UnityEngine; using UnityEngine;
public class Shop : ItemStorage { public class Shop : ItemStorage {

View file

@ -19,10 +19,11 @@ public class ShopSlot : ItemStorageSlot {
* Clears the Shop Slot * Clears the Shop Slot
*/ */
public override void ClearSlot() { public override void ClearSlot() {
base.ClearSlot();
nameText.text = ""; nameText.text = "";
costText.text = ""; costText.text = "";
amountText.text = ""; amountText.text = "";
// _shop.RemoveItem(Item, 1);
base.ClearSlot();
} }
/** /**
@ -35,7 +36,6 @@ public class ShopSlot : ItemStorageSlot {
_playerController.ChangeMoney(-Item.cost); _playerController.ChangeMoney(-Item.cost);
Debug.Log("Buying Item: " + Item.displayName); Debug.Log("Buying Item: " + Item.displayName);
Debug.Log("money left: " + _playerController.Money);
} else { } else {
Debug.Log("Not enough money to buy item."); Debug.Log("Not enough money to buy item.");
} }

View file

@ -4,6 +4,8 @@ using UnityEngine;
public class ShopUI : MonoBehaviour { public class ShopUI : MonoBehaviour {
public Transform itemsParent; public Transform itemsParent;
public GameObject shopUI; public GameObject shopUI;
public bool shopIsOpen;
private Shop _shop; private Shop _shop;
private ShopSlot[] _slots; private ShopSlot[] _slots;
@ -14,6 +16,7 @@ public class ShopUI : MonoBehaviour {
// Add all ShopSlot GameObjects to _slots and turn off the Shop UI // Add all ShopSlot GameObjects to _slots and turn off the Shop UI
_slots = itemsParent.GetComponentsInChildren<ShopSlot>(); _slots = itemsParent.GetComponentsInChildren<ShopSlot>();
shopIsOpen = false;
ToggleShop(); ToggleShop();
// Set the icon to not be a raycast target for the Description Hovering to work // 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() { private void Update() {
// When "Shop" button is pressed turn on/off Shop UI // When "Shop" button is pressed turn on/off Shop UI
if(Input.GetButtonDown("Shop")) { if(Input.GetButtonDown("Shop")) {
shopIsOpen = true;
ToggleShop(); ToggleShop();
} }
} }

View file

@ -60,7 +60,7 @@ MonoBehaviour:
m_EditorClassIdentifier: m_EditorClassIdentifier:
m_Material: {fileID: 0} m_Material: {fileID: 0}
m_Color: {r: 1, g: 1, b: 1, a: 1} 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_RaycastPadding: {x: 0, y: 0, z: 0, w: 0}
m_Maskable: 1 m_Maskable: 1
m_OnCullStateChanged: m_OnCullStateChanged:
@ -136,7 +136,7 @@ MonoBehaviour:
m_EditorClassIdentifier: m_EditorClassIdentifier:
m_Material: {fileID: 0} m_Material: {fileID: 0}
m_Color: {r: 1, g: 1, b: 1, a: 1} 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_RaycastPadding: {x: 0, y: 0, z: 0, w: 0}
m_Maskable: 1 m_Maskable: 1
m_OnCullStateChanged: m_OnCullStateChanged:
@ -271,7 +271,7 @@ MonoBehaviour:
m_EditorClassIdentifier: m_EditorClassIdentifier:
m_Material: {fileID: 0} m_Material: {fileID: 0}
m_Color: {r: 1, g: 1, b: 1, a: 1} 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_RaycastPadding: {x: 0, y: 0, z: 0, w: 0}
m_Maskable: 1 m_Maskable: 1
m_OnCullStateChanged: m_OnCullStateChanged:
@ -406,7 +406,7 @@ MonoBehaviour:
m_EditorClassIdentifier: m_EditorClassIdentifier:
m_Material: {fileID: 0} m_Material: {fileID: 0}
m_Color: {r: 1, g: 1, b: 1, a: 1} 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_RaycastPadding: {x: 0, y: 0, z: 0, w: 0}
m_Maskable: 1 m_Maskable: 1
m_OnCullStateChanged: m_OnCullStateChanged:
@ -633,11 +633,10 @@ MonoBehaviour:
m_Name: m_Name:
m_EditorClassIdentifier: m_EditorClassIdentifier:
icon: {fileID: 5121261191727116855} icon: {fileID: 5121261191727116855}
item: {fileID: 0}
nameText: {fileID: 5121261192692990484}
costText: {fileID: 5121261192300927449}
amountText: {fileID: 5121261192606669392} amountText: {fileID: 5121261192606669392}
timeToWait: 0.5 timeToWait: 0.5
nameText: {fileID: 5121261192692990484}
costText: {fileID: 5121261192300927449}
--- !u!61 &5121261193055935941 --- !u!61 &5121261193055935941
BoxCollider2D: BoxCollider2D:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0