13 changed files with 276 additions and 0 deletions
@ -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 |
||||
@ -0,0 +1,8 @@ |
|||||
|
fileFormatVersion: 2 |
||||
|
guid: 1177a0e378fd53d4f9550eb487d2d6f0 |
||||
|
NativeFormatImporter: |
||||
|
externalObjects: {} |
||||
|
mainObjectFileID: 11400000 |
||||
|
userData: |
||||
|
assetBundleName: |
||||
|
assetBundleVariant: |
||||
@ -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} |
||||
@ -0,0 +1,8 @@ |
|||||
|
fileFormatVersion: 2 |
||||
|
guid: 2ccd0c53b3ac2524296b31dbc4e0c986 |
||||
|
NativeFormatImporter: |
||||
|
externalObjects: {} |
||||
|
mainObjectFileID: 11400000 |
||||
|
userData: |
||||
|
assetBundleName: |
||||
|
assetBundleVariant: |
||||
@ -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 |
||||
@ -0,0 +1,8 @@ |
|||||
|
fileFormatVersion: 2 |
||||
|
guid: af3c28200c82f3a488c34bf80111980c |
||||
|
NativeFormatImporter: |
||||
|
externalObjects: {} |
||||
|
mainObjectFileID: 11400000 |
||||
|
userData: |
||||
|
assetBundleName: |
||||
|
assetBundleVariant: |
||||
@ -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 |
||||
@ -0,0 +1,8 @@ |
|||||
|
fileFormatVersion: 2 |
||||
|
guid: 3cdcd224e54a3a7498ac46f9629b8bbf |
||||
|
NativeFormatImporter: |
||||
|
externalObjects: {} |
||||
|
mainObjectFileID: 11400000 |
||||
|
userData: |
||||
|
assetBundleName: |
||||
|
assetBundleVariant: |
||||
@ -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 |
||||
|
} |
||||
@ -0,0 +1,11 @@ |
|||||
|
fileFormatVersion: 2 |
||||
|
guid: dc3d06499fcb8e144a0e4c1b92475eab |
||||
|
MonoImporter: |
||||
|
externalObjects: {} |
||||
|
serializedVersion: 2 |
||||
|
defaultReferences: [] |
||||
|
executionOrder: 0 |
||||
|
icon: {instanceID: 0} |
||||
|
userData: |
||||
|
assetBundleName: |
||||
|
assetBundleVariant: |
||||
@ -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; |
||||
|
} |
||||
@ -0,0 +1,11 @@ |
|||||
|
fileFormatVersion: 2 |
||||
|
guid: a9f6be742ec356945a9f8dbb5d330210 |
||||
|
MonoImporter: |
||||
|
externalObjects: {} |
||||
|
serializedVersion: 2 |
||||
|
defaultReferences: [] |
||||
|
executionOrder: 0 |
||||
|
icon: {instanceID: 0} |
||||
|
userData: |
||||
|
assetBundleName: |
||||
|
assetBundleVariant: |
||||
Loading…
Reference in new issue