From b7177d787f0b22c784e26b6717c97cda5ce80f62 Mon Sep 17 00:00:00 2001 From: Devin Braune Date: Tue, 2 Feb 2021 05:26:32 +0100 Subject: [PATCH] Prepare scriptable shop factories --- Assets/Resources/ScriptedItems.meta | 8 ++++ .../Resources/ScriptedItems/BetterSword.asset | 17 ++++++++ .../ScriptedItems/BetterSword.asset.meta | 8 ++++ .../Resources/ScriptedItems/SomeSword.asset | 17 ++++++++ .../ScriptedItems/SomeSword.asset.meta | 8 ++++ Assets/Resources/StandardShop.asset | 16 ++++++++ Assets/Resources/StandardShop.asset.meta | 8 ++++ Assets/Resources/StandardShopInventory.asset | 27 +++++++++++++ .../StandardShopInventory.asset.meta | 8 ++++ Assets/Scenes/NewShop.unity | 39 +++++++++++++------ Assets/Scripts/Shop/Model/BuyModel.cs | 7 ++++ Assets/Scripts/Shop/Model/IModelContainer.cs | 6 +++ .../Shop/Model/IModelContainer.cs.meta | 11 ++++++ Assets/Scripts/Shop/Model/ModelComponent.cs | 25 ++++++++++++ .../Scripts/Shop/Model/ModelComponent.cs.meta | 11 ++++++ .../Scripts/Shop/Model/ShopModelComponent.cs | 13 +++++++ .../Shop/Model/ShopModelComponent.cs.meta | 11 ++++++ .../Shop/Scriptable Objects/ItemFactory.cs | 10 +++++ .../Scriptable Objects/ItemFactory.cs.meta | 11 ++++++ .../Shop/Scriptable Objects/ScriptedItem.cs | 13 +++++++ .../Scriptable Objects/ScriptedItem.cs.meta | 11 ++++++ .../Scriptable Objects/ScriptedItemFactory.cs | 15 +++++++ .../ScriptedItemFactory.cs.meta | 11 ++++++ .../Shop/Scriptable Objects/ShopObject.cs | 14 +++++++ .../Scriptable Objects/ShopObject.cs.meta | 11 ++++++ .../Shop/View/GridViewItemContainer.cs | 1 - 26 files changed, 324 insertions(+), 13 deletions(-) create mode 100644 Assets/Resources/ScriptedItems.meta create mode 100644 Assets/Resources/ScriptedItems/BetterSword.asset create mode 100644 Assets/Resources/ScriptedItems/BetterSword.asset.meta create mode 100644 Assets/Resources/ScriptedItems/SomeSword.asset create mode 100644 Assets/Resources/ScriptedItems/SomeSword.asset.meta create mode 100644 Assets/Resources/StandardShop.asset create mode 100644 Assets/Resources/StandardShop.asset.meta create mode 100644 Assets/Resources/StandardShopInventory.asset create mode 100644 Assets/Resources/StandardShopInventory.asset.meta create mode 100644 Assets/Scripts/Shop/Model/IModelContainer.cs create mode 100644 Assets/Scripts/Shop/Model/IModelContainer.cs.meta create mode 100644 Assets/Scripts/Shop/Model/ModelComponent.cs create mode 100644 Assets/Scripts/Shop/Model/ModelComponent.cs.meta create mode 100644 Assets/Scripts/Shop/Model/ShopModelComponent.cs create mode 100644 Assets/Scripts/Shop/Model/ShopModelComponent.cs.meta create mode 100644 Assets/Scripts/Shop/Scriptable Objects/ItemFactory.cs create mode 100644 Assets/Scripts/Shop/Scriptable Objects/ItemFactory.cs.meta create mode 100644 Assets/Scripts/Shop/Scriptable Objects/ScriptedItem.cs create mode 100644 Assets/Scripts/Shop/Scriptable Objects/ScriptedItem.cs.meta create mode 100644 Assets/Scripts/Shop/Scriptable Objects/ScriptedItemFactory.cs create mode 100644 Assets/Scripts/Shop/Scriptable Objects/ScriptedItemFactory.cs.meta create mode 100644 Assets/Scripts/Shop/Scriptable Objects/ShopObject.cs create mode 100644 Assets/Scripts/Shop/Scriptable Objects/ShopObject.cs.meta diff --git a/Assets/Resources/ScriptedItems.meta b/Assets/Resources/ScriptedItems.meta new file mode 100644 index 0000000..4ab6242 --- /dev/null +++ b/Assets/Resources/ScriptedItems.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 5baa559c09c7aa84db8dbacf122bf34d +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Resources/ScriptedItems/BetterSword.asset b/Assets/Resources/ScriptedItems/BetterSword.asset new file mode 100644 index 0000000..5791cc4 --- /dev/null +++ b/Assets/Resources/ScriptedItems/BetterSword.asset @@ -0,0 +1,17 @@ +%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: 11500000, guid: af86c7c2268eed441b882ced845365f4, type: 3} + m_Name: BetterSword + m_EditorClassIdentifier: + Name: Good Sword + Description: Better than the Noob Sword + sprite: {fileID: -4063295180217184869, guid: b00993d063fbc4a87983115070f6145c, type: 3} diff --git a/Assets/Resources/ScriptedItems/BetterSword.asset.meta b/Assets/Resources/ScriptedItems/BetterSword.asset.meta new file mode 100644 index 0000000..8a91ad5 --- /dev/null +++ b/Assets/Resources/ScriptedItems/BetterSword.asset.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 8ec316abfe61e4b43862dd2c75f0f792 +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 11400000 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Resources/ScriptedItems/SomeSword.asset b/Assets/Resources/ScriptedItems/SomeSword.asset new file mode 100644 index 0000000..186e576 --- /dev/null +++ b/Assets/Resources/ScriptedItems/SomeSword.asset @@ -0,0 +1,17 @@ +%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: 11500000, guid: af86c7c2268eed441b882ced845365f4, type: 3} + m_Name: SomeSword + m_EditorClassIdentifier: + Name: Noob Sword + Description: This sword is for noobs + sprite: {fileID: -6229739577819397656, guid: b00993d063fbc4a87983115070f6145c, type: 3} diff --git a/Assets/Resources/ScriptedItems/SomeSword.asset.meta b/Assets/Resources/ScriptedItems/SomeSword.asset.meta new file mode 100644 index 0000000..1152272 --- /dev/null +++ b/Assets/Resources/ScriptedItems/SomeSword.asset.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: b0a77491a8b600245b47aa33287d7585 +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 11400000 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Resources/StandardShop.asset b/Assets/Resources/StandardShop.asset new file mode 100644 index 0000000..994ed7e --- /dev/null +++ b/Assets/Resources/StandardShop.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: 11500000, guid: 3145dd14dac0cf84a909862b61ec2893, type: 3} + m_Name: StandardShop + m_EditorClassIdentifier: + Money: 10000 + PriceModifier: 1.1 diff --git a/Assets/Resources/StandardShop.asset.meta b/Assets/Resources/StandardShop.asset.meta new file mode 100644 index 0000000..e850944 --- /dev/null +++ b/Assets/Resources/StandardShop.asset.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 366ca79a0c4a2df4fac53ddd28f65f1a +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 11400000 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Resources/StandardShopInventory.asset b/Assets/Resources/StandardShopInventory.asset new file mode 100644 index 0000000..c605385 --- /dev/null +++ b/Assets/Resources/StandardShopInventory.asset @@ -0,0 +1,27 @@ +%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: 11500000, guid: d4a440686e1eaa042a9d58081a9b8dbe, type: 3} + m_Name: StandardShopInventory + m_EditorClassIdentifier: + Items: + - {fileID: 11400000, guid: b0a77491a8b600245b47aa33287d7585, type: 2} + - {fileID: 11400000, guid: b0a77491a8b600245b47aa33287d7585, type: 2} + - {fileID: 11400000, guid: b0a77491a8b600245b47aa33287d7585, type: 2} + - {fileID: 11400000, guid: b0a77491a8b600245b47aa33287d7585, type: 2} + - {fileID: 11400000, guid: b0a77491a8b600245b47aa33287d7585, type: 2} + - {fileID: 11400000, guid: b0a77491a8b600245b47aa33287d7585, type: 2} + - {fileID: 11400000, guid: b0a77491a8b600245b47aa33287d7585, type: 2} + - {fileID: 11400000, guid: b0a77491a8b600245b47aa33287d7585, type: 2} + - {fileID: 11400000, guid: 8ec316abfe61e4b43862dd2c75f0f792, type: 2} + - {fileID: 11400000, guid: 8ec316abfe61e4b43862dd2c75f0f792, type: 2} + - {fileID: 11400000, guid: 8ec316abfe61e4b43862dd2c75f0f792, type: 2} + - {fileID: 11400000, guid: 8ec316abfe61e4b43862dd2c75f0f792, type: 2} diff --git a/Assets/Resources/StandardShopInventory.asset.meta b/Assets/Resources/StandardShopInventory.asset.meta new file mode 100644 index 0000000..47a79c3 --- /dev/null +++ b/Assets/Resources/StandardShopInventory.asset.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: d16c0801001245545908f8b001145a3d +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 11400000 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scenes/NewShop.unity b/Assets/Scenes/NewShop.unity index 9d9d224..9673871 100644 --- a/Assets/Scenes/NewShop.unity +++ b/Assets/Scenes/NewShop.unity @@ -373,6 +373,7 @@ GameObject: serializedVersion: 6 m_Component: - component: {fileID: 132445006} + - component: {fileID: 132445007} m_Layer: 5 m_Name: Shop m_TagString: Untagged @@ -387,20 +388,34 @@ RectTransform: m_PrefabInstance: {fileID: 0} m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 132445005} - m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} m_LocalPosition: {x: 0, y: 0, z: 0} m_LocalScale: {x: 1, y: 1, z: 1} m_Children: - - {fileID: 2131558511} - {fileID: 822572996} + - {fileID: 2131558511} m_Father: {fileID: 1697822368} m_RootOrder: 2 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} - m_AnchorMin: {x: 0.5, y: 0.5} - m_AnchorMax: {x: 0.5, y: 0.5} - m_AnchoredPosition: {x: 0, y: 0} - m_SizeDelta: {x: 100, y: 100} + m_AnchorMin: {x: 0, y: 0} + m_AnchorMax: {x: 1, y: 1} + m_AnchoredPosition: {x: 100, y: 1.2143555} + m_SizeDelta: {x: -199.99988, y: -2.241211} m_Pivot: {x: 0.5, y: 0.5} +--- !u!114 &132445007 +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: be8c4b332c72a3c4b85013b334ebde3a, type: 3} + m_Name: + m_EditorClassIdentifier: + factory: {fileID: 11400000, guid: d16c0801001245545908f8b001145a3d, type: 2} + shop: {fileID: 11400000, guid: 366ca79a0c4a2df4fac53ddd28f65f1a, type: 2} --- !u!1 &180905778 GameObject: m_ObjectHideFlags: 0 @@ -2883,12 +2898,12 @@ RectTransform: - {fileID: 779240604} - {fileID: 1510759986} m_Father: {fileID: 132445006} - m_RootOrder: 1 + m_RootOrder: 0 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_AnchorMin: {x: 0, y: 0} m_AnchorMax: {x: 1, y: 1} - m_AnchoredPosition: {x: 100, y: 0} - m_SizeDelta: {x: 1300, y: 654.2234} + m_AnchoredPosition: {x: 0, y: -1.2144165} + m_SizeDelta: {x: -0.00012207031, y: 2.4645996} m_Pivot: {x: 0.5, y: 0.5} --- !u!114 &822572997 MonoBehaviour: @@ -9328,12 +9343,12 @@ RectTransform: - {fileID: 849412833} - {fileID: 889320677} m_Father: {fileID: 132445006} - m_RootOrder: 0 + m_RootOrder: 1 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_AnchorMin: {x: 0, y: 0} m_AnchorMax: {x: 1, y: 1} - m_AnchoredPosition: {x: 100, y: 0} - m_SizeDelta: {x: 1300, y: 654.2234} + m_AnchoredPosition: {x: 0, y: -1.2144165} + m_SizeDelta: {x: -0.00012207031, y: 2.4645996} m_Pivot: {x: 0.5, y: 0.5} --- !u!114 &2131558512 MonoBehaviour: diff --git a/Assets/Scripts/Shop/Model/BuyModel.cs b/Assets/Scripts/Shop/Model/BuyModel.cs index 3997de5..32914b4 100644 --- a/Assets/Scripts/Shop/Model/BuyModel.cs +++ b/Assets/Scripts/Shop/Model/BuyModel.cs @@ -11,6 +11,13 @@ public class BuyModel : ShopModel } + // 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. + // 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) + { + } + //------------------------------------------------------------------------------------------------------------------------ // ConfirmSelectedItem() //------------------------------------------------------------------------------------------------------------------------ diff --git a/Assets/Scripts/Shop/Model/IModelContainer.cs b/Assets/Scripts/Shop/Model/IModelContainer.cs new file mode 100644 index 0000000..96ae15f --- /dev/null +++ b/Assets/Scripts/Shop/Model/IModelContainer.cs @@ -0,0 +1,6 @@ +/// +/// Just makes sure implementations have an accessible reference to a shop model. Could be an inventory of course. +/// +public interface IModelContainer{ + ShopModel Model { get; } +} diff --git a/Assets/Scripts/Shop/Model/IModelContainer.cs.meta b/Assets/Scripts/Shop/Model/IModelContainer.cs.meta new file mode 100644 index 0000000..f393472 --- /dev/null +++ b/Assets/Scripts/Shop/Model/IModelContainer.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: bac32d122ed6934498d1bbe6e2fbabc3 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/Shop/Model/ModelComponent.cs b/Assets/Scripts/Shop/Model/ModelComponent.cs new file mode 100644 index 0000000..670e412 --- /dev/null +++ b/Assets/Scripts/Shop/Model/ModelComponent.cs @@ -0,0 +1,25 @@ +using System; +using System.Collections; +using System.Collections.Generic; +using UnityEngine; +/// +/// This component basically associates a model with a gameobject. This allows to know its location in the world +/// (2D or 3D!) for fancy effects, or allows a view to switch between different models as it sees fit. +/// The actual model can be anything from a buymodel to an inventorymodel +/// +public abstract class ModelComponent : MonoBehaviour, IModelContainer +{ + public ShopModel Model { get => model; } + [SerializeField] private ItemFactory factory; + + protected ShopModel model; + + private void Awake() + { + Debug.Assert(factory != null,"Item factory not assigned!",this); + CreateModel(); // Of course, a generic model component can't select which type of model to use. So we use polymorphism! + factory.PopulateModel(model); + } + + protected abstract void CreateModel(); +} diff --git a/Assets/Scripts/Shop/Model/ModelComponent.cs.meta b/Assets/Scripts/Shop/Model/ModelComponent.cs.meta new file mode 100644 index 0000000..9496a7e --- /dev/null +++ b/Assets/Scripts/Shop/Model/ModelComponent.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 1abae9da667453942bb6221fd22826ee +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/Shop/Model/ShopModelComponent.cs b/Assets/Scripts/Shop/Model/ShopModelComponent.cs new file mode 100644 index 0000000..6b4562c --- /dev/null +++ b/Assets/Scripts/Shop/Model/ShopModelComponent.cs @@ -0,0 +1,13 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +public class ShopModelComponent : ModelComponent +{ + [SerializeField] private ShopObject shop; + protected override void CreateModel() + { + Debug.Assert(shop != null,"Shop model initial object never assigned!",this); + model = new BuyModel(shop); + } +} diff --git a/Assets/Scripts/Shop/Model/ShopModelComponent.cs.meta b/Assets/Scripts/Shop/Model/ShopModelComponent.cs.meta new file mode 100644 index 0000000..5964caf --- /dev/null +++ b/Assets/Scripts/Shop/Model/ShopModelComponent.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: be8c4b332c72a3c4b85013b334ebde3a +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/Shop/Scriptable Objects/ItemFactory.cs b/Assets/Scripts/Shop/Scriptable Objects/ItemFactory.cs new file mode 100644 index 0000000..2a002d6 --- /dev/null +++ b/Assets/Scripts/Shop/Scriptable Objects/ItemFactory.cs @@ -0,0 +1,10 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; +/// +/// An item factory is simply meant to procedurally (or pre-scripted) populate a shop model. +/// +public abstract class ItemFactory : ScriptableObject +{ + public abstract void PopulateModel(ShopModel model); +} diff --git a/Assets/Scripts/Shop/Scriptable Objects/ItemFactory.cs.meta b/Assets/Scripts/Shop/Scriptable Objects/ItemFactory.cs.meta new file mode 100644 index 0000000..0ed9e74 --- /dev/null +++ b/Assets/Scripts/Shop/Scriptable Objects/ItemFactory.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 46c010061a3c73145bc36b2b3efac6df +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/Shop/Scriptable Objects/ScriptedItem.cs b/Assets/Scripts/Shop/Scriptable Objects/ScriptedItem.cs new file mode 100644 index 0000000..aeaa128 --- /dev/null +++ b/Assets/Scripts/Shop/Scriptable Objects/ScriptedItem.cs @@ -0,0 +1,13 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; +/// +/// This represents anything needed to construct one item with pre-scripted information +/// +[CreateAssetMenu]//Allows creating ViewConfig objects in Assets -> Create menu in the Unity Editor +public class ScriptedItem : ScriptableObject +{ + public string Name; + public string Description; + public Sprite sprite; +} diff --git a/Assets/Scripts/Shop/Scriptable Objects/ScriptedItem.cs.meta b/Assets/Scripts/Shop/Scriptable Objects/ScriptedItem.cs.meta new file mode 100644 index 0000000..bad2a2a --- /dev/null +++ b/Assets/Scripts/Shop/Scriptable Objects/ScriptedItem.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: af86c7c2268eed441b882ced845365f4 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/Shop/Scriptable Objects/ScriptedItemFactory.cs b/Assets/Scripts/Shop/Scriptable Objects/ScriptedItemFactory.cs new file mode 100644 index 0000000..1e07da9 --- /dev/null +++ b/Assets/Scripts/Shop/Scriptable Objects/ScriptedItemFactory.cs @@ -0,0 +1,15 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; +/// +/// This item factory literally just takes a handcrafted list of items and populates the model with that! +/// +[CreateAssetMenu]//Allows creating ViewConfig objects in Assets -> Create menu in the Unity Editor +public class ScriptedItemFactory : ItemFactory +{ + public List Items; + public override void PopulateModel(ShopModel model) + { + + } +} diff --git a/Assets/Scripts/Shop/Scriptable Objects/ScriptedItemFactory.cs.meta b/Assets/Scripts/Shop/Scriptable Objects/ScriptedItemFactory.cs.meta new file mode 100644 index 0000000..75e4cf2 --- /dev/null +++ b/Assets/Scripts/Shop/Scriptable Objects/ScriptedItemFactory.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: d4a440686e1eaa042a9d58081a9b8dbe +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/Shop/Scriptable Objects/ShopObject.cs b/Assets/Scripts/Shop/Scriptable Objects/ShopObject.cs new file mode 100644 index 0000000..05ff1b1 --- /dev/null +++ b/Assets/Scripts/Shop/Scriptable Objects/ShopObject.cs @@ -0,0 +1,14 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; +/// +/// This shop object allows us to script which kind of stuff a shop starts out with. Models are meant to be created +/// 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. +/// +[CreateAssetMenu]//Allows creating ViewConfig objects in Assets -> Create menu in the Unity Editor +public class ShopObject : ScriptableObject +{ + public int Money; + public float PriceModifier; // How much more expensive than retail price does this shop sell stuff? +} diff --git a/Assets/Scripts/Shop/Scriptable Objects/ShopObject.cs.meta b/Assets/Scripts/Shop/Scriptable Objects/ShopObject.cs.meta new file mode 100644 index 0000000..ef0b7b3 --- /dev/null +++ b/Assets/Scripts/Shop/Scriptable Objects/ShopObject.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 3145dd14dac0cf84a909862b61ec2893 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/Shop/View/GridViewItemContainer.cs b/Assets/Scripts/Shop/View/GridViewItemContainer.cs index a8e9433..a11b6ed 100644 --- a/Assets/Scripts/Shop/View/GridViewItemContainer.cs +++ b/Assets/Scripts/Shop/View/GridViewItemContainer.cs @@ -50,7 +50,6 @@ public class GridViewItemContainer : MonoBehaviour, IItemContainer // Clones the first Sprite in the icon atlas that matches the iconName and uses it as the sprite of the icon image. Sprite sprite = iconAtlas.GetSprite(item.iconName); - if (sprite != null) { icon.sprite = sprite; }