private DefChallenge CreateDef(int depth) { RefDef refDef = RefLoader.RandomRefDef(depth); DefChallenge defChallenge = new DefChallenge { Name = refDef.Name, RequiredValue = GetDef(depth, refDef.Level) }; return(defChallenge); }
public static RefDef FromXml(XElement xElement) { RefDef refDef = new RefDef(); refDef.Name = LoadText(xElement); refDef.Level = xElement.Attribute("level")?.Value; refDef.MinDepth = Convert.ToInt32(xElement.Attribute("minDepth")?.Value); refDef.MaxDepth = Convert.ToInt32(xElement.Attribute("maxDepth")?.Value); refDef.MaxDepth = refDef.MaxDepth == 0 ? 999999999 : refDef.MaxDepth; return(refDef); }
public void LoadData() { // LOAD OPERATIONS // if your original XML file is located at // "Ressources/MyXMLFile.xml" TextAsset textAsset = (TextAsset)Resources.Load("Data/operations"); XmlDocument xmldoc = new XmlDocument(); xmldoc.LoadXml(textAsset.text); XElement xFileContent = XElement.Load(xmldoc.DocumentElement.CreateNavigator().ReadSubtree()); var operations = xFileContent.Elements("operation").ToList(); foreach (XElement e in operations) { RefOperation refOp = RefOperation.FromXml(e); RefOperations.Add(refOp); } // LOAD ATQ CHALLENGES textAsset = (TextAsset)Resources.Load("Data/creatures"); xmldoc = new XmlDocument(); xmldoc.LoadXml(textAsset.text); xFileContent = XElement.Load(xmldoc.DocumentElement.CreateNavigator().ReadSubtree()); var creatures = xFileContent.Elements("creature").ToList(); foreach (XElement e in creatures) { RefAtq refAtq = RefAtq.FromXml(e); RefAtqs.Add(refAtq); } // LOAD DEF CHALLENGES textAsset = (TextAsset)Resources.Load("Data/dangers"); xmldoc = new XmlDocument(); xmldoc.LoadXml(textAsset.text); xFileContent = XElement.Load(xmldoc.DocumentElement.CreateNavigator().ReadSubtree()); var dangers = xFileContent.Elements("danger").ToList(); foreach (XElement e in dangers) { RefDef refAtq = RefDef.FromXml(e); RefDefs.Add(refAtq); } }