shop updated
This commit is contained in:
parent
8211a11c2c
commit
7ccf683005
3 changed files with 21 additions and 12 deletions
|
|
@ -1535,7 +1535,7 @@ MonoBehaviour:
|
|||
m_TargetGraphic: {fileID: 2006577139}
|
||||
m_HandleRect: {fileID: 2006577138}
|
||||
m_Direction: 2
|
||||
m_Value: 0.9999998
|
||||
m_Value: 1
|
||||
m_Size: 0.59324205
|
||||
m_NumberOfSteps: 0
|
||||
m_OnValueChanged:
|
||||
|
|
@ -6320,6 +6320,8 @@ MonoBehaviour:
|
|||
m_EditorClassIdentifier:
|
||||
itemsParent: {fileID: 610140154}
|
||||
shopUI: {fileID: 1671356616}
|
||||
shopIsOpen: 0
|
||||
inventoryUI: {fileID: 1609015285}
|
||||
--- !u!224 &1551890462 stripped
|
||||
RectTransform:
|
||||
m_CorrespondingSourceObject: {fileID: 3510585822996971025, guid: 44dae5fbdb6f7df4f93a10807f66956f, type: 3}
|
||||
|
|
@ -6509,7 +6511,11 @@ MonoBehaviour:
|
|||
m_Script: {fileID: 11500000, guid: bc5eb8967b8912c42b93a2086383ddd9, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
startItems: []
|
||||
startItems:
|
||||
- {fileID: 11400000, guid: bb9777a7d5804bd6bf25d5510206aaf0, type: 2}
|
||||
- {fileID: 11400000, guid: bb9777a7d5804bd6bf25d5510206aaf0, type: 2}
|
||||
- {fileID: 11400000, guid: bb9777a7d5804bd6bf25d5510206aaf0, type: 2}
|
||||
- {fileID: 11400000, guid: 008a8fdd2c3a95745acafee4087a855d, type: 2}
|
||||
--- !u!1001 &1701153146
|
||||
PrefabInstance:
|
||||
m_ObjectHideFlags: 0
|
||||
|
|
@ -6752,7 +6758,7 @@ MonoBehaviour:
|
|||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
startMoney: 10000
|
||||
moneyTextMeshProUGUI: {fileID: 0}
|
||||
moneyTextMeshProUGUI: {fileID: 1347709342}
|
||||
--- !u!4 &1800469990
|
||||
Transform:
|
||||
m_ObjectHideFlags: 0
|
||||
|
|
|
|||
|
|
@ -5,29 +5,30 @@ public class ShopUI : MonoBehaviour {
|
|||
public Transform itemsParent;
|
||||
public GameObject shopUI;
|
||||
public bool shopIsOpen;
|
||||
|
||||
public GameObject inventoryUI;
|
||||
|
||||
private Shop _shop;
|
||||
private ShopSlot[] _slots;
|
||||
|
||||
|
||||
private void Start() {
|
||||
// Get Shop instance and add UpdateUI method to OnItemChanged delegate
|
||||
_shop = Shop.instance;
|
||||
_shop.onItemChangedCallback += UpdateUI;
|
||||
|
||||
|
||||
// Add all ShopSlot GameObjects to _slots and turn off the Shop UI
|
||||
_slots = itemsParent.GetComponentsInChildren<ShopSlot>();
|
||||
shopIsOpen = false;
|
||||
ToggleShop();
|
||||
|
||||
// Set the icon to not be a raycast target for the Description Hovering to work
|
||||
foreach(ShopSlot slot in _slots) {
|
||||
foreach (ShopSlot slot in _slots) {
|
||||
slot.icon.raycastTarget = false;
|
||||
}
|
||||
}
|
||||
|
||||
private void Update() {
|
||||
// When "Shop" button is pressed turn on/off Shop UI
|
||||
if(Input.GetButtonDown("Shop")) {
|
||||
if (Input.GetButtonDown("Shop")) {
|
||||
shopIsOpen = true;
|
||||
ToggleShop();
|
||||
}
|
||||
|
|
@ -37,6 +38,7 @@ public class ShopUI : MonoBehaviour {
|
|||
* Turn on/off the Shop UI
|
||||
*/
|
||||
private void ToggleShop() {
|
||||
inventoryUI.gameObject.SetActive(!shopUI.activeSelf);
|
||||
shopUI.SetActive(!shopUI.activeSelf);
|
||||
}
|
||||
|
||||
|
|
@ -45,13 +47,14 @@ public class ShopUI : MonoBehaviour {
|
|||
*/
|
||||
private void UpdateUI() {
|
||||
// Add all items to the correct slots and clear the ones where no item should be
|
||||
for(int i = 0; i < _slots.Length; i++) {
|
||||
if(i < _shop.items.Count) {
|
||||
for (int i = 0; i < _slots.Length; i++) {
|
||||
if (i < _shop.items.Count) {
|
||||
_slots[i].AddItem(_shop.items.ElementAt(i).Key);
|
||||
_slots[i].nameText.text = _slots[i].Item.displayName;
|
||||
_slots[i].costText.text = _slots[i].Item.cost + " µ";
|
||||
_slots[i].amountText.text = _shop.items[_shop.items.ElementAt(i).Key] + " #";
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
_slots[i].ClearSlot();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ namespace Tiles
|
|||
{
|
||||
public class GrassTile : BaseTile
|
||||
{
|
||||
public GrassTile() : base("C:/Users/maile/UnityProjects/2122_3AHITN_Scrum_sprechtl_jweissen_dhain/Assets/Farming Asset Pack/Split Assets/farming_tileset_000.png")
|
||||
public GrassTile() : base("Assets/Farming Asset Pack/Split Assets/farming_tileset_000.png")
|
||||
{
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue