/// <summary> /// Retourne une liste des différents Rôles /// </summary> /// <returns> /// Une liste des différents Rôles /// </returns> public static List <Role> RetournerRole() { List <Role> roles = new List <Role>(); var types = System.AppDomain.CurrentDomain.GetAllDerivedTypes(typeof(Role)); foreach (System.Type type in types) { roles.Add((Role)CreateInstance.MagicallyCreateInstance(type.ToString())); } return(roles); }
/// <summary> /// Retourne une liste des différents Personnages /// </summary> /// <returns> /// Une liste des différents Personnages /// </returns> public static List <Personnage> RetournerPersonnages() { List <Personnage> personnages = new List <Personnage>(); var types = System.AppDomain.CurrentDomain.GetAllDerivedTypes(typeof(Personnage)); foreach (System.Type type in types) { personnages.Add((Personnage)CreateInstance.MagicallyCreateInstance(type.ToString())); } return(personnages); }
/// <summary> /// Affiche les différents Rôles dans la console /// </summary> public static void AfficherRoles() { List <Role> roles = new List <Role>(); var types = System.AppDomain.CurrentDomain.GetAllDerivedTypes(typeof(Role)); foreach (System.Type type in types) { roles.Add((Role)CreateInstance.MagicallyCreateInstance(type.ToString())); } foreach (Role role in roles) { Debug.Log(role.titre); } }
/// <summary> /// Affiche les différents Personnages dans la console /// </summary> public static void AfficherPersonnages() { List <Personnage> personnages = new List <Personnage>(); var types = System.AppDomain.CurrentDomain.GetAllDerivedTypes(typeof(Personnage)); foreach (System.Type type in types) { personnages.Add((Personnage)CreateInstance.MagicallyCreateInstance(type.ToString())); } foreach (Personnage personnage in personnages) { Debug.Log(personnage.nom); } }
/// <summary> /// Returns an <see cref="Adventurer"/> /// </summary> /// <param name="fullPath"> Path of the xml file describing the <see cref="Adventurer"/> </param> /// <returns> An <see cref="Adventurer"/> </returns> public static Adventurer GetAdventurer(string fullPath) { // Setting the default values string name = "John DOE"; int hp = 3; Color32 color = new Color32(255, 255, 255, 255); List <Equipment> equipments = new List <Equipment>(); // Reading the file, changing the values if said to XmlReader xmlReader = XmlReader.Create(fullPath); while (xmlReader.Read()) { if (xmlReader.NodeType == XmlNodeType.Element) { if (xmlReader.Name == "adventurer" && xmlReader.HasAttributes) { name = xmlReader.GetAttribute("name"); hp = int.Parse(xmlReader.GetAttribute("hp")); color.r = Byte.Parse(xmlReader.GetAttribute("colorR")); color.g = Byte.Parse(xmlReader.GetAttribute("colorG")); color.b = Byte.Parse(xmlReader.GetAttribute("colorB")); } if (xmlReader.Name == "equipment" && xmlReader.HasAttributes) { int ID = int.Parse(xmlReader.GetAttribute("ID")); if (dictionaryEquipment.ContainsKey(ID)) { equipments.Add((Equipment)CreateInstance.MagicallyCreateInstance(dictionaryEquipment[ID])); } } } } return(new Adventurer(name, hp, equipments, color)); }