Browse Source

Add Potions

Devin Braune 5 years ago
parent
commit
92bfd5635e
  1. 1
      Assets/Resources/AllItemsFactory.asset
  2. 42
      Assets/Resources/GoodPotionFactory.asset
  3. 8
      Assets/Resources/GoodPotionFactory.asset.meta
  4. 18
      Assets/Resources/PotionsFactory.asset
  5. 8
      Assets/Resources/PotionsFactory.asset.meta
  6. 42
      Assets/Resources/RegularPotionFactory.asset
  7. 8
      Assets/Resources/RegularPotionFactory.asset.meta
  8. 42
      Assets/Resources/SuperPotionFactory.asset
  9. 8
      Assets/Resources/SuperPotionFactory.asset.meta
  10. 38
      Assets/Scripts/Shop/Model/ItemPotion.cs
  11. 11
      Assets/Scripts/Shop/Model/ItemPotion.cs.meta
  12. 39
      Assets/Scripts/Shop/Scriptable Objects/ProceduralPotionFactory.cs
  13. 11
      Assets/Scripts/Shop/Scriptable Objects/ProceduralPotionFactory.cs.meta

1
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}

42
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

8
Assets/Resources/GoodPotionFactory.asset.meta

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

18
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}

8
Assets/Resources/PotionsFactory.asset.meta

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

42
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

8
Assets/Resources/RegularPotionFactory.asset.meta

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

42
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

8
Assets/Resources/SuperPotionFactory.asset.meta

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

38
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
}

11
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:

39
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;
/// <summary>
/// This item factory uses all specified properties to procedurally generate a given amount of items. In this case, potion
/// </summary>
[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;
}

11
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:
Loading…
Cancel
Save