mirror of
https://github.com/smyalygames/monopoly.git
synced 2025-05-18 06:14:10 +02:00
Added the inventory UI
The inventory is not yet functional
This commit is contained in:
parent
6775b97073
commit
f65ff7e1f6
File diff suppressed because it is too large
Load Diff
@ -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();
|
||||
}
|
||||
}
|
||||
|
@ -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,7 +301,7 @@ 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.
|
||||
@ -306,11 +311,15 @@ public class Player
|
||||
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);
|
||||
|
||||
}
|
||||
|
||||
|
@ -1,2 +1,2 @@
|
||||
m_EditorVersion: 2020.1.2f1
|
||||
m_EditorVersionWithRevision: 2020.1.2f1 (7b32bc54ba47)
|
||||
m_EditorVersion: 2020.1.3f1
|
||||
m_EditorVersionWithRevision: 2020.1.3f1 (cf5c4788e1d8)
|
||||
|
@ -5,6 +5,9 @@ EditorUserSettings:
|
||||
m_ObjectHideFlags: 0
|
||||
serializedVersion: 4
|
||||
m_ConfigSettings:
|
||||
lightmappingDeviceAndPlatform:
|
||||
value: 53
|
||||
flags: 0
|
||||
vcSharedLogLevel:
|
||||
value: 0d5e400f0650
|
||||
flags: 0
|
||||
|
Loading…
x
Reference in New Issue
Block a user