12 changed files with 189 additions and 9 deletions
@ -0,0 +1,45 @@ |
|||
using System; |
|||
using System.Collections; |
|||
using System.Collections.Generic; |
|||
using TMPro; |
|||
using UnityEngine; |
|||
|
|||
/// <summary>
|
|||
/// This class' only purpose is to set the class of an item view prototype. Could be the item itself, or the infobox, or anything!
|
|||
/// </summary>
|
|||
[RequireComponent(typeof(TextMeshProUGUI))] |
|||
public class InventoryMoneyDisplay : MonoBehaviour,IShopModelObserver<Item> |
|||
{ |
|||
private TextMeshProUGUI text; |
|||
private void Start() |
|||
{ |
|||
text = GetComponent<TextMeshProUGUI>(); // Because of the meta tag, Unity will make sure this exists. No sanity checks
|
|||
} |
|||
|
|||
public void SetMoney(int balance) |
|||
{ |
|||
if(text == null) text = GetComponent<TextMeshProUGUI>(); // Just in case this gets called before Start()
|
|||
text.text = balance.ToString(); |
|||
} |
|||
|
|||
// This is why it's probably better to split this into two interfaces, but oh well
|
|||
public void OnSelected(Item item) |
|||
{ |
|||
//throw new NotImplementedException();
|
|||
} |
|||
|
|||
public void OnRemoved(Item item) |
|||
{ |
|||
//throw new NotImplementedException();
|
|||
} |
|||
|
|||
public void OnAdded(Item item) |
|||
{ |
|||
//throw new NotImplementedException();
|
|||
} |
|||
|
|||
public void OnTransaction(int balance) |
|||
{ |
|||
SetMoney(balance); |
|||
} |
|||
} |
|||
@ -0,0 +1,11 @@ |
|||
fileFormatVersion: 2 |
|||
guid: 1161ecc75d6ee4d44836c2efab2a0fd4 |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|||
Loading…
Reference in new issue