예제 #1
0
    public int maxNum;              //在同一个格子中能存储几个这个看了类型的物品

    public Item(int _id, string _name, ItemType _itemType, ItemQuality _itemQuality, ItemCareer _itemCareer, string _description, int _buyParice, int _sellPrice, string _sprite, int _maxNum)
    {
        this.id          = _id;
        this.name        = _name;
        this.itemType    = _itemType;
        this.itemQuality = _itemQuality;
        this.itemCareer  = _itemCareer;
        this.description = _description;
        this.buyPrice    = _buyParice;
        this.sellPrice   = _sellPrice;
        this.spritePath  = _sprite;
        this.maxNum      = _maxNum;
    }
예제 #2
0
    /// <summary>
    /// 根据id 和json的数据实例化item
    /// </summary>
    /// <param name="id"></param>
    /// <returns></returns>
    public Item GetItemObject(int id)
    {
        Item item = null;

        if (jsonDatasDic.Count == 0)
        {
            InitJsonMessage();
        }
        if (!jsonDatasDic.ContainsKey(id))
        {
            return(null);
        }
        JsonData    data        = jsonDatasDic[id];
        string      name        = data["name"].ToString();
        ItemType    itemType    = (ItemType)System.Enum.Parse(typeof(ItemType), data["itemType"].ToString());
        ItemQuality itemQuality = (ItemQuality)System.Enum.Parse(typeof(ItemQuality), data["itemQuality"].ToString());
        ItemCareer  itemCareer  = (ItemCareer)System.Enum.Parse(typeof(ItemCareer), data["itemCareer"].ToString());
        string      description = data["description"].ToString();
        int         buyPrice    = int.Parse(data["buyPrice"].ToString());
        int         sellPrice   = int.Parse(data["sellPrice"].ToString());
        string      spritePath  = data["spritePath"].ToString();
        int         maxNum      = int.Parse(data["maxNum"].ToString());

        switch (itemType)
        {
        case ItemType.Consumables:
            int hp = int.Parse(data["hp"].ToString());
            int mp = int.Parse(data["mp"].ToString());
            item = new Consumables(id, name, itemType, itemQuality, itemCareer, description, buyPrice, sellPrice, spritePath, maxNum, hp, mp);
            break;

        case ItemType.Equipment:
            int           defensivePower = int.Parse(data["defensivePower"].ToString());
            int           agility        = int.Parse(data["agility"].ToString());
            int           stamina        = int.Parse(data["stamina"].ToString());
            EquipmentType equipmentType  = (EquipmentType)System.Enum.Parse(typeof(EquipmentType), data["equipmentType"].ToString());
            item = new Equipment(id, name, itemType, itemQuality, itemCareer, description, buyPrice, sellPrice, spritePath, maxNum, defensivePower, agility, stamina, equipmentType);
            break;

        case ItemType.Weapon:
            int damage = int.Parse(data["damage"].ToString());
            item = new Weapon(id, name, itemType, itemQuality, itemCareer, description, buyPrice, sellPrice, spritePath, maxNum, damage);
            break;

        default:
            break;
        }
        return(item);
    }
예제 #3
0
    public int mp; //蓝量

    public Consumables(int _id, string _name, ItemType _itemType, ItemQuality _itemQuality, ItemCareer _itemCareer, string _description, int _buyParice, int _sellPrice, string _sprite,
                       int _maxNum, int _hp, int _mp) :
        base(_id, _name, _itemType, _itemQuality, _itemCareer, _description, _buyParice, _sellPrice, _sprite, _maxNum)
    {
        this.hp = _hp;
        this.mp = _mp;
    }
예제 #4
0
    public EquipmentType equipmentType; //装备的类型

    public Equipment(int _id, string _name, ItemType _itemType, ItemQuality _itemQuality, ItemCareer _itemCareer, string _description, int _buyParice, int _sellPrice, string _sprite, int _maxNum,
                     int _defensivePower, int _agility, int _stamina, EquipmentType _equipmentType) :
        base(_id, _name, _itemType, _itemQuality, _itemCareer, _description, _buyParice, _sellPrice, _sprite, _maxNum)
    {
        this.defensivePower = _defensivePower;
        this.agility        = _agility;
        this.stamina        = _stamina;
        this.equipmentType  = _equipmentType;
    }
예제 #5
0
 public int damage;//增加的伤害
 public Weapon(int _id, string _name, ItemType _itemType, ItemQuality _itemQuality, ItemCareer _itemCareer, string _description, int _buyParice, int _sellPrice, string _sprite,
               int _maxNum, int _damage) :
     base(_id, _name, _itemType, _itemQuality, _itemCareer, _description, _buyParice, _sellPrice, _sprite, _maxNum)
 {
     this.damage = _damage;
 }