Got the bones of the inventory

This commit is contained in:
Anthony Berg 2020-08-25 22:20:38 +01:00
parent b82552fc38
commit 168e2943fc
6 changed files with 747 additions and 63 deletions

File diff suppressed because it is too large Load Diff

View File

@ -18,7 +18,7 @@ public class ButtonHandler : MonoBehaviour
public Button inventory;
public TextMeshProUGUI inventoryText;
private bool inventoryOpen = false;
private Inventory inventoryClass;
public void disableRollDice()
{
@ -42,6 +42,7 @@ public class ButtonHandler : MonoBehaviour
void OpenInventory()
{
inventoryClass.OpenInventory();
GameUI.SetActive(false);
PropertyUI.SetActive(true);
inventoryText.text = "Close Inventory";
@ -68,12 +69,12 @@ public class ButtonHandler : MonoBehaviour
}
}
private Main main;
void Awake()
{
main = FindObjectOfType<Main>();
inventoryClass = FindObjectOfType<Inventory>();
}
void Start()

View File

@ -0,0 +1,71 @@
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using TMPro;
public class Inventory : MonoBehaviour
{
private Main main;
//Inventory
public GameObject inventoryPanel;
public Button[] properties; //These are all of the buttons in the inventory corresponding to each unique property.
//Property Panel
public GameObject propertyPanel;
public Button backButton;
public TextMeshProUGUI propertyName;
public Image propertyColour;
public Button buyHouse;
public Button sellHouse;
public Button Mortgage;
//This is the function that will be used when the user clicks to open the inventory.
public void OpenInventory()
{
Player currentPlayer = main.board.players[main.board.currentPlayer]; //Initialises the current player to make the code look neater.
for (int i = 0; i < properties.Length; i++) //Checks through all of the buttons.
{
for (int j = 0; j < currentPlayer.ownedProperties.Count; j++) //Checks through all of the owned properties.
{
if (currentPlayer.ownedProperties[j].property_name == properties[i].name) //Checks if the names of the property is the same as the button name/
{
properties[i].interactable = true; //Makes the button for the property interactable.
break; //Stops the j for loop as the owned properties list is in order.
}
}
}
}
void OpenProperties(Button button)
{
inventoryPanel.SetActive(false);
propertyPanel.SetActive(true);
Debug.Log(button.name);
}
void CloseProperties()
{
propertyPanel.SetActive(false);
inventoryPanel.SetActive(true);
}
private void Awake()
{
main = FindObjectOfType<Main>();
}
private void Start()
{
for (int i = 0; i < properties.Length; i++)
{
properties[i].onClick.AddListener(delegate { OpenProperties(properties[i]); });
}
backButton.onClick.AddListener(CloseProperties);
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: f0f66671b253015408df057494e40b89
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -229,7 +229,7 @@ public class Board //Creating the class for the board mechanics.
public void Mortgage()
{
//TODO
}
}

File diff suppressed because one or more lines are too long