money and daycount ui added
This commit is contained in:
parent
d28a1947eb
commit
9e082537d8
4 changed files with 819 additions and 9 deletions
|
|
@ -1,15 +1,17 @@
|
|||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Events;
|
||||
|
||||
public class HouseController : MonoBehaviour {
|
||||
private int dayCount = 0;
|
||||
private int dayCount = 1;
|
||||
private static UnityEvent newDayEvent;
|
||||
public static UnityEvent NewDayEvent => newDayEvent;
|
||||
|
||||
public Canvas menu;
|
||||
public TextMeshProUGUI dayCountTextMeshProUGUI;
|
||||
|
||||
private void OnMouseDown() {
|
||||
toggleMenu();
|
||||
|
|
@ -21,7 +23,7 @@ public class HouseController : MonoBehaviour {
|
|||
|
||||
public void newDay() {
|
||||
dayCount++;
|
||||
Debug.Log("New day: " + dayCount);
|
||||
dayCountTextMeshProUGUI.text = dayCount.ToString();
|
||||
newDayEvent?.Invoke();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UIElements;
|
||||
using Cursor = UnityEngine.Cursor;
|
||||
|
|
@ -21,14 +22,17 @@ public class PlayerController : MonoBehaviour {
|
|||
#endregion
|
||||
|
||||
private Inventory _inventory;
|
||||
public int money;
|
||||
private int _money;
|
||||
private UsableItem _selectedItem;
|
||||
|
||||
public int startMoney = 100;
|
||||
public TextMeshProUGUI moneyTextMeshProUGUI;
|
||||
|
||||
public int Money => _money;
|
||||
|
||||
// Start is called before the first frame update
|
||||
private void Start() {
|
||||
money = startMoney;
|
||||
_money = startMoney;
|
||||
_inventory = Inventory.instance;
|
||||
}
|
||||
|
||||
|
|
@ -44,4 +48,9 @@ public class PlayerController : MonoBehaviour {
|
|||
public UsableItem GetSelectedItem() {
|
||||
return _selectedItem;
|
||||
}
|
||||
|
||||
public void ChangeMoney(int amount) {
|
||||
_money += amount;
|
||||
moneyTextMeshProUGUI.text = amount + "µ";
|
||||
}
|
||||
}
|
||||
|
|
@ -76,13 +76,13 @@ public class ShopSlot : MonoBehaviour, IPointerEnterHandler, IPointerExitHandler
|
|||
* Gets called when the Shop Slot is clicked
|
||||
*/
|
||||
public void UseItem() {
|
||||
if(_playerController.money >= item.cost) {
|
||||
if(_playerController.Money >= item.cost) {
|
||||
_inventory.AddItem(item, 1);
|
||||
_shop.RemoveItem(item, 1);
|
||||
_playerController.money -= item.cost;
|
||||
_playerController.ChangeMoney(-item.cost);
|
||||
|
||||
Debug.Log("Buying Item: " + item.displayName);
|
||||
Debug.Log("money left: " + _playerController.money);
|
||||
Debug.Log("money left: " + _playerController.Money);
|
||||
} else {
|
||||
Debug.Log("Not enough money to buy item.");
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue