From ac9cad3b6b6b95808e14db6fcc508cc4485726ff Mon Sep 17 00:00:00 2001 From: Devin Braune Date: Wed, 3 Feb 2021 03:21:57 +0100 Subject: [PATCH] Add combined procedural and unique item factory to shop --- Assets/Prefabs/GridViewItem.prefab | 10 ++-- Assets/Resources/GigaSwordFactory.asset | 38 +++++++++++++++ Assets/Resources/GigaSwordFactory.asset.meta | 8 ++++ Assets/Resources/MegaSwordFactory.asset | 37 +++++++++++++++ Assets/Resources/MegaSwordFactory.asset.meta | 8 ++++ Assets/Resources/NoobSwordFactory.asset | 47 +++++++++++++++++++ Assets/Resources/NoobSwordFactory.asset.meta | 8 ++++ Assets/Resources/ProSwordFactory.asset | 39 +++++++++++++++ Assets/Resources/ProSwordFactory.asset.meta | 8 ++++ .../Resources/ScriptedItems/ActualSword.asset | 1 + .../Resources/ScriptedItems/DualBlade.asset | 22 +++++++++ .../ScriptedItems/DualBlade.asset.meta | 8 ++++ .../ScriptedItems/ImperialJapan.asset | 22 +++++++++ .../ScriptedItems/ImperialJapan.asset.meta | 8 ++++ Assets/Resources/ShopWeaponFactory.asset | 20 ++++++++ Assets/Resources/ShopWeaponFactory.asset.meta | 8 ++++ Assets/Resources/UniqueItems.asset | 17 +++++++ Assets/Resources/UniqueItems.asset.meta | 8 ++++ Assets/Scenes/NewShop.unity | 8 ++-- .../Shop/Components/ItemClassDisplay.cs | 3 +- Assets/Scripts/Shop/Model/Item.cs | 18 +++---- Assets/Scripts/Shop/Model/ItemWeapon.cs | 2 +- .../Scriptable Objects/MultiItemFactory.cs | 19 ++++++++ .../MultiItemFactory.cs.meta | 11 +++++ .../ProceduralItemFactory.cs | 39 +++++++++++++++ .../ProceduralItemFactory.cs.meta | 11 +++++ .../Shop/Scriptable Objects/ScriptedItem.cs | 1 + .../Shop/Scriptable Objects/ScriptedWeapon.cs | 2 +- 28 files changed, 410 insertions(+), 21 deletions(-) create mode 100644 Assets/Resources/GigaSwordFactory.asset create mode 100644 Assets/Resources/GigaSwordFactory.asset.meta create mode 100644 Assets/Resources/MegaSwordFactory.asset create mode 100644 Assets/Resources/MegaSwordFactory.asset.meta create mode 100644 Assets/Resources/NoobSwordFactory.asset create mode 100644 Assets/Resources/NoobSwordFactory.asset.meta create mode 100644 Assets/Resources/ProSwordFactory.asset create mode 100644 Assets/Resources/ProSwordFactory.asset.meta create mode 100644 Assets/Resources/ScriptedItems/DualBlade.asset create mode 100644 Assets/Resources/ScriptedItems/DualBlade.asset.meta create mode 100644 Assets/Resources/ScriptedItems/ImperialJapan.asset create mode 100644 Assets/Resources/ScriptedItems/ImperialJapan.asset.meta create mode 100644 Assets/Resources/ShopWeaponFactory.asset create mode 100644 Assets/Resources/ShopWeaponFactory.asset.meta create mode 100644 Assets/Resources/UniqueItems.asset create mode 100644 Assets/Resources/UniqueItems.asset.meta create mode 100644 Assets/Scripts/Shop/Scriptable Objects/MultiItemFactory.cs create mode 100644 Assets/Scripts/Shop/Scriptable Objects/MultiItemFactory.cs.meta create mode 100644 Assets/Scripts/Shop/Scriptable Objects/ProceduralItemFactory.cs create mode 100644 Assets/Scripts/Shop/Scriptable Objects/ProceduralItemFactory.cs.meta diff --git a/Assets/Prefabs/GridViewItem.prefab b/Assets/Prefabs/GridViewItem.prefab index 69851c0..6cd5cce 100644 --- a/Assets/Prefabs/GridViewItem.prefab +++ b/Assets/Prefabs/GridViewItem.prefab @@ -662,7 +662,7 @@ GameObject: m_Icon: {fileID: 0} m_NavMeshLayer: 0 m_StaticEditorFlags: 0 - m_IsActive: 1 + m_IsActive: 0 --- !u!224 &7781414650624386517 RectTransform: m_ObjectHideFlags: 0 @@ -677,9 +677,9 @@ RectTransform: m_Father: {fileID: 2236248579476745813} 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: 100, y: -25} m_SizeDelta: {x: 200, y: 50} m_Pivot: {x: 0.5, y: 0.5} --- !u!222 &6575481395058307399 @@ -1527,7 +1527,7 @@ RectTransform: m_AnchorMin: {x: 0, y: 0} m_AnchorMax: {x: 0, y: 0} m_AnchoredPosition: {x: 0, y: 0} - m_SizeDelta: {x: 200, y: 125} + m_SizeDelta: {x: 200, y: 85.52164} m_Pivot: {x: 0.5, y: 1} --- !u!222 &644337133234863296 CanvasRenderer: diff --git a/Assets/Resources/GigaSwordFactory.asset b/Assets/Resources/GigaSwordFactory.asset new file mode 100644 index 0000000..ddcd648 --- /dev/null +++ b/Assets/Resources/GigaSwordFactory.asset @@ -0,0 +1,38 @@ +%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: GigaSwordFactory + m_EditorClassIdentifier: SAShop::ProceduralWeaponFactory + Rarity: 16711935 + DamageMin: 40 + DamageMax: 60 + PriceMin: 4500 + PriceMax: 8000 + Items: + - Sprite: {fileID: -4016013334462737405, guid: b00993d063fbc4a87983115070f6145c, + type: 3} + Name: Giga-Axe + Description: This battle axe is two-sided and huge. While only the most skilled + heroes can master it, their foes are going to have a bad time. + AttackBonus: 5 + - Sprite: {fileID: -5362799649635832982, guid: b00993d063fbc4a87983115070f6145c, + type: 3} + Name: Falcon Punch + Description: Who needs a weapon when you can just falcon punch people? + AttackBonus: 12 + - Sprite: {fileID: 5947598201806246533, guid: b00993d063fbc4a87983115070f6145c, + type: 3} + Name: Electric Blade + Description: This sword is electrically charged and will deal massive damage + to anything it hits. + AttackBonus: 7 + Amount: 2 diff --git a/Assets/Resources/GigaSwordFactory.asset.meta b/Assets/Resources/GigaSwordFactory.asset.meta new file mode 100644 index 0000000..f882fce --- /dev/null +++ b/Assets/Resources/GigaSwordFactory.asset.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 7e20569483b8ce942a78031bd0b0121c +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 11400000 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Resources/MegaSwordFactory.asset b/Assets/Resources/MegaSwordFactory.asset new file mode 100644 index 0000000..ce72f64 --- /dev/null +++ b/Assets/Resources/MegaSwordFactory.asset @@ -0,0 +1,37 @@ +%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: MegaSwordFactory + m_EditorClassIdentifier: SAShop::ProceduralWeaponFactory + Rarity: 65280 + DamageMin: 20 + DamageMax: 25 + PriceMin: 800 + PriceMax: 2500 + Items: + - Sprite: {fileID: 3447626333678633045, guid: b00993d063fbc4a87983115070f6145c, + type: 3} + Name: Diamond Sword + Description: Blatant copyright infringement! + AttackBonus: 10 + - Sprite: {fileID: -7479063964076681684, guid: b00993d063fbc4a87983115070f6145c, + type: 3} + Name: Mace + Description: Not to be confused with Mace Windu, the jedi master! + AttackBonus: 5 + - Sprite: {fileID: 4292883687895924744, guid: b00993d063fbc4a87983115070f6145c, + type: 3} + Name: Stab Stick + Description: This weapon is quite rare, and quite difficult to use. But a hit + is sure to be fatal! + AttackBonus: 12 + Amount: 2 diff --git a/Assets/Resources/MegaSwordFactory.asset.meta b/Assets/Resources/MegaSwordFactory.asset.meta new file mode 100644 index 0000000..8f07808 --- /dev/null +++ b/Assets/Resources/MegaSwordFactory.asset.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 99965d8d09fad704fb867941e17eec1a +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 11400000 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Resources/NoobSwordFactory.asset b/Assets/Resources/NoobSwordFactory.asset new file mode 100644 index 0000000..3b19aea --- /dev/null +++ b/Assets/Resources/NoobSwordFactory.asset @@ -0,0 +1,47 @@ +%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: NoobSwordFactory + m_EditorClassIdentifier: SAShop::ProceduralWeaponFactory + Rarity: 16777215 + DamageMin: 2 + DamageMax: 7 + PriceMin: 50 + PriceMax: 120 + Items: + - Sprite: {fileID: -6229739577819397656, guid: b00993d063fbc4a87983115070f6145c, + type: 3} + Name: Wooden Sword + Description: This wooden sword is quite awful! + AttackBonus: 0 + - Sprite: {fileID: -4063295180217184869, guid: b00993d063fbc4a87983115070f6145c, + type: 3} + Name: Basic Sword + Description: A basic common sword, which is not particularly useful in battle, + but keeps you safe from wildlife. + AttackBonus: 2 + - Sprite: {fileID: -7651958066320933242, guid: b00993d063fbc4a87983115070f6145c, + type: 3} + Name: Weird Sword + Description: This sword is kind of weird. But it seems to do the job! + AttackBonus: 1 + - Sprite: {fileID: 206911327383899660, guid: b00993d063fbc4a87983115070f6145c, type: 3} + Name: Dagger + Description: Small dagger, easy to use and deadly, but with little range. + AttackBonus: 1 + - Sprite: {fileID: -8295029410813222302, guid: b00993d063fbc4a87983115070f6145c, + type: 3} + Name: Wood Axe + Description: This axe was built to chop down trees. Apparently it also chops + down your enemies! + AttackBonus: 3 + Amount: 4 diff --git a/Assets/Resources/NoobSwordFactory.asset.meta b/Assets/Resources/NoobSwordFactory.asset.meta new file mode 100644 index 0000000..4e26b53 --- /dev/null +++ b/Assets/Resources/NoobSwordFactory.asset.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 36357d288f5e56f4e91c809ea7909f67 +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 11400000 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Resources/ProSwordFactory.asset b/Assets/Resources/ProSwordFactory.asset new file mode 100644 index 0000000..92f4587 --- /dev/null +++ b/Assets/Resources/ProSwordFactory.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: 0} + m_Name: ProSwordFactory + m_EditorClassIdentifier: SAShop::ProceduralWeaponFactory + Rarity: 255 + DamageMin: 12 + DamageMax: 19 + PriceMin: 350 + PriceMax: 750 + Items: + - Sprite: {fileID: -5939302461621596088, guid: b00993d063fbc4a87983115070f6145c, + type: 3} + Name: Pirate Sword + Description: Pirates certainly know how to make swords. They may not slay a dragon, + but they are a safe bet for a battle. + AttackBonus: 2 + - Sprite: {fileID: -851246318378289833, guid: b00993d063fbc4a87983115070f6145c, + type: 3} + Name: Short Sword + Description: This sword looks very short, but when it actually connects with + its target, it has devastating consequences. + AttackBonus: 5 + - Sprite: {fileID: -5996106085844551684, guid: b00993d063fbc4a87983115070f6145c, + type: 3} + Name: Spike Club + Description: It may look primitive. But you certainly do not want to get hit + on the head by it! + AttackBonus: 0 + Amount: 3 diff --git a/Assets/Resources/ProSwordFactory.asset.meta b/Assets/Resources/ProSwordFactory.asset.meta new file mode 100644 index 0000000..10251c0 --- /dev/null +++ b/Assets/Resources/ProSwordFactory.asset.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 74b8070851d98094dbbaa907e8a7648d +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 11400000 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Resources/ScriptedItems/ActualSword.asset b/Assets/Resources/ScriptedItems/ActualSword.asset index 20b5fb4..d90e5ad 100644 --- a/Assets/Resources/ScriptedItems/ActualSword.asset +++ b/Assets/Resources/ScriptedItems/ActualSword.asset @@ -16,5 +16,6 @@ MonoBehaviour: Description: This sword is actually a sword though Sprite: {fileID: 3447626333678633045, guid: b00993d063fbc4a87983115070f6145c, type: 3} Price: 1000 + Rarity: 65280 Attack: 35 Damage: 45 diff --git a/Assets/Resources/ScriptedItems/DualBlade.asset b/Assets/Resources/ScriptedItems/DualBlade.asset new file mode 100644 index 0000000..d3df65b --- /dev/null +++ b/Assets/Resources/ScriptedItems/DualBlade.asset @@ -0,0 +1,22 @@ +%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: 1a6faf63d685386429bab9c581992b61, type: 3} + m_Name: DualBlade + m_EditorClassIdentifier: + Name: Dual Blade + Description: The legendary dual blade. Forged by the legendary legend himself. + It is so legendary that only the legend could wield it. + Sprite: {fileID: -1704500264438275045, guid: b00993d063fbc4a87983115070f6145c, type: 3} + Price: 50000 + Rarity: 16776960 + Attack: 350 + Damage: 420 diff --git a/Assets/Resources/ScriptedItems/DualBlade.asset.meta b/Assets/Resources/ScriptedItems/DualBlade.asset.meta new file mode 100644 index 0000000..0640441 --- /dev/null +++ b/Assets/Resources/ScriptedItems/DualBlade.asset.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 6219ccc5039acc1489e2da701bc93d82 +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 11400000 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Resources/ScriptedItems/ImperialJapan.asset b/Assets/Resources/ScriptedItems/ImperialJapan.asset new file mode 100644 index 0000000..3007e42 --- /dev/null +++ b/Assets/Resources/ScriptedItems/ImperialJapan.asset @@ -0,0 +1,22 @@ +%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: 1a6faf63d685386429bab9c581992b61, type: 3} + m_Name: ImperialJapan + m_EditorClassIdentifier: + Name: Imperial Japan + Description: Wielding Imperial Japan comes with great responsibility, but also + with great power! Although it is yellow for some reason. + Sprite: {fileID: -1083111729585998019, guid: b00993d063fbc4a87983115070f6145c, type: 3} + Price: 15000 + Rarity: 16776960 + Attack: 280 + Damage: 325 diff --git a/Assets/Resources/ScriptedItems/ImperialJapan.asset.meta b/Assets/Resources/ScriptedItems/ImperialJapan.asset.meta new file mode 100644 index 0000000..d411ce8 --- /dev/null +++ b/Assets/Resources/ScriptedItems/ImperialJapan.asset.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: cffb69fad9a3c914daa990daa78bcff4 +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 11400000 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Resources/ShopWeaponFactory.asset b/Assets/Resources/ShopWeaponFactory.asset new file mode 100644 index 0000000..550146a --- /dev/null +++ b/Assets/Resources/ShopWeaponFactory.asset @@ -0,0 +1,20 @@ +%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: ShopWeaponFactory + m_EditorClassIdentifier: + ItemFactories: + - {fileID: 11400000, guid: 36357d288f5e56f4e91c809ea7909f67, type: 2} + - {fileID: 11400000, guid: 74b8070851d98094dbbaa907e8a7648d, type: 2} + - {fileID: 11400000, guid: 99965d8d09fad704fb867941e17eec1a, type: 2} + - {fileID: 11400000, guid: 7e20569483b8ce942a78031bd0b0121c, type: 2} + - {fileID: 11400000, guid: c91975636a4024b46997f72b950e1977, type: 2} diff --git a/Assets/Resources/ShopWeaponFactory.asset.meta b/Assets/Resources/ShopWeaponFactory.asset.meta new file mode 100644 index 0000000..5c3684c --- /dev/null +++ b/Assets/Resources/ShopWeaponFactory.asset.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: ed86667a8c8440d489527401f6ada6b7 +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 11400000 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Resources/UniqueItems.asset b/Assets/Resources/UniqueItems.asset new file mode 100644 index 0000000..78aa004 --- /dev/null +++ b/Assets/Resources/UniqueItems.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: d4a440686e1eaa042a9d58081a9b8dbe, type: 3} + m_Name: UniqueItems + m_EditorClassIdentifier: + Items: + - {fileID: 11400000, guid: cffb69fad9a3c914daa990daa78bcff4, type: 2} + - {fileID: 11400000, guid: 6219ccc5039acc1489e2da701bc93d82, type: 2} diff --git a/Assets/Resources/UniqueItems.asset.meta b/Assets/Resources/UniqueItems.asset.meta new file mode 100644 index 0000000..b074c4a --- /dev/null +++ b/Assets/Resources/UniqueItems.asset.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: c91975636a4024b46997f72b950e1977 +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 11400000 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scenes/NewShop.unity b/Assets/Scenes/NewShop.unity index 5ac4eb2..a372308 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: d16c0801001245545908f8b001145a3d, type: 2} + factory: {fileID: 11400000, guid: ed86667a8c8440d489527401f6ada6b7, type: 2} shop: {fileID: 11400000, guid: 366ca79a0c4a2df4fac53ddd28f65f1a, type: 2} --- !u!1 &180905778 GameObject: @@ -1131,7 +1131,7 @@ RectTransform: m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_AnchorMin: {x: 0, y: 1} m_AnchorMax: {x: 0, y: 1} - m_AnchoredPosition: {x: 150, y: -100} + m_AnchoredPosition: {x: 150, y: -0} m_SizeDelta: {x: 280, y: 150} m_Pivot: {x: 0.5, y: 1} --- !u!114 &317898841 @@ -8561,7 +8561,7 @@ GameObject: m_Icon: {fileID: 0} m_NavMeshLayer: 0 m_StaticEditorFlags: 0 - m_IsActive: 1 + m_IsActive: 0 --- !u!224 &1941898338 RectTransform: m_ObjectHideFlags: 0 @@ -9636,7 +9636,7 @@ RectTransform: m_AnchorMin: {x: 0, y: 1} m_AnchorMax: {x: 0, y: 1} m_AnchoredPosition: {x: 150, y: -150} - m_SizeDelta: {x: 300, y: 250} + m_SizeDelta: {x: 300, y: 121.803894} m_Pivot: {x: 0.5, y: 1} --- !u!114 &2106869074 MonoBehaviour: diff --git a/Assets/Scripts/Shop/Components/ItemClassDisplay.cs b/Assets/Scripts/Shop/Components/ItemClassDisplay.cs index a9b64be..f1c6315 100644 --- a/Assets/Scripts/Shop/Components/ItemClassDisplay.cs +++ b/Assets/Scripts/Shop/Components/ItemClassDisplay.cs @@ -20,6 +20,7 @@ public class ItemClassDisplay : MonoBehaviour { if(text == null) text = GetComponent(); // Just in case this gets called before Start() text.text = clas.ToString(); - text.color = new Color32((byte)((uint)clas >> 24), (byte)((uint)clas >> 16), (byte)((uint)clas >> 8), (byte)((uint)clas)); + //text.color = new Color32((byte)((uint)clas >> 24), (byte)((uint)clas >> 16), (byte)((uint)clas >> 8), (byte)((uint)clas)); + text.color = new Color32((byte)((int)clas >> 16), (byte)((int)clas >> 8), (byte)((int)clas), 0xFF); } } diff --git a/Assets/Scripts/Shop/Model/Item.cs b/Assets/Scripts/Shop/Model/Item.cs index 39bfc2c..4e157bb 100644 --- a/Assets/Scripts/Shop/Model/Item.cs +++ b/Assets/Scripts/Shop/Model/Item.cs @@ -17,13 +17,13 @@ public abstract class Item //------------------------------------------------------------------------------------------------------------------------ // Item() //------------------------------------------------------------------------------------------------------------------------ - public Item(string name, string iconName, int pbasePrice, string itemDescr = "") + public Item(string name, string iconName, int pbasePrice, string itemDescr = "", ItemRarity rarity = ItemRarity.Common) { this.name = name; this.iconName = iconName; this.basePrice = pbasePrice; description = itemDescr; - rarity = ItemRarity.UltraRare; + this.rarity = rarity; } // This is supposed to return what type an item identifies as, purely used for filtering @@ -42,13 +42,13 @@ public enum ItemType Armor, Potion } - -public enum ItemRarity : uint // Int representing color, so that this enum not only works as an identifier, but also contains name and col in just 32 bits. C#-Magic! +[System.Serializable] +public enum ItemRarity : int // Int representing color, so that this enum not only works as an identifier, but also contains name and col in just 32 bits. C#-Magic! { - Common = 0xFFFFFFFF, - Uncommon = 0xFFFF00FF, - Rare = 0xFF0000FF, - UltraRare = 0xFF00FFFF, - Unique = 0x00FF00FF + Common = 0xFFFFFF, + Uncommon = 0x0000FF, + Rare = 0x00FF00, + Legendary = 0xFF00FF, + Unique = 0xFFFF00 } diff --git a/Assets/Scripts/Shop/Model/ItemWeapon.cs b/Assets/Scripts/Shop/Model/ItemWeapon.cs index 76f7493..ab9dde1 100644 --- a/Assets/Scripts/Shop/Model/ItemWeapon.cs +++ b/Assets/Scripts/Shop/Model/ItemWeapon.cs @@ -6,7 +6,7 @@ public class ItemWeapon : Item { public readonly int Attack; public readonly int Damage; - public ItemWeapon(string name, string iconName, int pbasePrice,int pAttack, int pDamage, string descr = "") : base(name, iconName, pbasePrice, descr) + public ItemWeapon(string name, string iconName, int pbasePrice,int pAttack, int pDamage, string descr = "", ItemRarity rarity = ItemRarity.Common) : base(name, iconName, pbasePrice, descr,rarity) { Attack = pAttack; Damage = pDamage; diff --git a/Assets/Scripts/Shop/Scriptable Objects/MultiItemFactory.cs b/Assets/Scripts/Shop/Scriptable Objects/MultiItemFactory.cs new file mode 100644 index 0000000..71bfbb7 --- /dev/null +++ b/Assets/Scripts/Shop/Scriptable Objects/MultiItemFactory.cs @@ -0,0 +1,19 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; +/// +/// This is an item factory of item factories, simply put. Allows you to combine all sorts of factories to populate +/// just one inventory with different types and levels of items. +/// +[CreateAssetMenu]//Allows creating ViewConfig objects in Assets -> Create menu in the Unity Editor +public class MultiItemFactory : ItemFactory +{ + public ItemFactory[] ItemFactories; + public override void PopulateModel(ShopModel model) + { + foreach (var factory in ItemFactories) + { + factory.PopulateModel(model); + } + } +} diff --git a/Assets/Scripts/Shop/Scriptable Objects/MultiItemFactory.cs.meta b/Assets/Scripts/Shop/Scriptable Objects/MultiItemFactory.cs.meta new file mode 100644 index 0000000..e3f6675 --- /dev/null +++ b/Assets/Scripts/Shop/Scriptable Objects/MultiItemFactory.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: be184c10b845d1044abbc1c356837cac +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/ProceduralItemFactory.cs new file mode 100644 index 0000000..c080cec --- /dev/null +++ b/Assets/Scripts/Shop/Scriptable Objects/ProceduralItemFactory.cs @@ -0,0 +1,39 @@ +using System; +using System.Collections; +using System.Collections.Generic; +using UnityEngine; +using Random = UnityEngine.Random; + +/// +/// 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 ProceduralWeaponFactory : ItemFactory +{ + public ItemRarity Rarity; + public int DamageMin; + public int DamageMax; + 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 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)); + } + } +} + +// 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; +} diff --git a/Assets/Scripts/Shop/Scriptable Objects/ProceduralItemFactory.cs.meta b/Assets/Scripts/Shop/Scriptable Objects/ProceduralItemFactory.cs.meta new file mode 100644 index 0000000..af22ac5 --- /dev/null +++ b/Assets/Scripts/Shop/Scriptable Objects/ProceduralItemFactory.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: ea9644082b1c77a44849c5b6af28eb4f +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 index eeca902..7207926 100644 --- a/Assets/Scripts/Shop/Scriptable Objects/ScriptedItem.cs +++ b/Assets/Scripts/Shop/Scriptable Objects/ScriptedItem.cs @@ -10,6 +10,7 @@ public abstract class ScriptedItem : ScriptableObject public string Description; public Sprite Sprite; public int Price; + public ItemRarity Rarity; public abstract Item GenerateItem(); } diff --git a/Assets/Scripts/Shop/Scriptable Objects/ScriptedWeapon.cs b/Assets/Scripts/Shop/Scriptable Objects/ScriptedWeapon.cs index 9cf98de..7d5dede 100644 --- a/Assets/Scripts/Shop/Scriptable Objects/ScriptedWeapon.cs +++ b/Assets/Scripts/Shop/Scriptable Objects/ScriptedWeapon.cs @@ -11,6 +11,6 @@ public class ScriptedWeapon : ScriptedItem public int Damage; public override Item GenerateItem() { - return new ItemWeapon(Name, Sprite.name, Price, Attack, Damage,Description); + return new ItemWeapon(Name, Sprite.name, Price, Attack, Damage,Description,Rarity); } }