Added the inventory UI

The inventory is not yet functional
This commit is contained in:
Anthony Berg
2020-08-24 21:32:55 +01:00
parent 6775b97073
commit f65ff7e1f6
5 changed files with 5320 additions and 129 deletions

View File

@@ -3,14 +3,23 @@ using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using TMPro;
public class ButtonHandler : MonoBehaviour
{
public GameObject GameUI;
public Button rollDice;
public GameObject buyButton;
public Button buyButtonButton;
//Inventory
public GameObject PropertyUI;
public Button inventory;
public TextMeshProUGUI inventoryText;
private bool inventoryOpen = false;
public void disableRollDice()
{
rollDice.interactable = false;
@@ -31,6 +40,34 @@ public class ButtonHandler : MonoBehaviour
buyButton.SetActive(true);
}
void OpenInventory()
{
GameUI.SetActive(false);
PropertyUI.SetActive(true);
inventoryText.text = "Close Inventory";
}
void CloseInventory()
{
GameUI.SetActive(true);
PropertyUI.SetActive(false);
inventoryText.text = "Open Inventory";
}
void ToggleInventory()
{
if (!inventoryOpen)
{
OpenInventory();
inventoryOpen = true;
}
else
{
CloseInventory();
inventoryOpen = false;
}
}
private Main main;
@@ -41,10 +78,11 @@ public class ButtonHandler : MonoBehaviour
void Start()
{
buyButtonButton.onClick.AddListener(TaskOnClick);
buyButtonButton.onClick.AddListener(BuyPropertyClick);
inventory.onClick.AddListener(ToggleInventory);
}
void TaskOnClick() {
void BuyPropertyClick() {
main.board.BuyProperty();
}
}

View File

@@ -219,6 +219,11 @@ public class Board //Creating the class for the board mechanics.
Debug.Log("The property cannot be bought!"); //Prints that theres an error
}
public void Mortgage()
{
}
}
public class Player
@@ -296,22 +301,26 @@ public class Player
public void CheckColourSet(string colour) //Checks if the player has a whole colour set.
public bool CheckColourSet(string colour) //Checks if the player has a whole colour set.
{
int required = 3; //This is the number of properties needed to own to buy houses.
int counter = 0; //This checks how many times the property is found.
if (colour == "brown" || colour == "dark blue") //Only brown and dark blue has 2 properties.
{
required = 2;
}
for (int i = 0; i < ownedProperties.Count; i++)
for (int i = 0; i < ownedProperties.Count && counter != required; i++)
{
//TODO Use the merge sort to make the for loop more efficient.
if (ownedProperties[i].property_group == colour)
{
counter++;
}
}
return (counter == required);
}
public void Pay(int fee)