From 92bfd5635ee046724f7e9f27789bce83e74f5e9d Mon Sep 17 00:00:00 2001 From: Devin Braune Date: Wed, 3 Feb 2021 21:31:44 +0100 Subject: [PATCH] Add Potions --- Assets/Resources/AllItemsFactory.asset | 1 + Assets/Resources/GoodPotionFactory.asset | 42 +++++++++++++++++++ Assets/Resources/GoodPotionFactory.asset.meta | 8 ++++ Assets/Resources/PotionsFactory.asset | 18 ++++++++ Assets/Resources/PotionsFactory.asset.meta | 8 ++++ Assets/Resources/RegularPotionFactory.asset | 42 +++++++++++++++++++ .../Resources/RegularPotionFactory.asset.meta | 8 ++++ Assets/Resources/SuperPotionFactory.asset | 42 +++++++++++++++++++ .../Resources/SuperPotionFactory.asset.meta | 8 ++++ Assets/Scripts/Shop/Model/ItemPotion.cs | 38 +++++++++++++++++ Assets/Scripts/Shop/Model/ItemPotion.cs.meta | 11 +++++ .../ProceduralPotionFactory.cs | 39 +++++++++++++++++ .../ProceduralPotionFactory.cs.meta | 11 +++++ 13 files changed, 276 insertions(+) create mode 100644 Assets/Resources/GoodPotionFactory.asset create mode 100644 Assets/Resources/GoodPotionFactory.asset.meta create mode 100644 Assets/Resources/PotionsFactory.asset create mode 100644 Assets/Resources/PotionsFactory.asset.meta create mode 100644 Assets/Resources/RegularPotionFactory.asset create mode 100644 Assets/Resources/RegularPotionFactory.asset.meta create mode 100644 Assets/Resources/SuperPotionFactory.asset create mode 100644 Assets/Resources/SuperPotionFactory.asset.meta create mode 100644 Assets/Scripts/Shop/Model/ItemPotion.cs create mode 100644 Assets/Scripts/Shop/Model/ItemPotion.cs.meta create mode 100644 Assets/Scripts/Shop/Scriptable Objects/ProceduralPotionFactory.cs create mode 100644 Assets/Scripts/Shop/Scriptable Objects/ProceduralPotionFactory.cs.meta diff --git a/Assets/Resources/AllItemsFactory.asset b/Assets/Resources/AllItemsFactory.asset index 1e2447e..55a9b85 100644 --- a/Assets/Resources/AllItemsFactory.asset +++ b/Assets/Resources/AllItemsFactory.asset @@ -15,3 +15,4 @@ MonoBehaviour: ItemFactories: - {fileID: 11400000, guid: ed86667a8c8440d489527401f6ada6b7, type: 2} - {fileID: 11400000, guid: 5577191489773c24f95b649170284aa4, type: 2} + - {fileID: 11400000, guid: 2ccd0c53b3ac2524296b31dbc4e0c986, type: 2} diff --git a/Assets/Resources/GoodPotionFactory.asset b/Assets/Resources/GoodPotionFactory.asset new file mode 100644 index 0000000..a1acd81 --- /dev/null +++ b/Assets/Resources/GoodPotionFactory.asset @@ -0,0 +1,42 @@ +%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: a9f6be742ec356945a9f8dbb5d330210, type: 3} + m_Name: GoodPotionFactory + m_EditorClassIdentifier: + Rarity: 255 + EffectMin: 12 + EffectMax: 20 + PriceMin: 250 + PriceMax: 300 + Items: + - Sprite: {fileID: 1533569245288039128, guid: b00993d063fbc4a87983115070f6145c, + type: 3} + Name: Health Potion+ + Description: Great instant healing effect. + Bonus: 5 + Type: 0 + EffectTime: 0 + - Sprite: {fileID: -3978551154961114089, guid: b00993d063fbc4a87983115070f6145c, + type: 3} + Name: Attack Potion+ + Description: Great temporary attack buff. + Bonus: 0 + Type: 1 + EffectTime: 180 + - Sprite: {fileID: 6720243606718852342, guid: b00993d063fbc4a87983115070f6145c, + type: 3} + Name: Defense Potion+ + Description: Great temporary defense buff. + Bonus: 0 + Type: 0 + EffectTime: 180 + Amount: 2 diff --git a/Assets/Resources/GoodPotionFactory.asset.meta b/Assets/Resources/GoodPotionFactory.asset.meta new file mode 100644 index 0000000..a11cc3a --- /dev/null +++ b/Assets/Resources/GoodPotionFactory.asset.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 1177a0e378fd53d4f9550eb487d2d6f0 +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 11400000 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Resources/PotionsFactory.asset b/Assets/Resources/PotionsFactory.asset new file mode 100644 index 0000000..50c1664 --- /dev/null +++ b/Assets/Resources/PotionsFactory.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: PotionsFactory + m_EditorClassIdentifier: + ItemFactories: + - {fileID: 11400000, guid: af3c28200c82f3a488c34bf80111980c, type: 2} + - {fileID: 11400000, guid: 1177a0e378fd53d4f9550eb487d2d6f0, type: 2} + - {fileID: 11400000, guid: 3cdcd224e54a3a7498ac46f9629b8bbf, type: 2} diff --git a/Assets/Resources/PotionsFactory.asset.meta b/Assets/Resources/PotionsFactory.asset.meta new file mode 100644 index 0000000..77222f7 --- /dev/null +++ b/Assets/Resources/PotionsFactory.asset.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 2ccd0c53b3ac2524296b31dbc4e0c986 +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 11400000 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Resources/RegularPotionFactory.asset b/Assets/Resources/RegularPotionFactory.asset new file mode 100644 index 0000000..2890b19 --- /dev/null +++ b/Assets/Resources/RegularPotionFactory.asset @@ -0,0 +1,42 @@ +%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: a9f6be742ec356945a9f8dbb5d330210, type: 3} + m_Name: RegularPotionFactory + m_EditorClassIdentifier: + Rarity: 16777215 + EffectMin: 4 + EffectMax: 12 + PriceMin: 50 + PriceMax: 150 + Items: + - Sprite: {fileID: -3930946897451993484, guid: b00993d063fbc4a87983115070f6145c, + type: 3} + Name: Health Potion + Description: Simple health potion. Instant effect. + Bonus: 0 + Type: 0 + EffectTime: 0 + - Sprite: {fileID: 1359165526104252653, guid: b00993d063fbc4a87983115070f6145c, + type: 3} + Name: Attack Potion + Description: Temporary Attack Buff. + Bonus: 1 + Type: 1 + EffectTime: 90 + - Sprite: {fileID: 9148803566423877661, guid: b00993d063fbc4a87983115070f6145c, + type: 3} + Name: Defense Potion + Description: Temporary Defense Buff. + Bonus: 0 + Type: 2 + EffectTime: 90 + Amount: 5 diff --git a/Assets/Resources/RegularPotionFactory.asset.meta b/Assets/Resources/RegularPotionFactory.asset.meta new file mode 100644 index 0000000..48c2128 --- /dev/null +++ b/Assets/Resources/RegularPotionFactory.asset.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: af3c28200c82f3a488c34bf80111980c +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 11400000 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Resources/SuperPotionFactory.asset b/Assets/Resources/SuperPotionFactory.asset new file mode 100644 index 0000000..2ba1b0d --- /dev/null +++ b/Assets/Resources/SuperPotionFactory.asset @@ -0,0 +1,42 @@ +%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: a9f6be742ec356945a9f8dbb5d330210, type: 3} + m_Name: SuperPotionFactory + m_EditorClassIdentifier: + Rarity: 65280 + EffectMin: 30 + EffectMax: 45 + PriceMin: 200 + PriceMax: 500 + Items: + - Sprite: {fileID: 1039740323736012158, guid: b00993d063fbc4a87983115070f6145c, + type: 3} + Name: Super Health Potion + Description: Huge instant healing. + Bonus: 5 + Type: 0 + EffectTime: 0 + - Sprite: {fileID: -8726926368370625433, guid: b00993d063fbc4a87983115070f6145c, + type: 3} + Name: Super Attack Potion + Description: Huge timed attack buff. + Bonus: 5 + Type: 0 + EffectTime: 240 + - Sprite: {fileID: -1067920246338498130, guid: b00993d063fbc4a87983115070f6145c, + type: 3} + Name: Super Defense Potion + Description: Huge timed defense buff. + Bonus: 5 + Type: 0 + EffectTime: 240 + Amount: 1 diff --git a/Assets/Resources/SuperPotionFactory.asset.meta b/Assets/Resources/SuperPotionFactory.asset.meta new file mode 100644 index 0000000..57b55d5 --- /dev/null +++ b/Assets/Resources/SuperPotionFactory.asset.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 3cdcd224e54a3a7498ac46f9629b8bbf +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 11400000 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/Shop/Model/ItemPotion.cs b/Assets/Scripts/Shop/Model/ItemPotion.cs new file mode 100644 index 0000000..46b3aad --- /dev/null +++ b/Assets/Scripts/Shop/Model/ItemPotion.cs @@ -0,0 +1,38 @@ +using System; +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +public class ItemPotion : Item +{ + public readonly int Effect; + public readonly PotionType Type; + public readonly int Time; // How long does this potion last? We don't have any use for it. Just here to demonstrate the item system + public ItemPotion(string name, string iconName, int pbasePrice,int effect, PotionType type, int time = -1, string descr = "", ItemRarity rarity = ItemRarity.Common) : base(name, iconName, pbasePrice, descr,rarity) + { + Effect = effect; + Type = type; + Time = Type == PotionType.Healing ? -1 : time; + } + + // 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.Potion; + } + + public override string GetStats() + { + return Time > 0 + ? "Strength: " + Effect + "\tType: " + Type + "\tTime: " + Time + : "Strength: " + Effect + "\tType: " + Type; + } +} + +[Serializable] +public enum PotionType +{ + Healing, + Attack, + Defense +} diff --git a/Assets/Scripts/Shop/Model/ItemPotion.cs.meta b/Assets/Scripts/Shop/Model/ItemPotion.cs.meta new file mode 100644 index 0000000..bc9e4ba --- /dev/null +++ b/Assets/Scripts/Shop/Model/ItemPotion.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: dc3d06499fcb8e144a0e4c1b92475eab +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/Shop/Scriptable Objects/ProceduralPotionFactory.cs b/Assets/Scripts/Shop/Scriptable Objects/ProceduralPotionFactory.cs new file mode 100644 index 0000000..3d64c04 --- /dev/null +++ b/Assets/Scripts/Shop/Scriptable Objects/ProceduralPotionFactory.cs @@ -0,0 +1,39 @@ +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, potion +/// +[CreateAssetMenu]//Allows creating ViewConfig objects in Assets -> Create menu in the Unity Editor +public class ProceduralPotionFactory : ItemFactory +{ + public ItemRarity Rarity; + public int EffectMin; + public int EffectMax; + public int PriceMin; + public int PriceMax; + public PotionPrototype[] 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 ItemPotion(item.Name,item.Sprite.name,Random.Range(PriceMin,PriceMax),item.EffectTime,item.Type,Random.Range(EffectMin,EffectMax) + item.Bonus + 3,item.Description, Rarity)); + } + } +} +[Serializable] +public struct PotionPrototype +{ + public Sprite Sprite; + public string Name; + public string Description; + public int Bonus; + public PotionType Type; + public int EffectTime; +} \ No newline at end of file diff --git a/Assets/Scripts/Shop/Scriptable Objects/ProceduralPotionFactory.cs.meta b/Assets/Scripts/Shop/Scriptable Objects/ProceduralPotionFactory.cs.meta new file mode 100644 index 0000000..fada271 --- /dev/null +++ b/Assets/Scripts/Shop/Scriptable Objects/ProceduralPotionFactory.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: a9f6be742ec356945a9f8dbb5d330210 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: