public class PlayerReadJosn
{
public static PlayerProperty ReadJsonData(string name)
{
TextAsset JsonText = Resources.Load(name) as TextAsset;
string jsonstr = JsonText.text;
//string jsonstr = File.ReadAllText(Application.dataPath + "/"+name+".txt");
JsonData Jd = JsonMapper.ToObject(jsonstr);
PlayerProperty pp = new PlayerProperty();
pp.PlayerPropertys = new List<PlayerPropertyData>();
for (int i = 0; i < Jd.Count; i++)
{
for (int j = 0; j < Jd[i]["playerData"].Count; j++)
{
PlayerPropertyData pd = new PlayerPropertyData();
pd.playerNamer = Jd[i]["playerData"][j]["playername"].ToString();
pd.playerType = Jd[i]["playerData"][j]["playerType"].ToString();
pd.playerHeight = Jd[i]["playerData"][j]["playerHeight"].ToString();
pd.playerGunTarget = Jd[i]["playerData"][j]["playerGunTarget"].ToString();
pd.playerGun = Jd[i]["playerData"][j]["playergun"].ToString();
pd.playerBody = Jd[i]["playerData"][j]["playerBody"].ToString();
pd.playerHead = Jd[i]["playerData"][j]["playerHead"].ToString();
pd.playerLeftHand = Jd[i]["playerData"][j]["playerLeftHand"].ToString();
pd.playerRightHand = Jd[i]["playerData"][j]["playerRightHand"].ToString();
pp.PlayerPropertys.Add(pd);
}
}
return pp;
}
public class PlayerProperty
{
public List<PlayerPropertyData> PlayerPropertys;
}
public class PlayerPropertyData
{
public string playerNamer;
public string playerType;
public string playerHeight;
public string playerGunTarget;
public string playerGun;
public string playerHead;
public string playerBody;
public string playerLeftHand;
public string playerRightHand;
}