/**
     * 解析Json文件
     * */
    public void ParseItemJson()
    {
        itemList = new List <ItemDetail>();
        TextAsset  itemText = Resources.Load <TextAsset>("ItemDetail");
        string     itemJson = itemText.text;
        JSONObject j        = new JSONObject(itemJson);

        foreach (var temp in j.list)
        {
            int    id   = (int)(temp["id"].n);
            string name = temp["name"].str;
            ItemDetail.ItemType    type    = (ItemDetail.ItemType)System.Enum.Parse(typeof(ItemDetail.ItemType), temp["type"].str);
            ItemDetail.ItemQuality quality = (ItemDetail.ItemQuality)System.Enum.Parse(typeof(ItemDetail.ItemQuality), temp["quality"].str);
            string     description         = temp["description"].str;
            int        capacity            = (int)(temp["capacity"].n);
            int        buyPrice            = (int)(temp["buyPrice"].n);
            int        sellPrice           = (int)(temp["sellPrice"].n);
            string     sprite = temp["sprite"].str;
            ItemDetail item   = null;
            switch (type)
            {
            case ItemDetail.ItemType.Consumable:
                int hp = (int)(temp["hp"].n);
                int mp = (int)(temp["mp"].n);
                item = new Consumable(id, name, type, quality, description, capacity, buyPrice, sellPrice, sprite, hp, mp);
                break;

            case ItemDetail.ItemType.Equipment:
                int M_MaxHp = (int)(temp["M_MaxHp"].n);
                int M_MaxMp = (int)(temp["M_MaxMp"].n);
                int M_Atk   = (int)(temp["M_Atk"].n);
                int M_Def   = (int)(temp["M_Def"].n);
                int M_Mgk   = (int)(temp["M_Mgk"].n);
                int M_Rgs   = (int)(temp["M_Rgs"].n);
                int M_Spd   = (int)(temp["M_Spd"].n);
                Equipment.EquipmentType equiType = (Equipment.EquipmentType)System.Enum.Parse(typeof(Equipment.EquipmentType), temp["equipType"].str);
                item = new Equipment(id, name, type, quality, description, capacity, buyPrice, sellPrice, sprite, M_MaxHp, M_MaxMp, M_Atk, M_Def, M_Mgk, M_Rgs, M_Spd, equiType);
                break;

            case ItemDetail.ItemType.QuestRelated:
                item = new QuestRelated(id, name, type, quality, description, capacity, buyPrice, sellPrice, sprite);
                break;
            }
            itemList.Add(item);
        }
    }
Beispiel #2
0
 private void QuestRelated_ItemParentChanged(On.QuestRelated.orig_ItemParentChanged orig, QuestRelated self)
 {
     OLogger.Log($"ItemParentChanged");
 }