MVC shop project for software architecture, in Unity.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

39 lines
1.2 KiB

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