예제 #1
0
 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])
     }
 }
예제 #2
0
 //<-------------Termina esto
 public void CargarPersonaje(XmlNodeList _Dinamicos,ref Map _mapa)
 {
     XmlNodeList _Elemento = ((XmlElement)_Dinamicos[0]).GetElementsByTagName("Personaje");
     //------------------Cargar info del Elemento animado--------------------//
     foreach (XmlElement a in _Elemento)
     {       //---------------------------Cargando datos del elemento-----------------//
         string nombre = a.GetAttribute("name");
         string clase = a.GetAttribute("clase");
         float width = float.Parse(a.GetAttribute("width"));
         float height = float.Parse(a.GetAttribute("height"));
         string _accion = a.GetAttribute("accion");
         Personaje temp = new Personaje(0, 0, width, height,1, 0);
         //-----------------------Cargando datos de la imagen----------------//
         temp=(Personaje)CargarImagen(temp, a);
         //----------------------Cargando datos de animaciones----------------//
         List<Animacion> Acciones = CargarAnimacion(a,temp.im);
         //----------------------Cargar posiciones--------------------------//
         List<PointF> posiciones = CargarPosicion(a);
         foreach (PointF p in posiciones)
         {
             Personaje _E=null;
             switch (clase)
             {
                 case "Jugador":
                     _E = new Jugador(p.X, p.Y, width, height, _mapa.k, temp.profundidad);
                     _mapa.player = _mapa.Ele.Count;
                     _mapa.IM.mover = new MovimientoPersonaje(_E.Caminar);
                     _mapa.mover = new Moverse(_E.Moverse);
                     _E.clase = "Jugador";
                     break;
                 case "Enemigo":
                     _E = new Enemigo(p.X, p.Y, width, height, _mapa.k, temp.profundidad);
                     _E.clase = "Enemigo";
                     break;
                 case "NPC":
                     _E = new NPC(p.X, p.Y, width, height, _mapa.k, temp.profundidad);
                     _E.clase = "NPC";
                     break;
             }
             _E.AddImg(temp.im);
             _E.DefinePortion(temp.rec[1].X, temp.rec[1].Y, temp.rec[1].Width, temp.rec[1].Height);
             _E.acciones = Acciones;
             _E.SetAction(_accion, false);
             _E.name=nombre;
             CargarEstado(_E, a);
             _E.rec[2] = CargarCaja(a, _E);
             _E.type = "Personaje";
             _mapa.AddElemento(_E, p.X, p.Y);
         }
     }
 }
예제 #3
0
 public void CargarElementoAnimado(XmlNodeList _Dinamicos,ref Map _mapa)
 {
     XmlNodeList _Elemento = ((XmlElement)_Dinamicos[0]).GetElementsByTagName("Elemento_Animado");
     //------------------Cargar info del Elemento animado--------------------//
     foreach (XmlElement a in _Elemento)
     {       //---------------------------Cargando datos del elemento-----------------//
         bool solid = bool.Parse(a.GetAttribute("solido"));
         float width = float.Parse(a.GetAttribute("width"));
         float height = float.Parse(a.GetAttribute("height"));
         Elemento_Ani temp = new Elemento_Ani(0, 0, width, height, 1, 0, solid);
         //-----------------------Cargando datos de la imagen----------------//
         temp=(Elemento_Ani)CargarImagen(temp, a);
         //----------------------Cargando datos de animaciones----------------//
         temp.ani = CargarAnimacion(a,temp.im)[0];
         //----------------------Cargar posiciones--------------------------//
         List<PointF> posiciones=CargarPosicion(a);
         foreach (PointF punto in posiciones)
         {
             Elemento_Ani _E = new Elemento_Ani(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.AddAnimation(temp.ani,new FileHandler(GetImg));
             _E.type = "Animado";
             _mapa.AddElemento(_E, punto.X, punto.Y);
         }
     }
 }