|
|
@ -14,7 +14,7 @@ using TMPro; |
|
|
/// </summary>
|
|
|
/// </summary>
|
|
|
public abstract class ShopView : MonoBehaviour, IShopModelObserver<Item> |
|
|
public abstract class ShopView : MonoBehaviour, IShopModelObserver<Item> |
|
|
{ |
|
|
{ |
|
|
public ShopModel ShopModel => model; //A getter to access shopModel.
|
|
|
public ShopModel ShopModel => model; //A getter to access shopModel. Will access inventory of trade partner in sell mode!
|
|
|
|
|
|
|
|
|
[SerializeField] |
|
|
[SerializeField] |
|
|
protected GameObject itemPrefab; //A prefab to display an item in the view
|
|
|
protected GameObject itemPrefab; //A prefab to display an item in the view
|
|
|
@ -27,6 +27,8 @@ public abstract class ShopView : MonoBehaviour, IShopModelObserver<Item> |
|
|
|
|
|
|
|
|
[SerializeField] protected LayoutGroup layoutGroup; // The layout group that represents this view visually
|
|
|
[SerializeField] protected LayoutGroup layoutGroup; // The layout group that represents this view visually
|
|
|
|
|
|
|
|
|
|
|
|
[SerializeField] private ModelComponent ownModel; // Reference to the model this view technically belongs to
|
|
|
|
|
|
|
|
|
protected ShopModel model; // Model in MVC pattern
|
|
|
protected ShopModel model; // Model in MVC pattern
|
|
|
protected ShopModel other; // Other model in MVC pattern (our own inventory)
|
|
|
protected ShopModel other; // Other model in MVC pattern (our own inventory)
|
|
|
private ShopController shopController; //Controller in MVC pattern
|
|
|
private ShopController shopController; //Controller in MVC pattern
|
|
|
@ -34,7 +36,9 @@ public abstract class ShopView : MonoBehaviour, IShopModelObserver<Item> |
|
|
// Set up the view's necessary stuff before the view is enabled
|
|
|
// Set up the view's necessary stuff before the view is enabled
|
|
|
protected virtual void Awake() |
|
|
protected virtual void Awake() |
|
|
{ |
|
|
{ |
|
|
model = new BuyModel(2f, 16, 500); //Right now use magic values to set up the shop
|
|
|
//model = new BuyModel(2f, 16, 500); //Right now use magic values to set up the shop
|
|
|
|
|
|
Debug.Assert(ownModel != null,"No shop model assigned!",this); |
|
|
|
|
|
model = ownModel.Model; |
|
|
shopController = gameObject.AddComponent<MouseController>().Initialize(model);//Set the default controller to be the mouse controller
|
|
|
shopController = gameObject.AddComponent<MouseController>().Initialize(model);//Set the default controller to be the mouse controller
|
|
|
SetupItemIconView(); //Setup the grid view's properties
|
|
|
SetupItemIconView(); //Setup the grid view's properties
|
|
|
InitializeButtons(); //Connect the buttons to the controller
|
|
|
InitializeButtons(); //Connect the buttons to the controller
|
|
|
|