海淀天下城电子沙盘单机版
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

49 lines
1.3 KiB

4 years ago
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
[DisallowMultipleComponent]
public class EquipRecord : MonoBehaviour, IRecordDiverseData, IReplayDiverseData
{
public void RecordDiverseData(List<KeyValueData> SpecialData, GameObject gameObject)
{
var bag = gameObject.GetComponent<Bag>();
if (!bag)
{
return;
}
var firemandata = new FiremanEquipRecordData
{
equips = bag.EquipList,
};
SpecialData.Add(new KeyValueData()
{
Key = typeof(FiremanEquipRecordData).ToString(),
Value = JsonUtility.ToJson(firemandata)
});
}
public void ReplayDiverseData(List<KeyValueData> SpecialData, GameObject gameObject)
{
FiremanEquipRecordData firemanbasedata = null;
for (int i = 0; i < SpecialData.Count; i++)
{
if (SpecialData[i].Key == typeof(FiremanEquipRecordData).ToString())
{
firemanbasedata = JsonUtility.FromJson<FiremanEquipRecordData>(SpecialData[i].Value);
break;
}
}
var bag = gameObject.GetComponent<Bag>();
if (bag&&firemanbasedata!=null)
{
bag.EquipList = firemanbasedata.equips;
bag.ChangeCloth();
}
}
}