Ejemplo n.º 1
0
        /// <summary>
        /// The function is used to read the script xml 
        /// </summary>
        /// <param name="objects"></param>
        public void convert(ObjectSpace objects)
        {
            IEnumerator<xmlObject> iter = objects.getIter();
            String temp;
            ScriptData script;

            while (iter.MoveNext())
            {

                script = new ScriptData();

                temp = iter.Current.findValueOfProperty("alias");

                if (temp != null)
                {
                    script.Alias = temp;
                }

                temp = iter.Current.findValueOfProperty("file");

                if (temp != null)
                {
                    script.File = temp;
                }

                //Check if there is a file name and alias
                if ((script.Alias != "") && (script.File != ""))
                {
                    Log.getInstance().log("@Folder:Scripts, Class:ScriptKeeper, Log Type: Error, Line No: 121, " + "Scriptkeeper : Empty script file missing alias or file ");
                }

                //Load the script
                addScript(script);
            }
        }
        /// <summary>
        /// The functions converts the xml data 
        /// </summary>
        /// <param name="objects"></param>
        public void getMapObjects(ObjectSpace objects)
        {
            IEnumerator<xmlObject> iter = objects.getIter();
            String temp;

            while (iter.MoveNext())
            {
                MapObject obj = new MapObject();

                temp = iter.Current.findValueOfProperty("x");
                if (temp != null)
                {
                    obj.X = (float) Convert.ToDouble(temp);
                }

                temp = iter.Current.findValueOfProperty("y");

                if (temp != null)
                {
                    obj.Y = (float)Convert.ToDouble(temp);
                }

                temp = iter.Current.findValueOfProperty("visible");

                if (temp != null)
                {
                    obj.Visible=Convert.ToBoolean(temp);
                }

                temp = iter.Current.findValueOfProperty("collision");

                if (temp != null)
                {
                    obj.Collision = Convert.ToBoolean(temp);
                }

                temp = iter.Current.findValueOfProperty("image");

                if (temp != null)
                {
                    obj.ImageAlias = temp;
                }

                temp = iter.Current.findValueOfProperty("alias");

                if (temp != null)
                {
                    obj.Alias = temp;
                }

                information.Add(obj);
            }
        }
Ejemplo n.º 3
0
 public void process(String token)
 {
     try
     {
         objects = new ObjectSpace();
         read = new XmlTextReader(fileName);
         xmlLoader(read, objects, token);
     }
     catch (Exception e)
     {
         Log.getInstance().log("@Folder:XML, Class:XMLReader, Log Type: Error, Line No: 54, " + "XML could not load the file " + fileName + " " + e.ToString());
         System.Environment.Exit(-1);
     }
 }
Ejemplo n.º 4
0
 public XMLReader(String file)
 {
     fileName = file;
     contents = "";
     objects = new ObjectSpace();
     try
     {
         read = new XmlTextReader(file);
     }
     catch (Exception e)
     {
         System.Console.WriteLine(e);
     }
 }
Ejemplo n.º 5
0
        public void convert(ObjectSpace objects)
        {
            IEnumerator<xmlObject> iter = objects.getIter();
            String temp;

            while (iter.MoveNext())
            {

                temp = iter.Current.findValueOfProperty("name");

                if (temp != null)
                {
                    assets.Add(temp);
                }
            }
        }
Ejemplo n.º 6
0
        /// <summary>
        /// The function converts the data about the worlds from an xml file
        /// </summary>
        /// <param name="objects"></param>
        public void convert(ObjectSpace objects)
        {
            IEnumerator<xmlObject> iter = objects.getIter();
            String temp;

            while (iter.MoveNext())
            {
                World world = new World();

                temp = iter.Current.findValueOfProperty("name");

                if (temp != null)
                {
                    world.Name = temp;
                }

                temp = iter.Current.findValueOfProperty("map");

                if (temp != null)
                {
                    world.MapFile = temp;
                }

                temp = iter.Current.findValueOfProperty("events");

                if (temp != null)
                {
                    world.EventMapFile = temp;
                }

                temp = iter.Current.findValueOfProperty("assets");

                if (temp != null)
                {
                    world.AssetFile = temp;
                }

                temp = iter.Current.findValueOfProperty("world_script");

                if (temp != null)
                {
                    world.ScriptFile = temp;
                }

                information.Add(world.Name,world);
            }
        }
Ejemplo n.º 7
0
        //The function allows the style object to be loaded from a file
        public void convert(ObjectSpace objects)
        {
            IEnumerator<xmlObject> iter = objects.getIter();
            String temp;

            while (iter.MoveNext())
            {

                temp = iter.Current.findValueOfProperty("BUTTON_DOWN");
                if (temp != null)
                {
                    skins.Add("BUTTON_DOWN",temp);
                }

                temp = iter.Current.findValueOfProperty("BUTTON_UP");

                if (temp != null)
                {
                    skins.Add("BUTTON_UP", temp);
                }

            }
        }
Ejemplo n.º 8
0
        public void xmlLoader(XmlTextReader read, ObjectSpace objects,String tag)
        {
            xmlObject obj = new xmlObject("dummy");
            int count = 0;
            String token = tag;
            String name = "";

            while (read.Read())
            {

                //Check if we should reset the object counter
                if (count > 0)
                {
                    objects.addObject(obj);
                    count = 0;
                }

                //Check if it is the start of a new object
                if (read.Name.Equals(token))
                {
                    obj = new xmlObject(token);
                    count++;

                }
                else if (read.NodeType == XmlNodeType.Element)
                {
                    name = read.Name;
                }
                else if (read.NodeType == XmlNodeType.Text)
                {
                    obj.addAttributes(name, read.Value);
                }

            }
            objects.checkRemoveEmpty();
        }
Ejemplo n.º 9
0
        public void convert(ObjectSpace objects)
        {
            IEnumerator<xmlObject> iter = objects.getIter();
            String temp;
            float x, y;

            while (iter.MoveNext())
            {
                EventObject obj = new EventObject();
                x = -1;
                y = -1;

                temp = iter.Current.findValueOfProperty("name");

                if (temp != null)
                {
                    obj.Name = temp;
                }

                temp = iter.Current.findValueOfProperty("script_file");

                if (temp != null)
                {
                    obj.ScriptFile = temp;
                }

                temp = iter.Current.findValueOfProperty("x");

                if (temp != null)
                {
                    x = (float)Convert.ToDouble(temp);
                }

                temp = iter.Current.findValueOfProperty("y");

                if (temp != null)
                {
                    y = (float)Convert.ToDouble(temp);
                }

                if ((x > -1) && (y > -1))
                {
                    obj.Pos = new Vector2(x, y);
                }

                temp = iter.Current.findValueOfProperty("width");

                if (temp != null)
                {
                    obj.Width = Convert.ToInt32(temp);
                }

                temp = iter.Current.findValueOfProperty("height");

                if (temp != null)
                {
                    obj.Height = Convert.ToInt32(temp);
                }

                temp = iter.Current.findValueOfProperty("trigger");

                if (temp != null)
                {
                    obj.Triggered = (Trigger)Convert.ToInt32(temp);
                }

                events.Add(obj.Name, obj);
            }
        }