Browse Source

Fix upgrade view not updating price until refresh

master
Devin 4 years ago
parent
commit
d4a2413a9b
  1. 10
      Assets/Scenes/NewShop.unity
  2. 10
      Assets/Scripts/Shop/View/ViewItemContainer.cs
  3. 5
      Assets/Scripts/Shop/View/ViewItemContainerGrid.cs
  4. 5
      Assets/Scripts/Shop/View/ViewItemContainerList.cs

10
Assets/Scenes/NewShop.unity

@ -8546,7 +8546,7 @@ GameObject:
m_Icon: {fileID: 0} m_Icon: {fileID: 0}
m_NavMeshLayer: 0 m_NavMeshLayer: 0
m_StaticEditorFlags: 0 m_StaticEditorFlags: 0
m_IsActive: 0 m_IsActive: 1
--- !u!224 &842666263 --- !u!224 &842666263
RectTransform: RectTransform:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
@ -10426,7 +10426,7 @@ MonoBehaviour:
m_OnCullStateChanged: m_OnCullStateChanged:
m_PersistentCalls: m_PersistentCalls:
m_Calls: [] m_Calls: []
m_text: Sell m_text: Upgrade
m_isRightToLeft: 0 m_isRightToLeft: 0
m_fontAsset: {fileID: 11400000, guid: 8f586378b4e144a9851e7b34d9b748ee, type: 2} m_fontAsset: {fileID: 11400000, guid: 8f586378b4e144a9851e7b34d9b748ee, type: 2}
m_sharedMaterial: {fileID: 2180264, guid: 8f586378b4e144a9851e7b34d9b748ee, type: 2} m_sharedMaterial: {fileID: 2180264, guid: 8f586378b4e144a9851e7b34d9b748ee, type: 2}
@ -10495,7 +10495,7 @@ MonoBehaviour:
m_margin: {x: 0, y: 0, z: 0, w: 0} m_margin: {x: 0, y: 0, z: 0, w: 0}
m_textInfo: m_textInfo:
textComponent: {fileID: 970726939} textComponent: {fileID: 970726939}
characterCount: 3 characterCount: 4
spriteCount: 0 spriteCount: 0
spaceCount: 0 spaceCount: 0
wordCount: 1 wordCount: 1
@ -15726,7 +15726,7 @@ GameObject:
m_Icon: {fileID: 0} m_Icon: {fileID: 0}
m_NavMeshLayer: 0 m_NavMeshLayer: 0
m_StaticEditorFlags: 0 m_StaticEditorFlags: 0
m_IsActive: 1 m_IsActive: 0
--- !u!224 &1396837741 --- !u!224 &1396837741
RectTransform: RectTransform:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
@ -16571,7 +16571,7 @@ MonoBehaviour:
m_OnCullStateChanged: m_OnCullStateChanged:
m_PersistentCalls: m_PersistentCalls:
m_Calls: [] m_Calls: []
m_text: Sell m_text: Upgrade
m_isRightToLeft: 0 m_isRightToLeft: 0
m_fontAsset: {fileID: 11400000, guid: 8f586378b4e144a9851e7b34d9b748ee, type: 2} m_fontAsset: {fileID: 11400000, guid: 8f586378b4e144a9851e7b34d9b748ee, type: 2}
m_sharedMaterial: {fileID: 2180264, guid: 8f586378b4e144a9851e7b34d9b748ee, type: 2} m_sharedMaterial: {fileID: 2180264, guid: 8f586378b4e144a9851e7b34d9b748ee, type: 2}

10
Assets/Scripts/Shop/View/ViewItemContainer.cs

@ -63,26 +63,26 @@ public abstract class ViewItemContainer : MonoBehaviour, IItemContainer, IShopMo
protected abstract void OnInitialize(Item item, ShopModel owner = null); protected abstract void OnInitialize(Item item, ShopModel owner = null);
// When the observable fires, check if we're the view corresponding to the selected item. Select if we are! // When the observable fires, check if we're the view corresponding to the selected item. Select if we are!
public void OnSelected(Item item) public virtual void OnSelected(Item item)
{ {
IsSelected = this.item == item; IsSelected = this.item == item;
} }
public void OnRemoved(Item item) public virtual void OnRemoved(Item item)
{ {
if (item != Item) return; // Well we only want this if the item removed from the model is actually ours! if (item != Item) return; // Well we only want this if the item removed from the model is actually ours!
IsSelected = false; // Kind of pointless, but won't hurt IsSelected = false; // Kind of pointless, but won't hurt
Destroy(gameObject); Destroy(gameObject);
} }
public void OnAdded(Item item) public virtual void OnAdded(Item item)
{ {
throw new NotImplementedException(); throw new NotImplementedException();
} }
public void OnTransaction(int cost) public virtual void OnTransaction(int cost)
{ {
//throw new NotImplementedException(); Irrelevant for the view containers
} }
// The reason we do this in OnDestroy() is so we don't have a memory leak when this gets removed externally somehow // The reason we do this in OnDestroy() is so we don't have a memory leak when this gets removed externally somehow

5
Assets/Scripts/Shop/View/ViewItemContainerGrid.cs

@ -25,4 +25,9 @@ public class ViewItemContainerGrid : ViewItemContainer
{ {
infoPanel.SetItemInfo(item, owner); // Grid info comes with a panel, so we set its info just once infoPanel.SetItemInfo(item, owner); // Grid info comes with a panel, so we set its info just once
} }
public override void OnTransaction(int balance)
{
infoPanel.Refresh();
}
} }

5
Assets/Scripts/Shop/View/ViewItemContainerList.cs

@ -25,4 +25,9 @@ public class ViewItemContainerList : ViewItemContainer
itemInfo = GetComponent<ViewItemInfoPanel>(); itemInfo = GetComponent<ViewItemInfoPanel>();
itemInfo?.SetItemInfo(item,owner); itemInfo?.SetItemInfo(item,owner);
} }
public override void OnTransaction(int balance)
{
itemInfo.Refresh();
}
} }

Loading…
Cancel
Save