/// <summary> /// 起始設定 /// </summary> public MainChara(byte _index, Dictionary <string, string> _attrsDic) { AttrsDic = _attrsDic; Index = _index; ID = int.Parse(AttrsDic["ID"]); Role = GameDictionary.RoleDic[int.Parse(AttrsDic["Role"])]; Level = int.Parse(AttrsDic["Level"]); CurExp = int.Parse(AttrsDic["Exp"]); Point = int.Parse(AttrsDic["Point"]); GrowConstitution = int.Parse(AttrsDic["Constitution"]); GrowStrength = int.Parse(AttrsDic["Strength"]); GrowMind = int.Parse(AttrsDic["Mind"]); GrowFaith = int.Parse(AttrsDic["Faith"]); GrowAlert = int.Parse(AttrsDic["Alert"]); GrowWill = int.Parse(AttrsDic["Will"]); GrowSkill = int.Parse(AttrsDic["Skill"]); GrowAgility = int.Parse(AttrsDic["Agility"]); //狀態 CurHealth = int.Parse(AttrsDic["CurHP"]); CurVitality = int.Parse(AttrsDic["CurVP"]); //天賦 MyTalent = GameDictionary.TalentDic[int.Parse(AttrsDic["Talent"])]; //武器 MyWeapons = new WeaponData[2]; int[] weaponIDs = TextManager.StringSplitToIntArray(AttrsDic["Weapon"], ','); for (int i = 0; i < MyWeapons.Length; i++) { if (i < weaponIDs.Length) { MyWeapons[i] = GameDictionary.WeaponDic[weaponIDs[i]]; } else { MyWeapons[i] = null; } } //主防具 MyArmor = GameDictionary.ArmorDic[int.Parse(AttrsDic["Armor"])]; //副防具 MyProtectors = new ProtectorData[4]; int[] ProtectorIDs = TextManager.StringSplitToIntArray(AttrsDic["Protector"], ','); for (int i = 0; i < MyProtectors.Length; i++) { if (i < ProtectorIDs.Length) { MyProtectors[i] = GameDictionary.ProtectorDic[ProtectorIDs[i]]; } else { MyProtectors[i] = null; } } }
/// <summary> /// 將字典傳入,依json表設定資料 /// </summary> public static void SetData(Dictionary<int, ProtectorData> _dic) { string jsonStr = Resources.Load<TextAsset>("Json/Protector").ToString(); JsonData jd = JsonMapper.ToObject(jsonStr); JsonData protectorItems = jd["Protector"]; for (int i = 0; i < protectorItems.Count; i++) { ProtectorData protectorData = new ProtectorData(protectorItems[i]); int id = int.Parse(protectorItems[i]["ID"].ToString()); _dic.Add(id, protectorData); } }
/// <summary> /// 將字典傳入,依json表設定資料 /// </summary> public static void SetData(Dictionary <int, ProtectorData> _dic) { string jsonStr = Resources.Load <TextAsset>("Json/Protector").ToString(); JsonData jd = JsonMapper.ToObject(jsonStr); JsonData protectorItems = jd["Protector"]; for (int i = 0; i < protectorItems.Count; i++) { ProtectorData protectorData = new ProtectorData(protectorItems[i]); int id = int.Parse(protectorItems[i]["ID"].ToString()); _dic.Add(id, protectorData); } }
/// <summary> /// 初始化武器,傳入武器ID /// </summary> public Protector(int _protectorID) : base(_protectorID) { Type = EquipmentTYpe.Protector; if (!GameDictionary.ProtectorDic.ContainsKey(ID)) { Debug.LogWarning("不存在的護具ID:" + ID); return; } ProtectorData protectorData = GameDictionary.ProtectorDic[ID]; InitEquipment(protectorData); ProType = protectorData.Type; }
/// <summary> /// 起始設定 /// </summary> public MainChara(byte _index, Dictionary<string, string> _attrsDic) { AttrsDic = _attrsDic; Index = _index; ID = int.Parse(AttrsDic["ID"]); Role = GameDictionary.RoleDic[int.Parse(AttrsDic["Role"])]; Level = int.Parse(AttrsDic["Level"]); CurExp = int.Parse(AttrsDic["Exp"]); Point = int.Parse(AttrsDic["Point"]); GrowConstitution = int.Parse(AttrsDic["Constitution"]); GrowStrength = int.Parse(AttrsDic["Strength"]); GrowMind = int.Parse(AttrsDic["Mind"]); GrowFaith = int.Parse(AttrsDic["Faith"]); GrowAlert = int.Parse(AttrsDic["Alert"]); GrowWill = int.Parse(AttrsDic["Will"]); GrowSkill = int.Parse(AttrsDic["Skill"]); GrowAgility = int.Parse(AttrsDic["Agility"]); //狀態 CurHealth = int.Parse(AttrsDic["CurHP"]); CurVitality = int.Parse(AttrsDic["CurVP"]); //天賦 MyTalent = GameDictionary.TalentDic[int.Parse(AttrsDic["Talent"])]; //武器 MyWeapons = new WeaponData[2]; int[] weaponIDs = TextManager.StringSplitToIntArray(AttrsDic["Weapon"], ','); for (int i = 0; i < MyWeapons.Length; i++) { if (i < weaponIDs.Length) MyWeapons[i] = GameDictionary.WeaponDic[weaponIDs[i]]; else MyWeapons[i] = null; } //主防具 MyArmor = GameDictionary.ArmorDic[int.Parse(AttrsDic["Armor"])]; //副防具 MyProtectors = new ProtectorData[4]; int[] ProtectorIDs = TextManager.StringSplitToIntArray(AttrsDic["Protector"], ','); for (int i = 0; i < MyProtectors.Length; i++) { if (i < ProtectorIDs.Length) MyProtectors[i] = GameDictionary.ProtectorDic[ProtectorIDs[i]]; else MyProtectors[i] = null; } }
/// <summary> /// 將Json資料寫入字典裡 /// </summary> static void LoadJsonDataToDic() { //文字字典 String_AttributeDic = new Dictionary <string, String_AttributeData>(); String_AttributeData.SetData(String_AttributeDic); //Sprite字典 SpriteDic = new Dictionary <string, SpriteData>(); SpriteData.SetData(SpriteDic); //被動施法 PSpellDic = new Dictionary <int, PassiveSpellData>(); PassiveSpellData.SetData(PSpellDic); //主動施法 ASpellDic = new Dictionary <int, ActivitySpellData>(); ActivitySpellData.SetData(ASpellDic); DamageDic = new Dictionary <int, DamageData>(); DamageData.SetData(DamageDic); CureDic = new Dictionary <int, CureData>(); CureData.SetData(CureDic); BufferDic = new Dictionary <int, BufferData>(); BufferData.SetData(BufferDic); //天賦字典 TalentDic = new Dictionary <int, TalentData>(); TalentData.SetData(TalentDic); //武器 WeaponDic = new Dictionary <int, WeaponData>(); WeaponData.SetData(WeaponDic); //防具 ArmorDic = new Dictionary <int, ArmorData>(); ArmorData.SetData(ArmorDic); //裝備 ProtectorDic = new Dictionary <int, ProtectorData>(); ProtectorData.SetData(ProtectorDic); //裝備 DropDic = new Dictionary <int, DropData>(); DropData.SetData(DropDic); //冒險 AdventureDic = new Dictionary <int, AdventureData>(); AdventureData.SetData(AdventureDic); //出怪事件 MonsterEventDic = new Dictionary <int, MonsterEventData>(); MonsterEventData.SetData(MonsterEventDic); //調查事件 InvestigateEventDic = new Dictionary <int, List <InvestigateEventData> >(); InvestigateEventData.SetData(InvestigateEventDic); //意外事件 AccidentEventDic = new Dictionary <int, List <AccidentEventData> >(); AccidentEventData.SetData(AccidentEventDic); //結果事件 EventResultDic = new Dictionary <int, EventResultData>(); EventResultData.SetData(EventResultDic); //紮營事件 CampDic = new Dictionary <int, List <CampEventData> >(); CampEventData.SetData(CampDic); //怪物 MonsterGroupDic = new Dictionary <int, List <MonsterData> >(); MonsterDic = new Dictionary <int, MonsterData>(); MonsterData.SetData(MonsterGroupDic, MonsterDic); //腳色字典 RoleDic = new Dictionary <int, RoleData>(); RoleData.SetData(RoleDic); //主屬性字典 MainAttributeDic = new Dictionary <MainAttribute, MainAttributeData>(); MainAttributeData.SetData(MainAttributeDic); //等級字典 LevelDic = new Dictionary <int, LevelData>(); LevelData.SetData(LevelDic); }