Unity3d背包系统(三)—— 设计物品类的JSON文件

这节谈谈物品的json文件,json文件主要的包括两种结构:

  • 一种是 “名称/值”对的集合,在不同的语言中,被解析的方式也不用如:对象(object),记录(record),结构(struct),字典(dictionary),哈希表(hash table),有键列表(keyed list),关联数组 (associative array)等;
  • 一种是值的有序列表,在大多部分语言中也被叫做“array”.
本节的json使用的是一个有序列表,列表中的内容包括了上节提到的物品的一些属性,下面直接列出物品的json文件:
[
  {
    "id": 1,
    "name": "血瓶",
    "type": "Consumable",
    "quality": "Common",
    "description": "这个是用来加血的",
    "capacity": 10,
    "buyPrice": 10,
    "sellPrice": 5,
    "hp": 10,
    "mp": 0,
    "sprite": "Sprites/Items/hp"
  },
  {
    "id": 2,
    "name": "蓝瓶",
    "type": "Consumable",
    "quality": "Common",
    "description": "这个是用来加蓝的",
    "capacity": 10,
    "buyPrice": 10,
    "sellPrice": 5,
    "hp": 0,
    "mp": 10,
    "sprite": "Sprites/Items/mp"
  },
  {
    "id": 3,
    "name": "神启胸甲",
    "type": "Equipment",
    "quality": "Rare",
    "description": "这个胸甲很牛B",
    "capacity": 1,
    "buyPrice": 20,
    "sellPrice": 10,
    "sprite": "Sprites/Items/armor",
    "level": 10, 
    "strength":10,
    "intellect":4,
    "agility":9,
    "stamina":1,
    "equipType":"Chest"
  },
  {
    "id": 4,
    "name": "神启腰带",
    "type": "Equipment",
    "quality": "Epic",
    "description": "这个腰带可以加速",
    "capacity": 1,
    "buyPrice": 20,
    "sellPrice": 10,
    "sprite": "Sprites/Items/belts",
    "level": 10, 
    "strength":1,
    "intellect":6,
    "agility":10,
    "stamina":10,
    "equipType":"Belt"
  },
  {
    "id": 5,
    "name": "神启站靴",
    "type": "Equipment",
    "quality": "Legendary",
    "description": "这个靴子可以加速",
    "capacity": 1,
    "buyPrice": 20,
    "sellPrice": 10,
    "sprite": "Sprites/Items/boots",
    "level": 10, 
    "strength":10,
    "intellect":5,
    "agility":0,
    "stamina":10,
    "equipType":"Boots"
  },
  {
    "id": 6,
    "name": "神启手镯",
    "type": "Equipment",
    "quality": "Rare",
    "description": "这个护腕可以增加防御",
    "capacity": 1,
    "buyPrice": 20,
    "sellPrice": 10,
    "sprite": "Sprites/Items/bracers",
    "level": 10, 
    "strength":1,
    "intellect":2,
    "agility":3,
    "stamina":4,
    "equipType":"Bracelet"
  },
  {
    "id": 7,
    "name": "神启手套",
    "type": "Weapon",
    "quality": "Common",
    "description": "很厉害的手套",
    "capacity": 1,
    "buyPrice": 10,
    "sellPrice": 5,
    "sprite": "Sprites/Items/gloves",
    "level": 10, 
    "damage":54,
    "weaponType":"MainWeapon"
  },
  {
    "id": 8,
    "name": "神启头盔",
    "type": "Equipment",
    "quality": "Artifact",
    "description": "很厉害的头盔",
    "capacity": 1,
    "buyPrice": 10,
    "sellPrice": 5,
    "sprite": "Sprites/Items/helmets",
    "level": 10, 
    "strength":2,
    "intellect":3,
    "agility":4,
    "stamina":4,
    "equipType":"Head"
  },
  {
    "id": 9,
    "name": "神启项链",
    "type": "Equipment",
    "quality": "Rare",
    "description": "很厉害的项链",
    "capacity": 1,
    "buyPrice": 10,
    "sellPrice": 5,
    "sprite": "Sprites/Items/necklace",
    "level": 10, 
    "strength":2,
    "intellect":3,
    "agility":4,
    "stamina":4,
    "equipType":"Neck"
  },
  {
    "id": 10,
    "name": "神启戒指",
    "type": "Equipment",
    "quality": "Common",
    "description": "很厉害的戒指",
    "capacity": 1,
    "buyPrice": 20,
    "sellPrice": 20,
    "sprite": "Sprites/Items/rings",
    "level": 10, 
    "strength":20,
    "intellect":3,
    "agility":4,
    "stamina":4,
    "equipType":"Ring"
  },
  {
    "id": 11,
    "name": "神启护腿",
    "type": "Equipment",
    "quality": "Common",
    "description": "很厉害的裤子",
    "capacity": 1,
    "buyPrice": 40,
    "sellPrice": 20,
    "sprite": "Sprites/Items/pants",
    "level": 10, 
    "strength":20,
    "intellect":30,
    "agility":40,
    "stamina":40,
    "equipType":"Leg"
  },
  {
    "id": 12,
    "name": "神启护肩",
    "type": "Equipment",
    "quality": "Legendary",
    "description": "很厉害的护肩",
    "capacity": 1,
    "buyPrice": 100,
    "sellPrice": 20,
    "sprite": "Sprites/Items/shoulders",
    "level": 10, 
    "strength":2,
    "intellect":3,
    "agility":4,
    "stamina":4,
    "equipType":"Shoulder"
  },
  {
    "id": 13,
    "name": "开天斧",
    "type": "Weapon",
    "quality": "Artifact",
    "description": "盘古开天的用的斧子",
    "capacity": 1,
    "buyPrice": 50,
    "sellPrice": 20,
    "sprite": "Sprites/Items/axe",
    "level": 10, 
    "damage":100,
    "weaponType":"MainWeapon"
  },
  {
    "id": 14,
    "name": "阴阳剑",
    "type": "Weapon",
    "quality": "Rare",
    "description": "非常厉害的剑",
    "capacity": 1,
    "buyPrice": 15,
    "sellPrice": 5,
    "sprite": "Sprites/Items/sword",
    "level": 10, 
    "damage":20,
    "weaponType":"OffWeapon"
  },
  {
    "id": 15,
    "name": "开天斧的锻造秘籍",
    "type": "Material",
    "quality": "Artifact",
    "description": "用来锻造开天斧的秘籍",
    "capacity": 2,
    "buyPrice": 100,
    "sellPrice": 99,
    "sprite": "Sprites/Items/book"
  },
  {
    "id": 16,
    "name": "头盔的锻造秘籍",
    "type": "Material",
    "quality": "Common",
    "description": "用来锻造头盔的秘籍",
    "capacity": 2,
    "buyPrice": 50,
    "sellPrice": 10,
    "sprite": "Sprites/Items/scroll"
  },
  {
    "id": 17,
    "name": "铁块",
    "type": "Material",
    "quality": "Common",
    "description": "用来锻造其他东西的必备材料",
    "capacity": 20,
    "buyPrice": 5,
    "sellPrice": 4,
    "sprite": "Sprites/Items/ingots"
  }
]

更多关于json数据格式的内容,请参考网上的其他文章,这里不做详细介绍,可以参考这篇文章: http://www.cnblogs.com/SkySoot/archive/2012/04/17/2453010.html

本节到此结束,下节继续。。。。。。

你可能感兴趣的:(Unity3d学习之路)