void Start() { List <Character_XML> CharacterList = new List <Character_XML>(); for (int i = 0; i < 1; ++i) { Character_XML Character = new Character_XML(); Character.character_id = i + 1; Character.character_name = "김준구"; Character.type = "PC"; Character.level = 1; Character.exp = 1000; Character.hp = 2000; Character.mp = 1000; Character.patk = 15.5f; Character.matk = 20.2f; Character.pdef = 33.2f; Character.mdef = 55.1f; Character.mspeed = 3; Character.str = 10; Character.magic = 90; Character.con = 300; Character.intel = 200; Character.dex = 50; CharacterList.Add(Character); } Character_stat.Write(CharacterList, Application.dataPath + "/StreamingAssets/Character.xml"); Debug.Log("ddd222"); }
public static List <Character_XML> Read(string filePath) //캐릭터 XML_에서 불러오기 { XmlDocument CharacterListDocument = new XmlDocument(); CharacterListDocument.Load(filePath); XmlElement CharacterListElement = CharacterListDocument["CharacterList"]; List <Character_XML> CharacterList = new List <Character_XML>(); foreach (XmlElement Character in CharacterListElement.ChildNodes) { Character_XML Ch = new Character_XML(); Ch.character_id = System.Convert.ToInt32(Character.GetAttribute("CHARACTER_ID")); Ch.character_name = Character.GetAttribute("CHARACTER_NAME"); Ch.type = Character.GetAttribute("TYPE"); Ch.level = System.Convert.ToInt32(Character.GetAttribute("LEVEL")); Ch.exp = System.Convert.ToInt32(Character.GetAttribute("EXP")); Ch.hp = System.Convert.ToInt32(Character.GetAttribute("HP")); Ch.mp = System.Convert.ToInt32(Character.GetAttribute("MP")); Ch.patk = System.Convert.ToSingle(Character.GetAttribute("PATK")); Ch.matk = System.Convert.ToSingle(Character.GetAttribute("MATK")); Ch.pdef = System.Convert.ToSingle(Character.GetAttribute("PDEF")); Ch.mdef = System.Convert.ToSingle(Character.GetAttribute("MDEF")); Ch.mspeed = System.Convert.ToInt32(Character.GetAttribute("MSPEED")); Ch.str = System.Convert.ToInt32(Character.GetAttribute("STR")); Ch.magic = System.Convert.ToInt32(Character.GetAttribute("MAGIC")); Ch.con = System.Convert.ToInt32(Character.GetAttribute("CON")); Ch.intel = System.Convert.ToInt32(Character.GetAttribute("INTEL")); Ch.dex = System.Convert.ToInt32(Character.GetAttribute("DEX")); CharacterList.Add(Ch); } return(CharacterList); }
void Start() { List <Character_XML> CharacterList = Character_stat.Read(Application.dataPath + "/StreamingAssets/Character.xml"); for (int i = 0; i < CharacterList.Count; ++i) { Character_XML Character = CharacterList[i]; Debug.Log(string.Format("Character_ID[{0}] : ({1}, {2}, {3}, {4},{5},{6},{7},{8},{9},{10},{11},{12},{13},{14},{15},{16})", Character.character_id, Character.character_name, Character.type, Character.level, Character.level, Character.exp, Character.hp , Character.mp, Character.patk, Character.matk, Character.pdef, Character.mdef, Character.mspeed, Character.str , Character.magic, Character.con, Character.intel, Character.dex)); } }