12345678910111213141516171819202122232425262728293031323334353637383940 |
- using UnityEngine;
- using System.Collections;
- using System.Collections.Generic;
- using LitJson;
- public class ReplayInfo
- {
- public List<Player> playerList;
- public ReplayInfo(string json)
- {
- playerList = new List<Player> ();
-
- JsonData data = JsonMapper.ToObject (json);
- JsonData playerArr = data ["p"];
- for(int i=0; i<playerArr.Count; i++)
- {
- Player player = new Player ();
- player.FromJson (playerArr [i]);
- playerList.Add (player);
- }
- }
- public static string ToJson(BattleSession battleSession)
- {
- JsonData json = JsonMapper.ToObject ("{}");
- JsonData playerArr = JsonMapper.ToObject ("[]");
- List<Player> list = battleSession.GetPlayerList ();
- for(int i=0; i<list.Count; i++)
- {
- playerArr.Add (list [i].ToJson ());
- }
- json ["p"] = playerArr;
- return json.ToJson ();
- }
- }
|