mirror of
https://github.com/smyalygames/monopoly.git
synced 2025-07-04 13:21:01 +02:00
Got the bones of the inventory
This commit is contained in:
parent
b82552fc38
commit
168e2943fc
File diff suppressed because it is too large
Load Diff
@ -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()
|
||||
|
71
Assets/Scripts/monopoly/Inventory.cs
Normal file
71
Assets/Scripts/monopoly/Inventory.cs
Normal 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);
|
||||
}
|
||||
}
|
11
Assets/Scripts/monopoly/Inventory.cs.meta
Normal file
11
Assets/Scripts/monopoly/Inventory.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f0f66671b253015408df057494e40b89
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -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
Loading…
x
Reference in New Issue
Block a user