Merge branch 'develop' into dhain
# Conflicts: # Assets/Scripts/ShopSlot.cs
This commit is contained in:
commit
6959240afe
4 changed files with 824 additions and 13 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,15 +22,19 @@ 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;
|
||||
moneyTextMeshProUGUI.text = _money + "µ";
|
||||
}
|
||||
|
||||
public void SetSelectedItem(UsableItem item) {
|
||||
|
|
@ -44,4 +49,9 @@ public class PlayerController : MonoBehaviour {
|
|||
public UsableItem GetSelectedItem() {
|
||||
return _selectedItem;
|
||||
}
|
||||
|
||||
public void ChangeMoney(int amount) {
|
||||
_money += amount;
|
||||
moneyTextMeshProUGUI.text = _money + "µ";
|
||||
}
|
||||
}
|
||||
|
|
@ -32,14 +32,14 @@ public class ShopSlot : ItemStorageSlot {
|
|||
/**
|
||||
* Gets called when the Shop Slot is clicked
|
||||
*/
|
||||
public override void UseItem() {
|
||||
if(_playerController.money >= Item.cost) {
|
||||
_inventory.AddItem(Item, 1);
|
||||
_shop.RemoveItem(Item, 1);
|
||||
_playerController.money -= Item.cost;
|
||||
public void UseItem() {
|
||||
if(_playerController.Money >= item.cost) {
|
||||
_inventory.AddItem(item, 1);
|
||||
_shop.RemoveItem(item, 1);
|
||||
_playerController.ChangeMoney(-item.cost);
|
||||
|
||||
Debug.Log("Buying Item: " + Item.displayName);
|
||||
Debug.Log("money left: " + _playerController.money);
|
||||
Debug.Log("Buying Item: " + item.displayName);
|
||||
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