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.
 
 
 

54 lines
1.9 KiB

using UnityEditor.Graphs;
using UnityEngine;
/// <summary>
/// This class holds data for an Item. Currently it has a name, an iconName and a base price.
/// </summary>
public abstract class Item
{
public readonly string name;
public readonly string iconName;
public readonly string description;
public readonly ItemRarity rarity;
public int basePrice { get; private set; } // This is the base price for the item, the buying and selling prices can be
// generated based on this value.
//------------------------------------------------------------------------------------------------------------------------
// Item()
//------------------------------------------------------------------------------------------------------------------------
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;
this.rarity = rarity;
}
// This is supposed to return what type an item identifies as, purely used for filtering
public abstract ItemType GetItemType();
// Returns a nicely formatted text about the item's stats. Implementation-specific, because different types of items generate these differently
public abstract string GetStats();
}
/// <summary>
/// Item type, mostly used as an identifier for item filters
/// </summary>
public enum ItemType
{
Weapon,
Armor,
Potion
}
[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 = 0xFFFFFF,
Uncommon = 0x0000FF,
Rare = 0x00FF00,
Legendary = 0xFF00FF,
Unique = 0xFFFF00
}