diff --git a/Assets/Scenes/NewShop.unity b/Assets/Scenes/NewShop.unity index a8b3b9d..9775ed8 100644 --- a/Assets/Scenes/NewShop.unity +++ b/Assets/Scenes/NewShop.unity @@ -3601,7 +3601,7 @@ MonoBehaviour: instructionText: {fileID: 360948192} layoutGroup: {fileID: 2049417198} ownModel: {fileID: 1237921498} - tradePartner: {fileID: 1237921497} + tradePartner: {fileID: 132445008} --- !u!114 &336428457 MonoBehaviour: m_ObjectHideFlags: 0 @@ -4837,6 +4837,7 @@ GameObject: - component: {fileID: 407729278} - component: {fileID: 407729280} - component: {fileID: 407729279} + - component: {fileID: 407729281} m_Layer: 5 m_Name: Number m_TagString: Untagged @@ -4984,6 +4985,18 @@ CanvasRenderer: m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 407729277} m_CullTransparentMesh: 0 +--- !u!114 &407729281 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 407729277} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 1161ecc75d6ee4d44836c2efab2a0fd4, type: 3} + m_Name: + m_EditorClassIdentifier: --- !u!1 &439186015 GameObject: m_ObjectHideFlags: 0 @@ -7272,6 +7285,7 @@ GameObject: - component: {fileID: 741829285} - component: {fileID: 741829287} - component: {fileID: 741829286} + - component: {fileID: 741829288} m_Layer: 5 m_Name: Number m_TagString: Untagged @@ -7419,6 +7433,18 @@ CanvasRenderer: m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 741829284} m_CullTransparentMesh: 0 +--- !u!114 &741829288 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 741829284} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 1161ecc75d6ee4d44836c2efab2a0fd4, type: 3} + m_Name: + m_EditorClassIdentifier: --- !u!1 &751126171 GameObject: m_ObjectHideFlags: 0 @@ -9726,6 +9752,7 @@ GameObject: - component: {fileID: 921117985} - component: {fileID: 921117987} - component: {fileID: 921117986} + - component: {fileID: 921117988} m_Layer: 5 m_Name: Number m_TagString: Untagged @@ -9873,6 +9900,18 @@ CanvasRenderer: m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 921117984} m_CullTransparentMesh: 0 +--- !u!114 &921117988 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 921117984} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 1161ecc75d6ee4d44836c2efab2a0fd4, type: 3} + m_Name: + m_EditorClassIdentifier: --- !u!1 &927674263 GameObject: m_ObjectHideFlags: 0 @@ -10169,6 +10208,7 @@ GameObject: - component: {fileID: 969238773} - component: {fileID: 969238775} - component: {fileID: 969238774} + - component: {fileID: 969238776} m_Layer: 5 m_Name: Number m_TagString: Untagged @@ -10316,6 +10356,18 @@ CanvasRenderer: m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 969238772} m_CullTransparentMesh: 0 +--- !u!114 &969238776 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 969238772} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 1161ecc75d6ee4d44836c2efab2a0fd4, type: 3} + m_Name: + m_EditorClassIdentifier: --- !u!1 &970726937 GameObject: m_ObjectHideFlags: 0 @@ -15496,6 +15548,7 @@ GameObject: - component: {fileID: 1393813460} - component: {fileID: 1393813462} - component: {fileID: 1393813461} + - component: {fileID: 1393813463} m_Layer: 5 m_Name: Number m_TagString: Untagged @@ -15643,6 +15696,18 @@ CanvasRenderer: m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 1393813459} m_CullTransparentMesh: 0 +--- !u!114 &1393813463 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1393813459} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 1161ecc75d6ee4d44836c2efab2a0fd4, type: 3} + m_Name: + m_EditorClassIdentifier: --- !u!1 &1396837740 GameObject: m_ObjectHideFlags: 0 diff --git a/Assets/Scripts/Shop/View/ShopView.cs b/Assets/Scripts/Shop/View/ShopView.cs index 1ea634f..917ad54 100644 --- a/Assets/Scripts/Shop/View/ShopView.cs +++ b/Assets/Scripts/Shop/View/ShopView.cs @@ -62,7 +62,7 @@ public abstract class ShopView : MonoBehaviour private void OnDisable() { ClearIconView(); - model.SetTradePartner(null); + //model.SetTradePartner(null); UnregisterMoneyObserver(); } diff --git a/Assets/Scripts/Shop/View/ShopViewGrid.cs b/Assets/Scripts/Shop/View/ShopViewGrid.cs index 6e0b15f..3776890 100644 --- a/Assets/Scripts/Shop/View/ShopViewGrid.cs +++ b/Assets/Scripts/Shop/View/ShopViewGrid.cs @@ -6,7 +6,7 @@ using UnityEngine; using UnityEngine.Assertions; using UnityEngine.UI; -public class ShopViewGrid : ShopView +public class ShopViewGrid : ShopView, IShopModelObserver { private GridLayoutGroup _gridLayoutGroup; // This is essentially just a reference to ShopView's layout group but with the correct type @@ -21,6 +21,7 @@ public class ShopViewGrid : ShopView Debug.Assert(viewConfig != null); Debug.Assert(_gridLayoutGroup != null); base.Awake(); + model.RegisterObserver(this); print("ShopView Grid Initialised"); } @@ -99,4 +100,25 @@ public class ShopViewGrid : ShopView if(!correctLayout) Debug.LogError("Layout group is not of type Grid!",this); //else Debug.Log("Grid shop view validated",this); } + + public void OnSelected(Item item) + { + //throw new NotImplementedException(); + } + + public void OnRemoved(Item item) + { + // Only need this one for the keyboard view mostly + shopController.RemoveSelectableItem(item); + } + + public void OnAdded(Item item) + { + + } + + public void OnTransaction(int balance) + { + + } } diff --git a/Assets/Scripts/Shop/View/ShopViewList.cs b/Assets/Scripts/Shop/View/ShopViewList.cs index b0df3e7..c1a7c6a 100644 --- a/Assets/Scripts/Shop/View/ShopViewList.cs +++ b/Assets/Scripts/Shop/View/ShopViewList.cs @@ -60,6 +60,7 @@ public class ShopViewList : ShopView, IShopModelObserver //bool isSelected = (item == model.GetSelectedItem()); var unsub = model.RegisterObserver(itemContainer); itemContainer.Initialize(item,model,unsub); + shopController.AddSelectableItem(item); //print("Attempt to add item " + item.name + " to view"); } @@ -70,6 +71,7 @@ public class ShopViewList : ShopView, IShopModelObserver { if (itemView.Item == item) { + shopController.RemoveSelectableItem(item); model.RemoveObserver(itemView); Destroy(itemView.gameObject); return; @@ -111,6 +113,7 @@ public class ShopViewList : ShopView, IShopModelObserver public void OnRemoved(Item item) { infoPanel?.SetItemInfo(null); // This should set the item info to nothing, effectively disabling it + shopController.RemoveSelectableItem(item); } public void OnAdded(Item item)