Browse Source

Refactor inventory to be in a unity component for shared inventory

master
Devin 4 years ago
parent
commit
70b217daef
  1. 8
      Assets/Resources/Inventories.meta
  2. 16
      Assets/Resources/Inventories/PlayerInventory.asset
  3. 8
      Assets/Resources/Inventories/PlayerInventory.asset.meta
  4. 16
      Assets/Resources/Inventories/ShopInventory.asset
  5. 8
      Assets/Resources/Inventories/ShopInventory.asset.meta
  6. 29
      Assets/Scenes/NewShop.unity
  7. 18
      Assets/Scripts/Shop/Components/InventoryComponent.cs
  8. 11
      Assets/Scripts/Shop/Components/InventoryComponent.cs.meta
  9. 2
      Assets/Scripts/Shop/Components/InventoryModelComponent.cs
  10. 2
      Assets/Scripts/Shop/Components/InventoryModelComponent.cs.meta
  11. 2
      Assets/Scripts/Shop/Components/ShopModelComponent.cs.meta
  12. 4
      Assets/Scripts/Shop/Model/BuyModel.cs
  13. 10
      Assets/Scripts/Shop/Model/IInventoryContainer.cs
  14. 11
      Assets/Scripts/Shop/Model/IInventoryContainer.cs.meta
  15. 6
      Assets/Scripts/Shop/Model/Inventory.cs
  16. 8
      Assets/Scripts/Shop/Model/ModelComponent.cs
  17. 4
      Assets/Scripts/Shop/Model/SellModel.cs
  18. 6
      Assets/Scripts/Shop/Model/ShopModel.cs
  19. 14
      Assets/Scripts/Shop/Scriptable Objects/InventoryInit.cs
  20. 11
      Assets/Scripts/Shop/Scriptable Objects/InventoryInit.cs.meta
  21. 2
      Assets/Scripts/Shop/Scriptable Objects/ItemFactory.cs
  22. 4
      Assets/Scripts/Shop/Scriptable Objects/MultiItemFactory.cs
  23. 4
      Assets/Scripts/Shop/Scriptable Objects/ProceduralArmorFactory.cs
  24. 4
      Assets/Scripts/Shop/Scriptable Objects/ProceduralPotionFactory.cs
  25. 4
      Assets/Scripts/Shop/Scriptable Objects/ProceduralWeaponFactory.cs
  26. 4
      Assets/Scripts/Shop/Scriptable Objects/ScriptedItemFactory.cs
  27. 6
      Assets/Scripts/Shop/Scriptable Objects/ShopObject.cs
  28. 2
      Assets/Scripts/Shop/View/ShopView.cs

8
Assets/Resources/Inventories.meta

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 3cb5ba7bdedc6a84c8e0964a07f63beb
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

16
Assets/Resources/Inventories/PlayerInventory.asset

@ -0,0 +1,16 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!114 &11400000
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 0}
m_Name: PlayerInventory
m_EditorClassIdentifier: SAShop::InventoryInitVals
Money: 5500
Items: {fileID: 11400000, guid: aed79a62cfb941741bd92ea0a643b752, type: 2}

8
Assets/Resources/Inventories/PlayerInventory.asset.meta

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 4ba20449d16e86b4eabf0b524c759f07
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 11400000
userData:
assetBundleName:
assetBundleVariant:

16
Assets/Resources/Inventories/ShopInventory.asset

@ -0,0 +1,16 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!114 &11400000
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 0}
m_Name: ShopInventory
m_EditorClassIdentifier: SAShop::InventoryInitVals
Money: 8000
Items: {fileID: 11400000, guid: b75166a8b7cdac24d9a9d1cd0edf4a15, type: 2}

8
Assets/Resources/Inventories/ShopInventory.asset.meta

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: e64d01fbae5b7cb41966afe48bf87dc9
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 11400000
userData:
assetBundleName:
assetBundleVariant:

29
Assets/Scenes/NewShop.unity

@ -787,6 +787,7 @@ GameObject:
m_Component: m_Component:
- component: {fileID: 132445006} - component: {fileID: 132445006}
- component: {fileID: 132445007} - component: {fileID: 132445007}
- component: {fileID: 132445008}
m_Layer: 5 m_Layer: 5
m_Name: Shop m_Name: Shop
m_TagString: Untagged m_TagString: Untagged
@ -827,8 +828,21 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: be8c4b332c72a3c4b85013b334ebde3a, type: 3} m_Script: {fileID: 11500000, guid: be8c4b332c72a3c4b85013b334ebde3a, type: 3}
m_Name: m_Name:
m_EditorClassIdentifier: m_EditorClassIdentifier:
factory: {fileID: 11400000, guid: b75166a8b7cdac24d9a9d1cd0edf4a15, type: 2} inventory: {fileID: 132445008}
shop: {fileID: 11400000, guid: 366ca79a0c4a2df4fac53ddd28f65f1a, type: 2} shop: {fileID: 11400000, guid: 366ca79a0c4a2df4fac53ddd28f65f1a, type: 2}
--- !u!114 &132445008
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 132445005}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: c83375c3d017aee4c9db24976f6a6ba4, type: 3}
m_Name:
m_EditorClassIdentifier:
factory: {fileID: 11400000, guid: e64d01fbae5b7cb41966afe48bf87dc9, type: 2}
--- !u!1 &169548028 --- !u!1 &169548028
GameObject: GameObject:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
@ -2704,7 +2718,7 @@ MonoBehaviour:
buyButton: {fileID: 1424786402} buyButton: {fileID: 1424786402}
instructionText: {fileID: 360948192} instructionText: {fileID: 360948192}
layoutGroup: {fileID: 2049417198} layoutGroup: {fileID: 2049417198}
ownModel: {fileID: 1237921497} ownModel: {fileID: 1237921498}
--- !u!114 &336428457 --- !u!114 &336428457
MonoBehaviour: MonoBehaviour:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
@ -9796,8 +9810,8 @@ GameObject:
serializedVersion: 6 serializedVersion: 6
m_Component: m_Component:
- component: {fileID: 1237921496} - component: {fileID: 1237921496}
- component: {fileID: 1237921497}
- component: {fileID: 1237921498} - component: {fileID: 1237921498}
- component: {fileID: 1237921497}
m_Layer: 5 m_Layer: 5
m_Name: Inventory m_Name: Inventory
m_TagString: Untagged m_TagString: Untagged
@ -9835,11 +9849,10 @@ MonoBehaviour:
m_GameObject: {fileID: 1237921495} m_GameObject: {fileID: 1237921495}
m_Enabled: 1 m_Enabled: 1
m_EditorHideFlags: 0 m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: be8c4b332c72a3c4b85013b334ebde3a, type: 3} m_Script: {fileID: 11500000, guid: c83375c3d017aee4c9db24976f6a6ba4, type: 3}
m_Name: m_Name:
m_EditorClassIdentifier: m_EditorClassIdentifier:
factory: {fileID: 11400000, guid: aed79a62cfb941741bd92ea0a643b752, type: 2} factory: {fileID: 11400000, guid: 4ba20449d16e86b4eabf0b524c759f07, type: 2}
shop: {fileID: 11400000, guid: 366ca79a0c4a2df4fac53ddd28f65f1a, type: 2}
--- !u!114 &1237921498 --- !u!114 &1237921498
MonoBehaviour: MonoBehaviour:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
@ -9852,7 +9865,7 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 8e211938370fd3d43a99aae3848bdd1c, type: 3} m_Script: {fileID: 11500000, guid: 8e211938370fd3d43a99aae3848bdd1c, type: 3}
m_Name: m_Name:
m_EditorClassIdentifier: m_EditorClassIdentifier:
factory: {fileID: 11400000, guid: aed79a62cfb941741bd92ea0a643b752, type: 2} inventory: {fileID: 1237921497}
shop: {fileID: 11400000, guid: 5832c828db6d00c42a09217f7b743233, type: 2} shop: {fileID: 11400000, guid: 5832c828db6d00c42a09217f7b743233, type: 2}
--- !u!1 &1287258904 --- !u!1 &1287258904
GameObject: GameObject:
@ -10084,7 +10097,7 @@ MonoBehaviour:
buyButton: {fileID: 1835603779} buyButton: {fileID: 1835603779}
instructionText: {fileID: 403716179} instructionText: {fileID: 403716179}
layoutGroup: {fileID: 981903572} layoutGroup: {fileID: 981903572}
ownModel: {fileID: 1237921497} ownModel: {fileID: 1237921498}
infoPanel: {fileID: 1800161527} infoPanel: {fileID: 1800161527}
--- !u!114 &1296916391 --- !u!114 &1296916391
MonoBehaviour: MonoBehaviour:

18
Assets/Scripts/Shop/Components/InventoryComponent.cs

@ -0,0 +1,18 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class InventoryComponent : MonoBehaviour, IInventoryContainer
{
[SerializeField] private InventoryInitVals factory;
//[SerializeField] private ShopObject inventoryStart;
// Start is called before the first frame update
void Awake()
{
Debug.Assert(factory != null,"Item factory not assigned!",this);
Inventory = new Inventory(factory.Money);
factory.Items.PopulateInventory(Inventory);
}
public Inventory Inventory { get; private set; }
}

11
Assets/Scripts/Shop/Components/InventoryComponent.cs.meta

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: c83375c3d017aee4c9db24976f6a6ba4
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: -50
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

2
Assets/Scripts/Shop/Components/InventoryModelComponent.cs

@ -8,6 +8,6 @@ public class InventoryModelComponent : ModelComponent
protected override void CreateModel() protected override void CreateModel()
{ {
Debug.Assert(shop != null,"Shop model initial object never assigned!",this); Debug.Assert(shop != null,"Shop model initial object never assigned!",this);
model = new SellModel(shop); model = new SellModel(shop,inventory.Inventory);
} }
} }

2
Assets/Scripts/Shop/Components/InventoryModelComponent.cs.meta

@ -4,7 +4,7 @@ MonoImporter:
externalObjects: {} externalObjects: {}
serializedVersion: 2 serializedVersion: 2
defaultReferences: [] defaultReferences: []
executionOrder: 0 executionOrder: -20
icon: {instanceID: 0} icon: {instanceID: 0}
userData: userData:
assetBundleName: assetBundleName:

2
Assets/Scripts/Shop/Components/ShopModelComponent.cs.meta

@ -4,7 +4,7 @@ MonoImporter:
externalObjects: {} externalObjects: {}
serializedVersion: 2 serializedVersion: 2
defaultReferences: [] defaultReferences: []
executionOrder: 0 executionOrder: -10
icon: {instanceID: 0} icon: {instanceID: 0}
userData: userData:
assetBundleName: assetBundleName:

4
Assets/Scripts/Shop/Model/BuyModel.cs

@ -14,8 +14,10 @@ public class BuyModel : ShopModel
// Rather than modifying the whole class, we just reuse the existing stuff but don't make it create any items. // Rather than modifying the whole class, we just reuse the existing stuff but don't make it create any items.
// This makes it less work to make proper functionality, without having to break any potential old functionality. // This makes it less work to make proper functionality, without having to break any potential old functionality.
// Additionally, saves us work having to rip out the inventory's own ability to generate items. // Additionally, saves us work having to rip out the inventory's own ability to generate items.
public BuyModel(ShopObject pShopInitials) : this(pShopInitials.PriceModifier, 0, pShopInitials.Money) // Edit: Nevermind, let's just allow setting the inventory in the constructor, for shared inventories between models!
public BuyModel(ShopObject pShopInitials, Inventory inventory = null) : this(pShopInitials.PriceModifier, 0, 0)
{ {
if (inventory != null) this.inventory = inventory;
} }
//------------------------------------------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------------------------------------------

10
Assets/Scripts/Shop/Model/IInventoryContainer.cs

@ -0,0 +1,10 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
/// <summary>
/// Defines a class that contains an inventory
/// </summary>
public interface IInventoryContainer
{
Inventory Inventory { get; }
}

11
Assets/Scripts/Shop/Model/IInventoryContainer.cs.meta

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 0ada16e429f65e945bfc92b2e6f91cd7
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

6
Assets/Scripts/Shop/Model/Inventory.cs

@ -11,9 +11,13 @@ public class Inventory
private List<Item> itemList = new List<Item>(); //Items in the inventory private List<Item> itemList = new List<Item>(); //Items in the inventory
//Set up the inventory with item count and money //Set up the inventory with item count and money
public Inventory(int pItemCount, int pMoney) public Inventory(int pItemCount, int pMoney) : this(pMoney)
{ {
PopulateInventory(pItemCount); PopulateInventory(pItemCount);
}
public Inventory(int pMoney)
{
Money = pMoney; Money = pMoney;
} }

8
Assets/Scripts/Shop/Model/ModelComponent.cs

@ -10,15 +10,17 @@ using UnityEngine;
public abstract class ModelComponent : MonoBehaviour, IModelContainer public abstract class ModelComponent : MonoBehaviour, IModelContainer
{ {
public ShopModel Model { get => model; } public ShopModel Model { get => model; }
[SerializeField] private ItemFactory factory; //[SerializeField] private ItemFactory factory;
[SerializeField] protected InventoryComponent inventory;
protected ShopModel model; protected ShopModel model;
private void Awake() private void Awake()
{ {
Debug.Assert(factory != null,"Item factory not assigned!",this); Debug.Assert(inventory != null,"Inventory not assigned!",this);
CreateModel(); // Of course, a generic model component can't select which type of model to use. So we use polymorphism! CreateModel(); // Of course, a generic model component can't select which type of model to use. So we use polymorphism!
factory.PopulateModel(model); model.inventory = inventory.Inventory;
//factory.PopulateInventory(model.inventory);
} }
protected abstract void CreateModel(); protected abstract void CreateModel();

4
Assets/Scripts/Shop/Model/SellModel.cs

@ -14,8 +14,10 @@ public class SellModel : ShopModel
// Rather than modifying the whole class, we just reuse the existing stuff but don't make it create any items. // Rather than modifying the whole class, we just reuse the existing stuff but don't make it create any items.
// This makes it less work to make proper functionality, without having to break any potential old functionality. // This makes it less work to make proper functionality, without having to break any potential old functionality.
// Additionally, saves us work having to rip out the inventory's own ability to generate items. // Additionally, saves us work having to rip out the inventory's own ability to generate items.
public SellModel(ShopObject pShopInitials) : this(pShopInitials.PriceModifier, 0, pShopInitials.Money) // Edit: Nevermind, let's just allow setting the inventory in the constructor, for shared inventories between models!
public SellModel(ShopObject pShopInitials, Inventory inventory = null) : this(pShopInitials.PriceModifier, 0, 0)
{ {
if (inventory != null) this.inventory = inventory;
} }
//------------------------------------------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------------------------------------------

6
Assets/Scripts/Shop/Model/ShopModel.cs

@ -8,7 +8,11 @@ using System.Collections.Generic;
/// </summary> /// </summary>
public abstract class ShopModel : IModelObservable<Item> public abstract class ShopModel : IModelObservable<Item>
{ {
public Inventory inventory { get; } // Getter of the inventory, the views might need this to set up the display. public Inventory inventory
{
get;
set;
} // Getter of the inventory, the views might need this to set up the display.
protected float priceModifier; //Modifies the item's price based on its base price protected float priceModifier; //Modifies the item's price based on its base price
protected int selectedItemIndex = 0; //selected item index protected int selectedItemIndex = 0; //selected item index

14
Assets/Scripts/Shop/Scriptable Objects/InventoryInit.cs

@ -0,0 +1,14 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
/// <summary>
/// This object allows us to script which kind of stuff an inventory starts out with. Inventory are meant to be created
/// by using the inventory unity component, which requires InventoryInitVals to be able to know which kind of money and other
/// things specific to a inventory they start with.
/// </summary>
[CreateAssetMenu]//Allows creating ViewConfig objects in Assets -> Create menu in the Unity Editor
public class InventoryInitVals : ScriptableObject
{
public int Money;
public ItemFactory Items;
}

11
Assets/Scripts/Shop/Scriptable Objects/InventoryInit.cs.meta

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 6b56b3d0165a9714ab2efbdf15c22d0d
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

2
Assets/Scripts/Shop/Scriptable Objects/ItemFactory.cs

@ -8,7 +8,7 @@ using UnityEngine.Serialization;
/// </summary> /// </summary>
public abstract class ItemFactory : ScriptableObject public abstract class ItemFactory : ScriptableObject
{ {
public abstract void PopulateModel(ShopModel model); public abstract void PopulateInventory(Inventory inv);
} }
// This has the sole purpose of associating a sprite with a name for the factory. Not making it a scriptable object because doing this in the factory editor view is faster // This has the sole purpose of associating a sprite with a name for the factory. Not making it a scriptable object because doing this in the factory editor view is faster

4
Assets/Scripts/Shop/Scriptable Objects/MultiItemFactory.cs

@ -9,11 +9,11 @@ using UnityEngine;
public class MultiItemFactory : ItemFactory public class MultiItemFactory : ItemFactory
{ {
public ItemFactory[] ItemFactories; public ItemFactory[] ItemFactories;
public override void PopulateModel(ShopModel model) public override void PopulateInventory(Inventory model)
{ {
foreach (var factory in ItemFactories) foreach (var factory in ItemFactories)
{ {
factory.PopulateModel(model); factory.PopulateInventory(model);
} }
} }
} }

4
Assets/Scripts/Shop/Scriptable Objects/ProceduralArmorFactory.cs

@ -18,12 +18,12 @@ public class ProceduralArmorFactory : ItemFactory
public ItemPrototype[] Items; public ItemPrototype[] Items;
public int Amount; public int Amount;
public override void PopulateModel(ShopModel model) public override void PopulateInventory(Inventory model)
{ {
for (int i = 0; i < Amount; i++) for (int i = 0; i < Amount; i++)
{ {
var item = Items[Random.Range(0, Items.Length)]; var item = Items[Random.Range(0, Items.Length)];
model.inventory.AddItem(new ItemArmor(item.Name,item.Sprite.name,Random.Range(PriceMin,PriceMax),Random.Range(DefenseMax,DefenseMax) + item.Bonus,Random.Range(DefenseMin,DefenseMax) + item.Bonus + 3,item.Description, Rarity)); model.AddItem(new ItemArmor(item.Name,item.Sprite.name,Random.Range(PriceMin,PriceMax),Random.Range(DefenseMax,DefenseMax) + item.Bonus,Random.Range(DefenseMin,DefenseMax) + item.Bonus + 3,item.Description, Rarity));
} }
} }
} }

4
Assets/Scripts/Shop/Scriptable Objects/ProceduralPotionFactory.cs

@ -18,12 +18,12 @@ public class ProceduralPotionFactory : ItemFactory
public PotionPrototype[] Items; public PotionPrototype[] Items;
public int Amount; public int Amount;
public override void PopulateModel(ShopModel model) public override void PopulateInventory(Inventory model)
{ {
for (int i = 0; i < Amount; i++) for (int i = 0; i < Amount; i++)
{ {
var item = Items[Random.Range(0, Items.Length)]; var item = Items[Random.Range(0, Items.Length)];
model.inventory.AddItem(new ItemPotion(item.Name,item.Sprite.name,Random.Range(PriceMin,PriceMax),item.EffectTime,item.Type,Random.Range(EffectMin,EffectMax) + item.Bonus + 3,item.Description, Rarity)); model.AddItem(new ItemPotion(item.Name,item.Sprite.name,Random.Range(PriceMin,PriceMax),item.EffectTime,item.Type,Random.Range(EffectMin,EffectMax) + item.Bonus + 3,item.Description, Rarity));
} }
} }
} }

4
Assets/Scripts/Shop/Scriptable Objects/ProceduralWeaponFactory.cs

@ -18,12 +18,12 @@ public class ProceduralWeaponFactory : ItemFactory
public ItemPrototype[] Items; public ItemPrototype[] Items;
public int Amount; public int Amount;
public override void PopulateModel(ShopModel model) public override void PopulateInventory(Inventory model)
{ {
for (int i = 0; i < Amount; i++) for (int i = 0; i < Amount; i++)
{ {
var item = Items[Random.Range(0, Items.Length)]; var item = Items[Random.Range(0, Items.Length)];
model.inventory.AddItem(new ItemWeapon(item.Name,item.Sprite.name,Random.Range(PriceMin,PriceMax),Random.Range(DamageMin,DamageMax) + item.Bonus,Random.Range(DamageMin,DamageMax) + item.Bonus + 3,item.Description, Rarity)); model.AddItem(new ItemWeapon(item.Name,item.Sprite.name,Random.Range(PriceMin,PriceMax),Random.Range(DamageMin,DamageMax) + item.Bonus,Random.Range(DamageMin,DamageMax) + item.Bonus + 3,item.Description, Rarity));
} }
} }
} }

4
Assets/Scripts/Shop/Scriptable Objects/ScriptedItemFactory.cs

@ -8,11 +8,11 @@ using UnityEngine;
public class ScriptedItemFactory : ItemFactory public class ScriptedItemFactory : ItemFactory
{ {
public List<ScriptedItem> Items; public List<ScriptedItem> Items;
public override void PopulateModel(ShopModel model) public override void PopulateInventory(Inventory model)
{ {
foreach (var item in Items) foreach (var item in Items)
{ {
model.inventory.AddItem(item.GenerateItem()); model.AddItem(item.GenerateItem());
} }
} }
} }

6
Assets/Scripts/Shop/Scriptable Objects/ShopObject.cs

@ -2,13 +2,11 @@
using System.Collections.Generic; using System.Collections.Generic;
using UnityEngine; using UnityEngine;
/// <summary> /// <summary>
/// This shop object allows us to script which kind of stuff a shop starts out with. Models are meant to be created /// Currently only contains shop specific stuff, such as a price modifier
/// by using the appropriate unity component, which requires a shopobject to be able to which kind of money and other
/// things specific to a shop they start with.
/// </summary> /// </summary>
[CreateAssetMenu]//Allows creating ViewConfig objects in Assets -> Create menu in the Unity Editor [CreateAssetMenu]//Allows creating ViewConfig objects in Assets -> Create menu in the Unity Editor
public class ShopObject : ScriptableObject public class ShopObject : ScriptableObject
{ {
public int Money; //public int Money;
public float PriceModifier; // How much more expensive than retail price does this shop sell stuff? public float PriceModifier; // How much more expensive than retail price does this shop sell stuff?
} }

2
Assets/Scripts/Shop/View/ShopView.cs

@ -49,6 +49,8 @@ public abstract class ShopView : MonoBehaviour
private void OnEnable() private void OnEnable()
{ {
// sanity check
if (model == null) model = ownModel.Model;
PopulateItemIconView(); //Display items PopulateItemIconView(); //Display items
} }

Loading…
Cancel
Save