From c0808799021a70ea90f5c7157a681efd74fd4a57 Mon Sep 17 00:00:00 2001 From: Devin Braune Date: Wed, 3 Feb 2021 17:05:45 +0100 Subject: [PATCH] Add armor generation --- Assets/Resources/AllItemsFactory.asset | 17 +++ Assets/Resources/AllItemsFactory.asset.meta | 8 ++ Assets/Resources/BasicArmorFactory.asset | 43 ++++++ Assets/Resources/BasicArmorFactory.asset.meta | 8 ++ Assets/Resources/GigaSwordFactory.asset | 2 +- Assets/Resources/GigaSwordFactory.asset.meta | 2 +- Assets/Resources/GreatArmorFactory.asset | 39 ++++++ Assets/Resources/GreatArmorFactory.asset.meta | 8 ++ Assets/Resources/MegaSwordFactory.asset | 2 +- Assets/Resources/MegaSwordFactory.asset.meta | 2 +- Assets/Resources/NoobSwordFactory.asset | 2 +- Assets/Resources/NoobSwordFactory.asset.meta | 2 +- Assets/Resources/ProSwordFactory.asset | 2 +- Assets/Resources/ProSwordFactory.asset.meta | 2 +- Assets/Resources/RareArmorFactory.asset | 36 +++++ Assets/Resources/RareArmorFactory.asset.meta | 8 ++ Assets/Resources/ShopArmorFactory.asset | 18 +++ Assets/Resources/ShopArmorFactory.asset.meta | 8 ++ Assets/Scenes/NewShop.unity | 123 ++++++++++-------- .../Shop/Components/ItemIconDisplay.cs | 29 +++++ .../Shop/Components/ItemIconDisplay.cs.meta | 11 ++ Assets/Scripts/Shop/Model/ItemArmor.cs | 25 ++++ Assets/Scripts/Shop/Model/ItemArmor.cs.meta | 11 ++ .../Shop/Scriptable Objects/ItemFactory.cs | 12 ++ .../ProceduralArmorFactory.cs | 29 +++++ .../ProceduralArmorFactory.cs.meta | 11 ++ ...mFactory.cs => ProceduralWeaponFactory.cs} | 16 +-- ...s.meta => ProceduralWeaponFactory.cs.meta} | 0 .../Shop/Scriptable Objects/ScriptedArmor.cs | 16 +++ .../Scriptable Objects/ScriptedArmor.cs.meta | 11 ++ Assets/Scripts/Shop/View/ShopViewGrid.cs | 2 +- Assets/Scripts/Shop/View/ShopViewList.cs | 3 +- Assets/Scripts/Shop/View/ViewItemInfoPanel.cs | 7 + 33 files changed, 438 insertions(+), 77 deletions(-) create mode 100644 Assets/Resources/AllItemsFactory.asset create mode 100644 Assets/Resources/AllItemsFactory.asset.meta create mode 100644 Assets/Resources/BasicArmorFactory.asset create mode 100644 Assets/Resources/BasicArmorFactory.asset.meta create mode 100644 Assets/Resources/GreatArmorFactory.asset create mode 100644 Assets/Resources/GreatArmorFactory.asset.meta create mode 100644 Assets/Resources/RareArmorFactory.asset create mode 100644 Assets/Resources/RareArmorFactory.asset.meta create mode 100644 Assets/Resources/ShopArmorFactory.asset create mode 100644 Assets/Resources/ShopArmorFactory.asset.meta create mode 100644 Assets/Scripts/Shop/Components/ItemIconDisplay.cs create mode 100644 Assets/Scripts/Shop/Components/ItemIconDisplay.cs.meta create mode 100644 Assets/Scripts/Shop/Model/ItemArmor.cs create mode 100644 Assets/Scripts/Shop/Model/ItemArmor.cs.meta create mode 100644 Assets/Scripts/Shop/Scriptable Objects/ProceduralArmorFactory.cs create mode 100644 Assets/Scripts/Shop/Scriptable Objects/ProceduralArmorFactory.cs.meta rename Assets/Scripts/Shop/Scriptable Objects/{ProceduralItemFactory.cs => ProceduralWeaponFactory.cs} (59%) rename Assets/Scripts/Shop/Scriptable Objects/{ProceduralItemFactory.cs.meta => ProceduralWeaponFactory.cs.meta} (100%) create mode 100644 Assets/Scripts/Shop/Scriptable Objects/ScriptedArmor.cs create mode 100644 Assets/Scripts/Shop/Scriptable Objects/ScriptedArmor.cs.meta diff --git a/Assets/Resources/AllItemsFactory.asset b/Assets/Resources/AllItemsFactory.asset new file mode 100644 index 0000000..1e2447e --- /dev/null +++ b/Assets/Resources/AllItemsFactory.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: be184c10b845d1044abbc1c356837cac, type: 3} + m_Name: AllItemsFactory + m_EditorClassIdentifier: + ItemFactories: + - {fileID: 11400000, guid: ed86667a8c8440d489527401f6ada6b7, type: 2} + - {fileID: 11400000, guid: 5577191489773c24f95b649170284aa4, type: 2} diff --git a/Assets/Resources/AllItemsFactory.asset.meta b/Assets/Resources/AllItemsFactory.asset.meta new file mode 100644 index 0000000..67688ec --- /dev/null +++ b/Assets/Resources/AllItemsFactory.asset.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: b75166a8b7cdac24d9a9d1cd0edf4a15 +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 11400000 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Resources/BasicArmorFactory.asset b/Assets/Resources/BasicArmorFactory.asset new file mode 100644 index 0000000..332837e --- /dev/null +++ b/Assets/Resources/BasicArmorFactory.asset @@ -0,0 +1,43 @@ +%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: ebeacc5773329254488339277dadfae7, type: 3} + m_Name: BasicArmorFactory + m_EditorClassIdentifier: + Rarity: 16777215 + DefenseMin: 5 + DefenseMax: 8 + PriceMin: 150 + PriceMax: 300 + Items: + - Sprite: {fileID: 6077338267653451029, guid: b00993d063fbc4a87983115070f6145c, + type: 3} + Name: Mooscles + Description: If you drink the milk, your mooscles will be stronk, and you can + defend yourself with them. + Bonus: 0 + - Sprite: {fileID: -7323674943459820596, guid: b00993d063fbc4a87983115070f6145c, + type: 3} + Name: Champion's Tunic + Description: This blue tunic seems to have belonged to a fallen hero hundreds + of years ago. + Bonus: 3 + - Sprite: {fileID: -8650232248937032532, guid: b00993d063fbc4a87983115070f6145c, + type: 3} + Name: Tunic of Time + Description: This green tunic may look familiar. + Bonus: 4 + - Sprite: {fileID: -4790045407390419966, guid: b00993d063fbc4a87983115070f6145c, + type: 3} + Name: Hero's Boots + Description: These boots may look familiar. + Bonus: 2 + Amount: 4 diff --git a/Assets/Resources/BasicArmorFactory.asset.meta b/Assets/Resources/BasicArmorFactory.asset.meta new file mode 100644 index 0000000..f3db2b2 --- /dev/null +++ b/Assets/Resources/BasicArmorFactory.asset.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: a99cf577f5b2a5a4bbf949e8732bb406 +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 11400000 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Resources/GigaSwordFactory.asset b/Assets/Resources/GigaSwordFactory.asset index ddcd648..f4a82e9 100644 --- a/Assets/Resources/GigaSwordFactory.asset +++ b/Assets/Resources/GigaSwordFactory.asset @@ -9,7 +9,7 @@ MonoBehaviour: m_GameObject: {fileID: 0} m_Enabled: 1 m_EditorHideFlags: 0 - m_Script: {fileID: 0} + m_Script: {fileID: 11500000, guid: ea9644082b1c77a44849c5b6af28eb4f, type: 3} m_Name: GigaSwordFactory m_EditorClassIdentifier: SAShop::ProceduralWeaponFactory Rarity: 16711935 diff --git a/Assets/Resources/GigaSwordFactory.asset.meta b/Assets/Resources/GigaSwordFactory.asset.meta index f882fce..38289cf 100644 --- a/Assets/Resources/GigaSwordFactory.asset.meta +++ b/Assets/Resources/GigaSwordFactory.asset.meta @@ -2,7 +2,7 @@ fileFormatVersion: 2 guid: 7e20569483b8ce942a78031bd0b0121c NativeFormatImporter: externalObjects: {} - mainObjectFileID: 11400000 + mainObjectFileID: 0 userData: assetBundleName: assetBundleVariant: diff --git a/Assets/Resources/GreatArmorFactory.asset b/Assets/Resources/GreatArmorFactory.asset new file mode 100644 index 0000000..e26e276 --- /dev/null +++ b/Assets/Resources/GreatArmorFactory.asset @@ -0,0 +1,39 @@ +%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: ebeacc5773329254488339277dadfae7, type: 3} + m_Name: GreatArmorFactory + m_EditorClassIdentifier: + Rarity: 255 + DefenseMin: 14 + DefenseMax: 19 + PriceMin: 500 + PriceMax: 800 + Items: + - Sprite: {fileID: -1754823780530430466, guid: b00993d063fbc4a87983115070f6145c, + type: 3} + Name: Helmet of the Sun + Description: This type of helmet is forged and used by the sun people. Not many + of them are in circulation in other parts of the world. + Bonus: 4 + - Sprite: {fileID: -2660569609710428876, guid: b00993d063fbc4a87983115070f6145c, + type: 3} + Name: Leather Chestplate + Description: Thick leather seems to be more protective of its wearer than thin + cloth. + Bonus: 3 + - Sprite: {fileID: 3386722485073375770, guid: b00993d063fbc4a87983115070f6145c, + type: 3} + Name: Steelcap Boots + Description: Boots with a steelcap are simply better than boots without one - + that is, unless you're trying to stay afloat! + Bonus: 1 + Amount: 2 diff --git a/Assets/Resources/GreatArmorFactory.asset.meta b/Assets/Resources/GreatArmorFactory.asset.meta new file mode 100644 index 0000000..2e3534c --- /dev/null +++ b/Assets/Resources/GreatArmorFactory.asset.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: d951ed0254060cf448168db909dc407c +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 11400000 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Resources/MegaSwordFactory.asset b/Assets/Resources/MegaSwordFactory.asset index ce72f64..08a7eb1 100644 --- a/Assets/Resources/MegaSwordFactory.asset +++ b/Assets/Resources/MegaSwordFactory.asset @@ -9,7 +9,7 @@ MonoBehaviour: m_GameObject: {fileID: 0} m_Enabled: 1 m_EditorHideFlags: 0 - m_Script: {fileID: 0} + m_Script: {fileID: 11500000, guid: ea9644082b1c77a44849c5b6af28eb4f, type: 3} m_Name: MegaSwordFactory m_EditorClassIdentifier: SAShop::ProceduralWeaponFactory Rarity: 65280 diff --git a/Assets/Resources/MegaSwordFactory.asset.meta b/Assets/Resources/MegaSwordFactory.asset.meta index 8f07808..8238c71 100644 --- a/Assets/Resources/MegaSwordFactory.asset.meta +++ b/Assets/Resources/MegaSwordFactory.asset.meta @@ -2,7 +2,7 @@ fileFormatVersion: 2 guid: 99965d8d09fad704fb867941e17eec1a NativeFormatImporter: externalObjects: {} - mainObjectFileID: 11400000 + mainObjectFileID: 0 userData: assetBundleName: assetBundleVariant: diff --git a/Assets/Resources/NoobSwordFactory.asset b/Assets/Resources/NoobSwordFactory.asset index 3b19aea..4335b7a 100644 --- a/Assets/Resources/NoobSwordFactory.asset +++ b/Assets/Resources/NoobSwordFactory.asset @@ -9,7 +9,7 @@ MonoBehaviour: m_GameObject: {fileID: 0} m_Enabled: 1 m_EditorHideFlags: 0 - m_Script: {fileID: 0} + m_Script: {fileID: 11500000, guid: ea9644082b1c77a44849c5b6af28eb4f, type: 3} m_Name: NoobSwordFactory m_EditorClassIdentifier: SAShop::ProceduralWeaponFactory Rarity: 16777215 diff --git a/Assets/Resources/NoobSwordFactory.asset.meta b/Assets/Resources/NoobSwordFactory.asset.meta index 4e26b53..c5858e9 100644 --- a/Assets/Resources/NoobSwordFactory.asset.meta +++ b/Assets/Resources/NoobSwordFactory.asset.meta @@ -2,7 +2,7 @@ fileFormatVersion: 2 guid: 36357d288f5e56f4e91c809ea7909f67 NativeFormatImporter: externalObjects: {} - mainObjectFileID: 11400000 + mainObjectFileID: 0 userData: assetBundleName: assetBundleVariant: diff --git a/Assets/Resources/ProSwordFactory.asset b/Assets/Resources/ProSwordFactory.asset index 92f4587..d5436f2 100644 --- a/Assets/Resources/ProSwordFactory.asset +++ b/Assets/Resources/ProSwordFactory.asset @@ -9,7 +9,7 @@ MonoBehaviour: m_GameObject: {fileID: 0} m_Enabled: 1 m_EditorHideFlags: 0 - m_Script: {fileID: 0} + m_Script: {fileID: 11500000, guid: ea9644082b1c77a44849c5b6af28eb4f, type: 3} m_Name: ProSwordFactory m_EditorClassIdentifier: SAShop::ProceduralWeaponFactory Rarity: 255 diff --git a/Assets/Resources/ProSwordFactory.asset.meta b/Assets/Resources/ProSwordFactory.asset.meta index 10251c0..f1aeda8 100644 --- a/Assets/Resources/ProSwordFactory.asset.meta +++ b/Assets/Resources/ProSwordFactory.asset.meta @@ -2,7 +2,7 @@ fileFormatVersion: 2 guid: 74b8070851d98094dbbaa907e8a7648d NativeFormatImporter: externalObjects: {} - mainObjectFileID: 11400000 + mainObjectFileID: 0 userData: assetBundleName: assetBundleVariant: diff --git a/Assets/Resources/RareArmorFactory.asset b/Assets/Resources/RareArmorFactory.asset new file mode 100644 index 0000000..578e739 --- /dev/null +++ b/Assets/Resources/RareArmorFactory.asset @@ -0,0 +1,36 @@ +%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: ebeacc5773329254488339277dadfae7, type: 3} + m_Name: RareArmorFactory + m_EditorClassIdentifier: + Rarity: 65280 + DefenseMin: 25 + DefenseMax: 40 + PriceMin: 3500 + PriceMax: 6000 + Items: + - Sprite: {fileID: 117214147892069551, guid: b00993d063fbc4a87983115070f6145c, type: 3} + Name: Steel Gloves + Description: Very difficult to craft, therefore very rare, but immensely helpful + in combat. + Bonus: 2 + - Sprite: {fileID: -5703758344047898144, guid: b00993d063fbc4a87983115070f6145c, + type: 3} + Name: Steel Chestplate + Description: Name checks out + Bonus: 8 + - Sprite: {fileID: -7905648789407400134, guid: b00993d063fbc4a87983115070f6145c, + type: 3} + Name: Strong Leather Chestplate + Description: This reinforced leather chestplate is extremely strong, yet mobile. + Bonus: 1 + Amount: 2 diff --git a/Assets/Resources/RareArmorFactory.asset.meta b/Assets/Resources/RareArmorFactory.asset.meta new file mode 100644 index 0000000..d10ea8b --- /dev/null +++ b/Assets/Resources/RareArmorFactory.asset.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 0480ad1a4fb45e544944b8a42a6ef541 +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 11400000 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Resources/ShopArmorFactory.asset b/Assets/Resources/ShopArmorFactory.asset new file mode 100644 index 0000000..dea336d --- /dev/null +++ b/Assets/Resources/ShopArmorFactory.asset @@ -0,0 +1,18 @@ +%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: be184c10b845d1044abbc1c356837cac, type: 3} + m_Name: ShopArmorFactory + m_EditorClassIdentifier: + ItemFactories: + - {fileID: 11400000, guid: a99cf577f5b2a5a4bbf949e8732bb406, type: 2} + - {fileID: 11400000, guid: d951ed0254060cf448168db909dc407c, type: 2} + - {fileID: 11400000, guid: 0480ad1a4fb45e544944b8a42a6ef541, type: 2} diff --git a/Assets/Resources/ShopArmorFactory.asset.meta b/Assets/Resources/ShopArmorFactory.asset.meta new file mode 100644 index 0000000..453e308 --- /dev/null +++ b/Assets/Resources/ShopArmorFactory.asset.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 5577191489773c24f95b649170284aa4 +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 11400000 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scenes/NewShop.unity b/Assets/Scenes/NewShop.unity index a372308..23b2798 100644 --- a/Assets/Scenes/NewShop.unity +++ b/Assets/Scenes/NewShop.unity @@ -427,7 +427,7 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: be8c4b332c72a3c4b85013b334ebde3a, type: 3} m_Name: m_EditorClassIdentifier: - factory: {fileID: 11400000, guid: ed86667a8c8440d489527401f6ada6b7, type: 2} + factory: {fileID: 11400000, guid: b75166a8b7cdac24d9a9d1cd0edf4a15, type: 2} shop: {fileID: 11400000, guid: 366ca79a0c4a2df4fac53ddd28f65f1a, type: 2} --- !u!1 &180905778 GameObject: @@ -771,9 +771,9 @@ RectTransform: m_Father: {fileID: 274071969} m_RootOrder: 0 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} - m_AnchorMin: {x: 0, y: 0} - m_AnchorMax: {x: 0, y: 0} - m_AnchoredPosition: {x: 0, y: 0} + m_AnchorMin: {x: 0, y: 1} + m_AnchorMax: {x: 0, y: 1} + m_AnchoredPosition: {x: 466.68445, y: -24.63433} m_SizeDelta: {x: 933.3689, y: 49.26866} m_Pivot: {x: 0.5, y: 0.5} --- !u!114 &240970668 @@ -870,9 +870,9 @@ RectTransform: m_Father: {fileID: 849412833} m_RootOrder: 0 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} - m_AnchorMin: {x: 0, y: 1} - m_AnchorMax: {x: 0, y: 1} - m_AnchoredPosition: {x: 58.397293, y: -20} + m_AnchorMin: {x: 0, y: 0} + m_AnchorMax: {x: 0, y: 0} + m_AnchoredPosition: {x: 0, y: 0} m_SizeDelta: {x: 116.794586, y: 38.03768} m_Pivot: {x: 0.5, y: 0.5} --- !u!114 &242976726 @@ -2239,9 +2239,9 @@ RectTransform: m_Father: {fileID: 849412833} m_RootOrder: 1 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} - m_AnchorMin: {x: 0, y: 1} - m_AnchorMax: {x: 0, y: 1} - m_AnchoredPosition: {x: 136.79459, y: -20} + m_AnchorMin: {x: 0, y: 0} + m_AnchorMax: {x: 0, y: 0} + m_AnchoredPosition: {x: 0, y: 0} m_SizeDelta: {x: 20, y: 20} m_Pivot: {x: 0.5, y: 0.5} --- !u!114 &552208507 @@ -2389,9 +2389,9 @@ RectTransform: m_Father: {fileID: 779240604} m_RootOrder: 1 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} - m_AnchorMin: {x: 0, y: 0} - m_AnchorMax: {x: 0, y: 0} - m_AnchoredPosition: {x: 0, y: 0} + m_AnchorMin: {x: 0, y: 1} + m_AnchorMax: {x: 0, y: 1} + m_AnchoredPosition: {x: 136.79459, y: -20} m_SizeDelta: {x: 20, y: 20} m_Pivot: {x: 0.5, y: 0.5} --- !u!114 &591197038 @@ -2583,9 +2583,9 @@ RectTransform: m_Father: {fileID: 779240604} m_RootOrder: 2 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} - m_AnchorMin: {x: 0, y: 0} - m_AnchorMax: {x: 0, y: 0} - m_AnchoredPosition: {x: 0, y: 0} + m_AnchorMin: {x: 0, y: 1} + m_AnchorMax: {x: 0, y: 1} + m_AnchoredPosition: {x: 208.98698, y: -20} m_SizeDelta: {x: 104.384796, y: 40} m_Pivot: {x: 0.5, y: 0.5} --- !u!114 &741829286 @@ -2741,9 +2741,9 @@ RectTransform: m_Father: {fileID: 240970667} m_RootOrder: 4 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} - m_AnchorMin: {x: 0, y: 0} - m_AnchorMax: {x: 0, y: 0} - m_AnchoredPosition: {x: 0, y: 0} + m_AnchorMin: {x: 0, y: 1} + m_AnchorMax: {x: 0, y: 1} + m_AnchoredPosition: {x: 799.6245, y: -24.63433} m_SizeDelta: {x: 150, y: 40.22} m_Pivot: {x: 0.5, y: 0.5} --- !u!114 &777484100 @@ -3063,7 +3063,7 @@ GameObject: m_Icon: {fileID: 0} m_NavMeshLayer: 0 m_StaticEditorFlags: 0 - m_IsActive: 1 + m_IsActive: 0 --- !u!224 &822572996 RectTransform: m_ObjectHideFlags: 0 @@ -3465,9 +3465,9 @@ RectTransform: m_Father: {fileID: 240970667} m_RootOrder: 1 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} - m_AnchorMin: {x: 0, y: 0} - m_AnchorMax: {x: 0, y: 0} - m_AnchoredPosition: {x: 0, y: 0} + m_AnchorMin: {x: 0, y: 1} + m_AnchorMax: {x: 0, y: 1} + m_AnchoredPosition: {x: 199.62448, y: -24.63433} m_SizeDelta: {x: 150, y: 40.22} m_Pivot: {x: 0.5, y: 0.5} --- !u!114 &904235320 @@ -3931,9 +3931,9 @@ RectTransform: m_Father: {fileID: 779240604} m_RootOrder: 0 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} - m_AnchorMin: {x: 0, y: 0} - m_AnchorMax: {x: 0, y: 0} - m_AnchoredPosition: {x: 0, y: 0} + m_AnchorMin: {x: 0, y: 1} + m_AnchorMax: {x: 0, y: 1} + m_AnchoredPosition: {x: 58.397293, y: -20} m_SizeDelta: {x: 116.794586, y: 38.03768} m_Pivot: {x: 0.5, y: 0.5} --- !u!114 &1071789911 @@ -5859,9 +5859,9 @@ RectTransform: m_Father: {fileID: 240970667} m_RootOrder: 0 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} - m_AnchorMin: {x: 0, y: 0} - m_AnchorMax: {x: 0, y: 0} - m_AnchoredPosition: {x: 0, y: 0} + m_AnchorMin: {x: 0, y: 1} + m_AnchorMax: {x: 0, y: 1} + m_AnchoredPosition: {x: 42.31224, y: -24.63433} m_SizeDelta: {x: 64.62448, y: 40.22} m_Pivot: {x: 0.5, y: 0.5} --- !u!114 &1374344515 @@ -6894,9 +6894,9 @@ RectTransform: m_Father: {fileID: 240970667} m_RootOrder: 3 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} - m_AnchorMin: {x: 0, y: 0} - m_AnchorMax: {x: 0, y: 0} - m_AnchoredPosition: {x: 0, y: 0} + m_AnchorMin: {x: 0, y: 1} + m_AnchorMax: {x: 0, y: 1} + m_AnchoredPosition: {x: 599.6245, y: -24.63433} m_SizeDelta: {x: 150, y: 40.22} m_Pivot: {x: 0.5, y: 0.5} --- !u!114 &1701112578 @@ -7488,9 +7488,9 @@ RectTransform: m_Father: {fileID: 1424701243} m_RootOrder: 2 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} - m_AnchorMin: {x: 0, y: 1} - m_AnchorMax: {x: 0, y: 1} - m_AnchoredPosition: {x: 400, y: 0} + m_AnchorMin: {x: 0, y: 0} + m_AnchorMax: {x: 0, y: 0} + m_AnchoredPosition: {x: 0, y: 0} m_SizeDelta: {x: 160, y: 50} m_Pivot: {x: 0.5, y: 1} --- !u!114 &1763223519 @@ -7764,9 +7764,9 @@ RectTransform: m_Father: {fileID: 1424701243} m_RootOrder: 0 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} - m_AnchorMin: {x: 0, y: 1} - m_AnchorMax: {x: 0, y: 1} - m_AnchoredPosition: {x: 80, y: 0} + m_AnchorMin: {x: 0, y: 0} + m_AnchorMax: {x: 0, y: 0} + m_AnchoredPosition: {x: 0, y: 0} m_SizeDelta: {x: 160, y: 50} m_Pivot: {x: 0.5, y: 1} --- !u!114 &1779774928 @@ -8153,9 +8153,9 @@ RectTransform: m_Father: {fileID: 274071969} m_RootOrder: 1 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} - m_AnchorMin: {x: 0, y: 0} - m_AnchorMax: {x: 0, y: 0} - m_AnchoredPosition: {x: 0, y: 0} + m_AnchorMin: {x: 0, y: 1} + m_AnchorMax: {x: 0, y: 1} + m_AnchoredPosition: {x: 475, y: -49.26866} m_SizeDelta: {x: 950, y: 602} m_Pivot: {x: 0.5, y: 1} --- !u!114 &1865708447 @@ -8459,9 +8459,9 @@ RectTransform: m_Father: {fileID: 1424701243} m_RootOrder: 3 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} - m_AnchorMin: {x: 0, y: 1} - m_AnchorMax: {x: 0, y: 1} - m_AnchoredPosition: {x: 560, y: 0} + m_AnchorMin: {x: 0, y: 0} + m_AnchorMax: {x: 0, y: 0} + m_AnchoredPosition: {x: 0, y: 0} m_SizeDelta: {x: 160, y: 50} m_Pivot: {x: 0.5, y: 1} --- !u!114 &1918696018 @@ -8884,9 +8884,9 @@ RectTransform: m_Father: {fileID: 849412833} m_RootOrder: 2 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} - m_AnchorMin: {x: 0, y: 1} - m_AnchorMax: {x: 0, y: 1} - m_AnchoredPosition: {x: 208.98698, y: -20} + m_AnchorMin: {x: 0, y: 0} + m_AnchorMax: {x: 0, y: 0} + m_AnchoredPosition: {x: 0, y: 0} m_SizeDelta: {x: 104.384796, y: 40} m_Pivot: {x: 0.5, y: 0.5} --- !u!114 &1947464188 @@ -9042,9 +9042,9 @@ RectTransform: m_Father: {fileID: 240970667} m_RootOrder: 2 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} - m_AnchorMin: {x: 0, y: 0} - m_AnchorMax: {x: 0, y: 0} - m_AnchoredPosition: {x: 0, y: 0} + m_AnchorMin: {x: 0, y: 1} + m_AnchorMax: {x: 0, y: 1} + m_AnchoredPosition: {x: 399.62448, y: -24.63433} m_SizeDelta: {x: 150, y: 40.22} m_Pivot: {x: 0.5, y: 0.5} --- !u!114 &1966788905 @@ -9364,9 +9364,9 @@ RectTransform: m_Father: {fileID: 1424701243} m_RootOrder: 1 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} - m_AnchorMin: {x: 0, y: 1} - m_AnchorMax: {x: 0, y: 1} - m_AnchoredPosition: {x: 240, y: 0} + m_AnchorMin: {x: 0, y: 0} + m_AnchorMax: {x: 0, y: 0} + m_AnchoredPosition: {x: 0, y: 0} m_SizeDelta: {x: 160, y: 50} m_Pivot: {x: 0.5, y: 1} --- !u!114 &1982954963 @@ -9460,6 +9460,7 @@ GameObject: - component: {fileID: 2071906704} - component: {fileID: 2071906706} - component: {fileID: 2071906705} + - component: {fileID: 2071906707} m_Layer: 5 m_Name: ItemIcon m_TagString: Untagged @@ -9524,6 +9525,20 @@ CanvasRenderer: m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 2071906703} m_CullTransparentMesh: 0 +--- !u!114 &2071906707 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 2071906703} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 3061dcd664e618547bf8a20ebd8ff459, type: 3} + m_Name: + m_EditorClassIdentifier: + iconAtlas: {fileID: 4343727234628468602, guid: 61885a51c5dad46cd8f257139ddcc43a, + type: 2} --- !u!1 &2075705431 GameObject: m_ObjectHideFlags: 0 @@ -9718,7 +9733,7 @@ GameObject: m_Icon: {fileID: 0} m_NavMeshLayer: 0 m_StaticEditorFlags: 0 - m_IsActive: 0 + m_IsActive: 1 --- !u!224 &2131558511 RectTransform: m_ObjectHideFlags: 0 diff --git a/Assets/Scripts/Shop/Components/ItemIconDisplay.cs b/Assets/Scripts/Shop/Components/ItemIconDisplay.cs new file mode 100644 index 0000000..4bd4241 --- /dev/null +++ b/Assets/Scripts/Shop/Components/ItemIconDisplay.cs @@ -0,0 +1,29 @@ +using System; +using System.Collections; +using System.Collections.Generic; +using TMPro; +using UnityEngine; +using UnityEngine.U2D; +using UnityEngine.UI; + +/// +/// This class' only purpose is to set the price of a UI element +/// +[RequireComponent(typeof(Sprite))] +public class ItemIconDisplay : MonoBehaviour +{ + + [SerializeField] + protected SpriteAtlas iconAtlas; + private Image sprite; + private void Start() + { + sprite = GetComponent(); // Because of the meta tag, Unity will make sure this exists. No sanity checks + } + + public void SetIcon(string name) + { + if(sprite == null) sprite = GetComponent(); // Just in case this gets called before Start() + sprite.sprite = iconAtlas.GetSprite(name); + } +} diff --git a/Assets/Scripts/Shop/Components/ItemIconDisplay.cs.meta b/Assets/Scripts/Shop/Components/ItemIconDisplay.cs.meta new file mode 100644 index 0000000..365a549 --- /dev/null +++ b/Assets/Scripts/Shop/Components/ItemIconDisplay.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 3061dcd664e618547bf8a20ebd8ff459 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/Shop/Model/ItemArmor.cs b/Assets/Scripts/Shop/Model/ItemArmor.cs new file mode 100644 index 0000000..89df9cc --- /dev/null +++ b/Assets/Scripts/Shop/Model/ItemArmor.cs @@ -0,0 +1,25 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +public class ItemArmor : Item +{ + public readonly int Defense; + public readonly int Block; + public ItemArmor(string name, string iconName, int pbasePrice,int pDefense, int pBlock, string descr = "", ItemRarity rarity = ItemRarity.Common) : base(name, iconName, pbasePrice, descr,rarity) + { + Block = pBlock; + Defense = pDefense; + } + + // This is used so we can identify a type purely through polymorphism. No hardcoding of types involved, nothing to see here! + public override ItemType GetItemType() + { + return ItemType.Armor; + } + + public override string GetStats() + { + return "Defense: " + Defense + "\tBlock: " + Block; + } +} diff --git a/Assets/Scripts/Shop/Model/ItemArmor.cs.meta b/Assets/Scripts/Shop/Model/ItemArmor.cs.meta new file mode 100644 index 0000000..edc264a --- /dev/null +++ b/Assets/Scripts/Shop/Model/ItemArmor.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 62c7f34ec32965348bd59d6b53788d62 +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 index 2a002d6..96b79f2 100644 --- a/Assets/Scripts/Shop/Scriptable Objects/ItemFactory.cs +++ b/Assets/Scripts/Shop/Scriptable Objects/ItemFactory.cs @@ -1,6 +1,8 @@ using System.Collections; using System.Collections.Generic; using UnityEngine; +using UnityEngine.Serialization; + /// /// An item factory is simply meant to procedurally (or pre-scripted) populate a shop model. /// @@ -8,3 +10,13 @@ public abstract class ItemFactory : ScriptableObject { public abstract void PopulateModel(ShopModel model); } + +// 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 +[System.Serializable] +public struct ItemPrototype +{ + public Sprite Sprite; + public string Name; + public string Description; + [FormerlySerializedAs("AttackBonus")] public int Bonus; // FormerlySerializedAs so we don't have to reassign from when it was only used for weapons. Compatibility, yay! +} diff --git a/Assets/Scripts/Shop/Scriptable Objects/ProceduralArmorFactory.cs b/Assets/Scripts/Shop/Scriptable Objects/ProceduralArmorFactory.cs new file mode 100644 index 0000000..104a54d --- /dev/null +++ b/Assets/Scripts/Shop/Scriptable Objects/ProceduralArmorFactory.cs @@ -0,0 +1,29 @@ +using System; +using System.Collections; +using System.Collections.Generic; +using UnityEngine; +using Random = UnityEngine.Random; + +/// +/// This item factory uses all specified properties to procedurally generate a given amount of items. In this case, armor +/// +[CreateAssetMenu]//Allows creating ViewConfig objects in Assets -> Create menu in the Unity Editor +public class ProceduralArmorFactory : ItemFactory +{ + public ItemRarity Rarity; + public int DefenseMin; + public int DefenseMax; + public int PriceMin; + public int PriceMax; + public ItemPrototype[] Items; + public int Amount; + + public override void PopulateModel(ShopModel model) + { + for (int i = 0; i < Amount; i++) + { + 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)); + } + } +} \ No newline at end of file diff --git a/Assets/Scripts/Shop/Scriptable Objects/ProceduralArmorFactory.cs.meta b/Assets/Scripts/Shop/Scriptable Objects/ProceduralArmorFactory.cs.meta new file mode 100644 index 0000000..cf4881b --- /dev/null +++ b/Assets/Scripts/Shop/Scriptable Objects/ProceduralArmorFactory.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: ebeacc5773329254488339277dadfae7 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/Shop/Scriptable Objects/ProceduralItemFactory.cs b/Assets/Scripts/Shop/Scriptable Objects/ProceduralWeaponFactory.cs similarity index 59% rename from Assets/Scripts/Shop/Scriptable Objects/ProceduralItemFactory.cs rename to Assets/Scripts/Shop/Scriptable Objects/ProceduralWeaponFactory.cs index c080cec..7d898b6 100644 --- a/Assets/Scripts/Shop/Scriptable Objects/ProceduralItemFactory.cs +++ b/Assets/Scripts/Shop/Scriptable Objects/ProceduralWeaponFactory.cs @@ -5,7 +5,7 @@ using UnityEngine; using Random = UnityEngine.Random; /// -/// This item factory literally just takes a handcrafted list of items and populates the model with that! +/// This item factory uses all specified properties to procedurally generate a given amount of items. In this case, weapons /// [CreateAssetMenu]//Allows creating ViewConfig objects in Assets -> Create menu in the Unity Editor public class ProceduralWeaponFactory : ItemFactory @@ -23,17 +23,7 @@ public class ProceduralWeaponFactory : ItemFactory for (int i = 0; i < Amount; i++) { 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.AttackBonus,Random.Range(DamageMin,DamageMax) + item.AttackBonus + 3,item.Description, Rarity)); + 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)); } } -} - -// 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 -[System.Serializable] -public struct ItemPrototype -{ - public Sprite Sprite; - public string Name; - public string Description; - public int AttackBonus; -} +} \ No newline at end of file diff --git a/Assets/Scripts/Shop/Scriptable Objects/ProceduralItemFactory.cs.meta b/Assets/Scripts/Shop/Scriptable Objects/ProceduralWeaponFactory.cs.meta similarity index 100% rename from Assets/Scripts/Shop/Scriptable Objects/ProceduralItemFactory.cs.meta rename to Assets/Scripts/Shop/Scriptable Objects/ProceduralWeaponFactory.cs.meta diff --git a/Assets/Scripts/Shop/Scriptable Objects/ScriptedArmor.cs b/Assets/Scripts/Shop/Scriptable Objects/ScriptedArmor.cs new file mode 100644 index 0000000..658a0c6 --- /dev/null +++ b/Assets/Scripts/Shop/Scriptable Objects/ScriptedArmor.cs @@ -0,0 +1,16 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; +/// +/// The scripted armor generates armor with the specified defense +/// +[CreateAssetMenu]//Allows creating ViewConfig objects in Assets -> Create menu in the Unity Editor +public class ScriptedArmor : ScriptedItem +{ + public int Defense; + public int Block; + public override Item GenerateItem() + { + return new ItemArmor(Name, Sprite.name, Price, Defense, Block,Description,Rarity); + } +} diff --git a/Assets/Scripts/Shop/Scriptable Objects/ScriptedArmor.cs.meta b/Assets/Scripts/Shop/Scriptable Objects/ScriptedArmor.cs.meta new file mode 100644 index 0000000..a4af763 --- /dev/null +++ b/Assets/Scripts/Shop/Scriptable Objects/ScriptedArmor.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 6e5b03c031ce21c43b42e368b0dd68bc +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/Shop/View/ShopViewGrid.cs b/Assets/Scripts/Shop/View/ShopViewGrid.cs index 3d865ff..39935b1 100644 --- a/Assets/Scripts/Shop/View/ShopViewGrid.cs +++ b/Assets/Scripts/Shop/View/ShopViewGrid.cs @@ -51,7 +51,7 @@ public class ShopViewGrid : ShopView //bool isSelected = (item == model.GetSelectedItem()); var unsub = model.RegisterObserver(itemContainer); itemContainer.Initialize(item,unsub); - print("Attempt to add item " + item.name + " to view"); + //print("Attempt to add item " + item.name + " to view"); } protected override void RemoveItemFromView(Item item) diff --git a/Assets/Scripts/Shop/View/ShopViewList.cs b/Assets/Scripts/Shop/View/ShopViewList.cs index 7cb226f..982cba1 100644 --- a/Assets/Scripts/Shop/View/ShopViewList.cs +++ b/Assets/Scripts/Shop/View/ShopViewList.cs @@ -2,6 +2,7 @@ using System.Collections; using System.Collections.Generic; using System.Security.Permissions; +using UnityEditor; using UnityEngine; using UnityEngine.Assertions; using UnityEngine.UI; @@ -59,7 +60,7 @@ public class ShopViewList : ShopView, IShopModelObserver //bool isSelected = (item == model.GetSelectedItem()); var unsub = model.RegisterObserver(itemContainer); itemContainer.Initialize(item,unsub); - print("Attempt to add item " + item.name + " to view"); + //print("Attempt to add item " + item.name + " to view"); } protected override void RemoveItemFromView(Item item) diff --git a/Assets/Scripts/Shop/View/ViewItemInfoPanel.cs b/Assets/Scripts/Shop/View/ViewItemInfoPanel.cs index b572e49..03c23ef 100644 --- a/Assets/Scripts/Shop/View/ViewItemInfoPanel.cs +++ b/Assets/Scripts/Shop/View/ViewItemInfoPanel.cs @@ -17,6 +17,7 @@ public class ViewItemInfoPanel : MonoBehaviour private List prices; private List descr; private List rarity; + private List icons; private void Awake() { UpdateComponentInfo(); @@ -31,6 +32,7 @@ public class ViewItemInfoPanel : MonoBehaviour prices = GetComponentsInChildren().ToList(); descr = GetComponentsInChildren().ToList(); rarity = GetComponentsInChildren().ToList(); + icons = GetComponentsInChildren().ToList(); //if (names == null) names = ; // TODO: Create and add all other types in here as components! } @@ -74,5 +76,10 @@ public class ViewItemInfoPanel : MonoBehaviour { itemClass.SetClass(item.rarity); } + + foreach (var icon in icons) + { + icon.SetIcon(item.iconName); + } } }