public void DetectarColiciones(ref List<Elemento> lista, Elemento a) { foreach (Elemento b in lista) { if (a != b) { if (a.solido && b.solido) { if (a.right || ColAnt=="right")//&& !a.down && !a.up) { Right_Col(ref a, b); } else if (a.left || ColAnt=="left")//&& !a.down && !a.up) { Left_Col(ref a, b); } else if (a.up || ColAnt == "up")// && !a.left && !a.right) { Up_Col(ref a, b); } else if (a.down || ColAnt == "down")//&& !a.left && !a.right) { Down_Col(ref a, b); } } } } }
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 void Down_Col(ref Elemento a, Elemento b) { if (Colicion(b.rec[0], new PointF(a.rec[2].Left, a.rec[2].Bottom)) || Colicion(b.rec[0], new PointF(a.rec[2].Right, a.rec[2].Bottom))) { //if (ColAnt == "" || ColAnt == "down") //{ a.down = false; float n = a.rec[2].Y - a.rec[0].Y; a.rec[2].Y = b.rec[0].Top - a.rec[2].Height; a.rec[0].Y = a.rec[2].Y - n; //ColAnt = "down"; //}//return; } }
public void AddElemento(Elemento e, float j, float i) { if (e._x > w) { w = (int)e._x; Escenario.Width = w * k; } if(e._y>h) { h = (int)e._y; Escenario.Width = h * k; } //e.AddPosition(x+j*k,y+i*k); e.rec[2].X += e.rec[0].X; e.rec[2].Y += e.rec[0].Y; Ele.Add(e); }
public void ColicionElementos(string d,Elemento a,Elemento b) { if (d == "left") { if (Colicion(b.rec[0], new PointF(a.rec[0].X, a.rec[0].Y)) || Colicion(b.rec[0], new PointF(a.rec[0].X, a.rec[0].Bottom))) ((Personaje)a).Caminar('l', false); } if (d == "right") { if (Colicion(b.rec[0], new PointF(a.rec[0].Right, a.rec[0].Y)) || Colicion(b.rec[0], new PointF(a.rec[0].Right, a.rec[0].Bottom))) ((Personaje)a).Caminar('r', false); } if (d == "up") { if (Colicion(b.rec[0], new PointF(a.rec[0].X, a.rec[0].Y)) || Colicion(b.rec[0], new PointF(a.rec[0].Right, a.rec[0].Y))) ((Personaje)a).Caminar('u', false); } if (d == "down") { if (Colicion(b.rec[0], new PointF(a.rec[0].X, a.rec[0].Bottom)) || Colicion(b.rec[0], new PointF(a.rec[0].Right, a.rec[0].Bottom))) ((Personaje)a).Caminar('d', false); } }
public RectangleF CargarCaja(XmlElement a,Elemento e) { XmlNodeList Caja = a.GetElementsByTagName("Caja"); float x=float.Parse(((XmlElement)Caja[0]).GetAttribute("x")); float y=float.Parse(((XmlElement)Caja[0]).GetAttribute("y")); float w=float.Parse(((XmlElement)Caja[0]).GetAttribute("w")); float h=float.Parse(((XmlElement)Caja[0]).GetAttribute("h")); RectangleF rec = new RectangleF(/*e.rec[0].X*32 +*/ x * e.rec[0].Width, /*e.rec[0].Y*32 +*/ y * e.rec[0].Height, w * e.rec[0].Width, h* e.rec[0].Width); return rec; }
public void WriteTexto(XmlWriter writer, Elemento b) { int n=0; foreach (string t in b.Texto) { writer.WriteStartElement("Texto"); writer.WriteAttributeString("Linea", n.ToString()); writer.WriteAttributeString("contenido", b.Texto[n]); writer.WriteEndElement(); } }
public void WritePosition(XmlWriter writer, Elemento b) { writer.WriteStartElement("Pos"); writer.WriteAttributeString("coor", b._x.ToString()+","+b._y.ToString()); writer.WriteEndElement(); }
public void WriteImage(XmlWriter writer, Elemento b) { writer.WriteStartElement("Imagen"); writer.WriteAttributeString("name", b.im); writer.WriteAttributeString("deep", b.profundidad.ToString()); writer.WriteAttributeString("x", b.rec[1].X.ToString()); writer.WriteAttributeString("y", b.rec[1].Y.ToString()); writer.WriteAttributeString("w", b.rec[1].Width.ToString()); writer.WriteAttributeString("h", b.rec[1].Height.ToString()); writer.WriteEndElement(); }
public void WriteHitBox(XmlWriter writer, Elemento b) { writer.WriteStartElement("Caja"); writer.WriteAttributeString("x", b.rec[2].X.ToString()); writer.WriteAttributeString("y", b.rec[2].Y.ToString()); writer.WriteAttributeString("w", b.rec[2].Width.ToString()); writer.WriteAttributeString("h", b.rec[2].Height.ToString()); writer.WriteEndElement(); }
public void WriteAnimacion(XmlWriter writer, Elemento b) { int n = 0; List<Animacion> AniTemp=new List<Animacion>(); if (b.type == "Animado") AniTemp.Add(((Elemento_Ani)b).ani); else if (b.type == "Personaje") AniTemp = ((Personaje)b).acciones; foreach (Animacion a in AniTemp) { writer.WriteStartElement("Animacion"); writer.WriteAttributeString("name", AniTemp[n].nombre); writer.WriteAttributeString("frame_c", AniTemp[n].F_colum.ToString()); writer.WriteAttributeString("frame_f", AniTemp[n].F_fila.ToString()); writer.WriteAttributeString("frame_seg", AniTemp[n].FxS.ToString()); writer.WriteAttributeString("frame_ini", AniTemp[n].F_inicial.ToString()); writer.WriteAttributeString("frame_fin", AniTemp[n].F_final.ToString()); writer.WriteAttributeString("play", "false"); writer.WriteEndElement(); } }
public void Right_Col(ref Elemento a, Elemento b) { if (Colicion(b.rec[0], new PointF(a.rec[2].Right, a.rec[2].Top)) || Colicion(b.rec[0], new PointF(a.rec[2].Right, a.rec[2].Bottom))) { a.right = false; //if (temp.Right - b.rec[0].Left > 0 && temp.Right - b.rec[0].Left <temp.Width/4) float n = a.rec[2].X - a.rec[0].X; a.rec[2].X = b.rec[0].Left - a.rec[2].Width; a.rec[0].X = a.rec[2].X - n;// b.rec[0].Left - (a.rec[0].Width - (a.rec[0].Right - a.rec[2].Right)); //ColAnt = "right"; //return; } }
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]) } }
public void Up_Col(ref Elemento a, Elemento b) { if (Colicion(b.rec[0], new PointF(a.rec[2].Left, a.rec[2].Top)) || Colicion(b.rec[0], new PointF(a.rec[2].Right, a.rec[2].Top))) { a.up = false; float n = a.rec[2].Y - a.rec[0].Y; a.rec[2].Y = b.rec[0].Bottom; a.rec[0].Y = a.rec[2].Y - n; //ColAnt = "up"; //return; } }
public void SaveTecla(Elemento a) { }
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 Left_Col(ref Elemento a, Elemento b) { if (Colicion(b.rec[0], new PointF(a.rec[2].Left, a.rec[2].Top)) || Colicion(b.rec[0], new PointF(a.rec[2].Left, a.rec[2].Bottom))) { a.left = false; float n = a.rec[2].X - a.rec[0].X; a.rec[2].X = b.rec[0].Right; a.rec[0].X = a.rec[2].X - n; //ColAnt = "left"; //return; } }