Exemplo n.º 1
0
        public static RefOperation FromXml(XElement xElement)
        {
            RefOperation op = new RefOperation();

            op.Name        = LoadText(xElement.Element("name"));
            op.Description = LoadText(xElement.Element("description"));
            op.MinDepth    = Convert.ToInt32(xElement.Attribute("minDepth")?.Value);
            op.MaxDepth    = Convert.ToInt32(xElement.Attribute("maxDepth")?.Value);
            op.MaxDepth    = op.MaxDepth == 0 ? 999999999 : op.MaxDepth;
            op.Dig         = xElement.Element("dig").Value;
            op.CapsReward  = xElement.Element("reward").Attribute("caps")?.Value;
            op.RootsReward = xElement.Element("reward").Attribute("roots")?.Value;

            return(op);
        }
Exemplo n.º 2
0
        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);
            }
        }
Exemplo n.º 3
0
        public RunningOperation Create(int depth)
        {
            RefOperation refOp = RefLoader.RandomRefOperation(depth);

            RunningOperation runningOp = new RunningOperation();

            runningOp.Name        = refOp.Name;
            runningOp.Description = refOp.Description;
            runningOp.Depth       = depth;

            runningOp.Dig      = 0;
            runningOp.DigTotal = GetDig(depth, refOp.Dig);

            runningOp.AtqChallenge = CreateAtq(depth);
            runningOp.DefChallenge = CreateDef(depth);

            runningOp.CapsReward  = GetCapsReward(depth, refOp.CapsReward);
            runningOp.RootsReward = GetRootsReward(depth, refOp.RootsReward);

            return(runningOp);
        }