private AtqChallenge CreateAtq(int depth) { RefAtq refAtq = RefLoader.RandomRefAtq(depth); AtqChallenge atqChallenge = new AtqChallenge { Name = refAtq.Name, RequiredValue = GetAtq(depth, refAtq.Level) }; return(atqChallenge); }
public static RefAtq FromXml(XElement xElement) { RefAtq refAtq = new RefAtq(); refAtq.Name = LoadText(xElement); refAtq.Level = xElement.Attribute("level")?.Value; refAtq.MinDepth = Convert.ToInt32(xElement.Attribute("minDepth")?.Value); refAtq.MaxDepth = Convert.ToInt32(xElement.Attribute("maxDepth")?.Value); refAtq.MaxDepth = refAtq.MaxDepth == 0 ? 999999999 : refAtq.MaxDepth; return(refAtq); }
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); } }