示例#1
0
 public void AddElemento(string img,int prof, float _w, float _h, float i, float j,bool s, Rectangle r)
 {
     Elemento temp = new Elemento(x + j * k, y + i * k, _w, _h, k, prof, s);
     temp.AddImg(img);
     temp.DefinePortion(r.X, r.Y, r.Width, r.Height);
     Ele.Add(temp);
 }
        public Elemento CargarImagen(Elemento temp, XmlElement a)
        {
            XmlNodeList _imagen = a.GetElementsByTagName("Imagen");
            string Img_Nombre = ((XmlElement)_imagen[0]).GetAttribute("name");
            int deep = int.Parse(((XmlElement)_imagen[0]).GetAttribute("deep"));
            int img_x = int.Parse(((XmlElement)_imagen[0]).GetAttribute("x"));
            int img_y = int.Parse(((XmlElement)_imagen[0]).GetAttribute("y"));
            int img_w = int.Parse(((XmlElement)_imagen[0]).GetAttribute("w"));
            int img_h = int.Parse(((XmlElement)_imagen[0]).GetAttribute("h"));

            temp.AddImg(Img_Nombre);
            temp.profundidad = deep;
            temp.DefinePortion(img_x, img_y, img_w, img_h);
            return temp;
        }
 public void CargarElementoEstatico(XmlNodeList _Elementos, ref Map _mapa)
 {
     XmlNodeList _Estaticos = ((XmlElement)_Elementos[0]).GetElementsByTagName("Estaticos");
     XmlNodeList _Elemento = ((XmlElement)_Estaticos[0]).GetElementsByTagName("Elemento");
     foreach (XmlElement a in _Elemento)
     {
         //---------------------------Guardando datos del elemento-----------------//
         bool solid=bool.Parse(a.GetAttribute("solido"));
         float width=float.Parse(a.GetAttribute("width"));
         float height=float.Parse(a.GetAttribute("height"));
         string nombre = a.GetAttribute("name");
         Elemento temp=new Elemento(0,0,width,height,1,0,solid);
             //--------------------------Guardando Especificaciones de imagen------------//
         CargarImagen(temp, a);
             //---------------------------Guardando las posicion-----------------//
         List<PointF> posiciones=CargarPosicion(a);
             //---------------------------Agregar cada elemento al mapa----------//\
         foreach (PointF punto in posiciones)
         {
             Elemento _E =new Elemento(punto.X,punto.Y,temp.rec[0].Width,temp.rec[0].Height,_mapa.k,temp.profundidad,temp.solido);
             _E.AddImg(temp.im);
             _E.DefinePortion(temp.rec[1].X, temp.rec[1].Y, temp.rec[1].Width, temp.rec[1].Height);
             _E.name = nombre;
             _E.type = "Estatico";
             _mapa.AddElemento(_E, punto.X, punto.Y);
         }
             //_mapa.AddElemento(temp.im,temp.profundidad,temp.rec[0].Width,temp.Height,punto.Y,punto.Y,temp,temp.rec[0])
     }
 }