diff options
Diffstat (limited to 'WorldlineKeepers/Assets/Scripts')
6 files changed, 177 insertions, 43 deletions
diff --git a/WorldlineKeepers/Assets/Scripts/Buffs/Buff.cs b/WorldlineKeepers/Assets/Scripts/Buffs/Buff.cs index 430fa70..8f65991 100644 --- a/WorldlineKeepers/Assets/Scripts/Buffs/Buff.cs +++ b/WorldlineKeepers/Assets/Scripts/Buffs/Buff.cs @@ -15,4 +15,12 @@ public abstract class Buff // buff效果器 public BuffEfectorBase effector; + public string uid + { + get + { + return metadata.uid; + } + } + } diff --git a/WorldlineKeepers/Assets/Scripts/Buffs/BuffMetadata.cs b/WorldlineKeepers/Assets/Scripts/Buffs/BuffMetadata.cs index de7c391..fd82064 100644 --- a/WorldlineKeepers/Assets/Scripts/Buffs/BuffMetadata.cs +++ b/WorldlineKeepers/Assets/Scripts/Buffs/BuffMetadata.cs @@ -14,7 +14,7 @@ namespace WK.Data public string icon; - // 暂留数据 + // 扩展数据 public string extra_data; } diff --git a/WorldlineKeepers/Assets/Scripts/Perks/PerkBase.cs b/WorldlineKeepers/Assets/Scripts/Perks/PerkBase.cs index 18e39ea..a8d150f 100644 --- a/WorldlineKeepers/Assets/Scripts/Perks/PerkBase.cs +++ b/WorldlineKeepers/Assets/Scripts/Perks/PerkBase.cs @@ -7,7 +7,7 @@ using UnityEngine; /// </summary> public class PerkBase { - + public string uid; } diff --git a/WorldlineKeepers/Assets/Scripts/Tests/TestJson.cs b/WorldlineKeepers/Assets/Scripts/Tests/TestJson.cs new file mode 100644 index 0000000..89d6219 --- /dev/null +++ b/WorldlineKeepers/Assets/Scripts/Tests/TestJson.cs @@ -0,0 +1,72 @@ +using LitJson; +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +public class SaveData +{ + public int serialNumber; //搴忓彿 + public string accountNumber; //璐﹀彿 + public string password; //瀵嗙爜 + public List<string> code; + public Dictionary<string, string> map; +} +public class SaveDatas +{ + public SaveData[] saveDatas; +} + +public class TestJson : MonoBehaviour +{ + #region 搴忓垪鍖 + + #endregion + + #region 鍏叡瀛楁 + + #endregion + + #region 绉佹湁瀛楁 + + #endregion + + private void OnEnable() + { + + //绗竴涓敤鎴风殑璐﹀彿瀵嗙爜 + SaveData peopleOne = new SaveData(); + peopleOne.serialNumber = 1; + peopleOne.accountNumber = "鑻忛啋"; + peopleOne.password = "123456"; + peopleOne.code = new List<string> { "112312asd", "asdasde123"}; + peopleOne.map = new Dictionary<string, string> { + {"ada", "wewe" }, + {"sdw", "wew" }, + {"qweqwe", "s" }, + {"sd1", "asd" }, + }; + + //绗簩涓敤鎴风殑璐﹀彿瀵嗙爜 + SaveData peopleTwo = new SaveData(); + peopleTwo.serialNumber = 2; + peopleTwo.accountNumber = "wangtao"; + peopleTwo.password = "789789"; + + //瀛樺偍鏁版嵁 + SaveDatas peoples = new SaveDatas(); + peoples.saveDatas = new SaveData[] { peopleOne, peopleTwo }; + + //鍒涘缓Json + string Datas = JsonMapper.ToJson(peoples); + //瑙f瀽Json + SaveDatas sd = JsonMapper.ToObject<SaveDatas>(Datas); + + Debug.Log(Datas); + } + + private void Reset() + { + OnEnable(); + } + +} diff --git a/WorldlineKeepers/Assets/Scripts/Tests/TestJson.cs.meta b/WorldlineKeepers/Assets/Scripts/Tests/TestJson.cs.meta new file mode 100644 index 0000000..bd8735f --- /dev/null +++ b/WorldlineKeepers/Assets/Scripts/Tests/TestJson.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 807579a6a3913a7488bd4be81ce79a12 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/WorldlineKeepers/Assets/Scripts/Unit/Characters/CharacterInfo.cs b/WorldlineKeepers/Assets/Scripts/Unit/Characters/CharacterInfo.cs index 950b7ae..62dd830 100644 --- a/WorldlineKeepers/Assets/Scripts/Unit/Characters/CharacterInfo.cs +++ b/WorldlineKeepers/Assets/Scripts/Unit/Characters/CharacterInfo.cs @@ -11,43 +11,8 @@ namespace WK public class CharacterStatsCollection { - - } - - public class CharacterBuffsCollection - { - - } - - public class CharacterPerksCollection - { - - } - - /// <summary> - /// 角色当前状态 - /// </summary> - public class CharacterInfo - { - - /// <summary> - /// 角色当前所有属性 - /// </summary> private List<CharacterStats> m_Stats; - - public CharacterStatsCollection stats { get { return m_AllStats; } } - private CharacterStatsCollection m_AllStats; - - /// <summary> - /// 角色当前所有buff - /// </summary> - private List<Buff> m_Buffs; - - /// <summary> - /// 角色当前所有被动 - /// </summary> - private List<PerkBase> m_Perks; - + public List<CharacterStats> stats { get { return m_Stats; } } public CharacterStats this[string statsUID] { get @@ -56,10 +21,9 @@ namespace WK { return null; } - return GetStats(statsUID); + return GetStats(statsUID); } } - public CharacterStats GetStats(string statsUID) { for (int i = 0; i < m_Stats.Count; ++i) @@ -72,7 +36,7 @@ namespace WK return null; } - public bool HasStats(string statsUID) + public bool HasStats(string statsUID) { for (int i = 0; i < m_Stats.Count; ++i) { @@ -83,12 +47,91 @@ namespace WK } return false; } + } + + public class CharacterBuffsCollection + { + private List<Buff> m_Buffs; + public List<Buff> buffs { get { return m_Buffs; } } + + public Buff this[string buffUID] + { + get + { + return GetBuff(buffUID); + } + } - public bool HasBuff(string buffUID) + public Buff GetBuff(string buffUID) { - return false; + if (m_Buffs == null) + return null; + for(int i = 0; i < m_Buffs.Count; ++i) + { + if (m_Buffs[i].uid == buffUID) + { + return m_Buffs[i]; + } + } + return null; + } + + public bool HasBuff(string buffUID) + { + return GetBuff(buffUID) != null; + } + + } + + public class CharacterPerksCollection + { + private List<PerkBase> m_Perks; + public List<PerkBase> perks { get { return m_Perks; } } + + public PerkBase this[string buffUID] + { + get + { + return GetBuff(buffUID); + } + } + + public PerkBase GetBuff(string buffUID) + { + if (m_Perks == null) + return null; + for (int i = 0; i < m_Perks.Count; ++i) + { + if (m_Perks[i].uid == buffUID) + { + return m_Perks[i]; + } + } + return null; } + public bool HasBuff(string buffUID) + { + return GetBuff(buffUID) != null; + } + + } + + /// <summary> + /// 角色当前状态 + /// </summary> + public class CharacterInfo + { + + public CharacterStatsCollection stats { get { return m_Stats; } } + private CharacterStatsCollection m_Stats; + + public CharacterBuffsCollection buffs { get { return m_Buffs; } } + private CharacterBuffsCollection m_Buffs; + + public CharacterPerksCollection perks { get { return m_Perks; } } + public CharacterPerksCollection m_Perks; + } } |