/// <summary> /// Añade un objeto de cualquier tipo. En caso de ser un tipo Tarea3.Celda, solo se podran agregar objetos de tipo Tarea3.Celda a futuro /// </summary> /// <param name="contenido"></param> public void Add(object contenido) { if (head == null && contenido is Celda) //Lista de celdas { celdatipo = true; } if (celdatipo == true) { if (contenido is Celda) { Celda ccelda = contenido as Celda; if (head == null) { head = new Nodolista(contenido); head.px = ccelda.px; head.py = ccelda.py; tail = head; } else { tail.next = new Nodolista(contenido); tail = tail.next; tail.px = ccelda.px; tail.py = ccelda.py; tail.next = null; } } else { Console.WriteLine("ERROR: Agregando nodos del tipo incorrecto"); }; } else //Lista de cualquier otra cosa { if (head == null) { head = new Nodolista(contenido); tail = head; } else { tail.next = new Nodolista(contenido); tail = tail.next; } } largo++; }
public Etapa(int radio, string name, string objetivo, LibreriaT3.PetalColor[] pushes) { this.pushes = pushes; pushrestantes = pushes.Length; this.nombre = name; this.radio = radio; Listanodos = new Lista(); Celdabase = new Celda(0, 0, Listanodos); Listanodos.Add(Celdabase); Celdabase.crecer(this.radio - 1); Celdabase.crearborde(this.radio); Celda dem = (Celda)Listanodos.buscar(1, 1); this.nobjetivo = objetivo; //Parsear esto a algo logico counters.obj = objetivo; this.name = nombre; }
public static void draw(Lista lista) { //h=x, d=y for (int i = 0; i < lista.Largo; i++) { Celda tmp = (Celda)lista.buscar(i); UI.UpdateCell(tmp.py, tmp.px, tmp.celdatipo); if (tmp.ptipo != null) { if (tmp.ptipo == LibreriaT3.PetalType.Normal && tmp.pcolor != null) { LibreriaT3.PetalColor tmpcolor = (LibreriaT3.PetalColor)tmp.pcolor; //Evitar declaraciones null LibreriaT3.PetalType tmpptipo = (LibreriaT3.PetalType)tmp.ptipo; UI.CreateHex(tmp.py, tmp.px, tmpptipo, tmpcolor); } else if (tmp.ptipo != LibreriaT3.PetalType.Normal) { LibreriaT3.PetalType tmpptipo = (LibreriaT3.PetalType)tmp.ptipo; UI.CreateHex(tmp.py, tmp.px, tmpptipo, LibreriaT3.PetalColor.Blue); } } } }
public void OpenFile(string path) //Armar todas las estructuras, y luego ir presentandolas { Console.WriteLine("55"); XmlDocument xDoc = new XmlDocument(); try { xDoc.Load(path); this.reload = true; } catch (ArgumentException) { Console.WriteLine("ERROR - error 00002"); return; } XmlNodeList dat = xDoc.SelectNodes("//stageList/stage"); //Asigancion de nodos a sus posiciones iniciales... foreach (XmlNode stage in dat) //Leer etapas, crear una estructura hex para cada etapa, se cargan en una lista, luego se cargan individualmente { int i = 0; XmlNodeList Compstage = stage.ChildNodes; XmlNodeList pushList = Compstage[2].ChildNodes; LibreriaT3.PetalColor[] tmppushes = new LibreriaT3.PetalColor[pushList.Count]; //Cargando los pushes #region foreach (XmlNode push in pushList) { switch (push.Attributes[0].Value) { case "blue": tmppushes[i] = LibreriaT3.PetalColor.Blue; break; case "pink": tmppushes[i] = LibreriaT3.PetalColor.Pink; break; case "green": tmppushes[i] = LibreriaT3.PetalColor.Green; break; case "orange": tmppushes[i] = LibreriaT3.PetalColor.Orange; break; default: Console.WriteLine("[!] No se reconoció un pushpetal en el XML"); break; } i++; } #endregion Etapa tempetapa = new Etapa(int.Parse(stage.Attributes[1].Value), stage.Attributes[0].Value, Compstage[3].ChildNodes[0].Attributes[0].Value, tmppushes); etapas.Add(tempetapa); XmlNodeList petalList = Compstage[0].ChildNodes; //Cargando los petalos #region foreach (XmlNode petal in petalList) { int bx = int.Parse(petal.Attributes[2].Value); //d=x int by = int.Parse(petal.Attributes[1].Value); //h=y Celda celdatmp = tempetapa.Listanodos.buscar(bx, by); switch (petal.Attributes[0].Value) { case "bluePetal": celdatmp.pcolor = LibreriaT3.PetalColor.Blue; celdatmp.ptipo = LibreriaT3.PetalType.Normal; break; case "greenPetal": celdatmp.pcolor = LibreriaT3.PetalColor.Green; celdatmp.ptipo = LibreriaT3.PetalType.Normal; break; case "pinkPetal": celdatmp.pcolor = LibreriaT3.PetalColor.Pink; celdatmp.ptipo = LibreriaT3.PetalType.Normal; break; case "orangePetal": celdatmp.pcolor = LibreriaT3.PetalColor.Orange; celdatmp.ptipo = LibreriaT3.PetalType.Normal; break; case "bomb": celdatmp.ptipo = LibreriaT3.PetalType.Explosive; celdatmp.pcolor = null; break; case "rasho": celdatmp.ptipo = LibreriaT3.PetalType.Lightning; celdatmp.pcolor = null; break; case "gravity": celdatmp.ptipo = LibreriaT3.PetalType.Gravity; celdatmp.pcolor = null; break; } } #endregion XmlNodeList cellList = Compstage[1].ChildNodes; //Cargando las celdas especiales #region foreach (XmlNode celda in cellList) { int by = int.Parse(celda.Attributes[2].Value); int bx = int.Parse(celda.Attributes[1].Value); Celda celdatmp = tempetapa.Listanodos.buscar(bx, by); switch (celda.Attributes[0].Value) { case "ArrowS": celdatmp.celdatipo = LibreriaT3.CellType.ArrowS; break; case "ArrowNE": celdatmp.celdatipo = LibreriaT3.CellType.ArrowNE; break; case "ArrowNW": celdatmp.celdatipo = LibreriaT3.CellType.ArrowNW; break; case "ArrowSE": celdatmp.celdatipo = LibreriaT3.CellType.ArrowSE; break; case "ArrowSW": celdatmp.celdatipo = LibreriaT3.CellType.ArrowSW; break; case "ArrowN": celdatmp.celdatipo = LibreriaT3.CellType.ArrowN; break; case "PortalO": celdatmp.celdatipo = LibreriaT3.CellType.PortalO; tempetapa.portalO = celdatmp; break; case "PortalB": celdatmp.celdatipo = LibreriaT3.CellType.PortalB; tempetapa.portalB = celdatmp; break; case "Hole": celdatmp.celdatipo = LibreriaT3.CellType.Hole; break; } } #endregion } this.mapacargado = true; }
/// <summary> /// Envia los datos a la siguiente celda, Empuja la siguiente celda /// </summary> /// <param name="origen"></param> /// <param name="tipoIn"></param> /// <param name="colorIn"></param> public void push2(Celda origen, bool destruir) { if (this.pcolor == null && this.ptipo == null) { } #region Celda tmp = null; int nx = 0; int ny = 0; string dest = null; if (origen == this.NN) { tmp = this.SS; ny = this.py - 1; nx = this.px; dest = "SS"; } else if (origen == this.NW) // SS = SE , this.px -> this.px + 1, this.py -> this.py - 1 { tmp = this.SE; ny = this.py - 1; nx = this.px + 1; dest = "SE"; } else if (origen == this.NE) //SS = SW , this.px -> this.px - 1, this.py -> this.py { tmp = this.SW; ny = this.py; nx = this.px - 1; dest = "SW"; } else if (origen == this.SW) //SS = NE, this.px -> this.px + 1, this.py -> this.py { tmp = this.NE; ny = this.py; nx = this.px + 1; dest = "NE"; } else if (origen == this.SS) //SS = NN, this.px -> this.px, this.py -> this.py + 1 { tmp = this.NN; ny = this.py + 1; nx = this.px; dest = "NN"; } else if (origen == this.SE) //SS = NW , this.px -> this.px - 1, this.py -> this.py + 1 { tmp = this.NW; ny = this.py + 1; nx = this.px - 1; dest = "SW"; } if (tmp != null) //generalizar { if (tmp.pcolor != null && tmp.ptipo == LibreriaT3.PetalType.Normal && tmp.celdatipo == LibreriaT3.CellType.Normal) //Hay un petalo comun abajo. Se empuja el siguiente, se le envia la informacion de este petalo y se le entrega el petalo { tmp.push2(this, false); //envia la informacion que debe adoptar al siguiente nodo... tmp.pcolor = this.pcolor; tmp.ptipo = this.ptipo; opinterfaz.UI.MoveHex(this.py, this.px, ny, nx); } else if (tmp.pcolor == null && tmp.celdatipo == LibreriaT3.CellType.Normal) // Hay un nada abajo, se le entrega informacion y luego el pétalo { tmp.pcolor = this.pcolor; tmp.ptipo = this.ptipo; opinterfaz.UI.MoveHex(this.py, this.px, ny, nx); } else if (tmp.celdatipo == LibreriaT3.CellType.Hole) //Hay un agujero abajo. Se entrega el pétalo, y luego se elimina { opinterfaz.UI.MoveHex(this.py, this.px, ny, nx); opinterfaz.UI.DeleteHex(ny, nx); } else if (tmp.celdatipo == LibreriaT3.CellType.PortalB || tmp.celdatipo == LibreriaT3.CellType.PortalO) // Hay un portal abajo { if (tmp.celdatipo == LibreriaT3.CellType.PortalB) //Entra en B, sale en O { opinterfaz.portalO.pcolor = this.pcolor; opinterfaz.portalO.ptipo = this.ptipo; opinterfaz.UI.MoveHex(this.py, this.px, opinterfaz.portalO.py, opinterfaz.portalO.px); opinterfaz.portalO.pushportal(dest); } else // vic { opinterfaz.portalB.pcolor = this.pcolor; opinterfaz.portalB.ptipo = this.ptipo; opinterfaz.UI.MoveHex(this.py, this.px, opinterfaz.portalB.py, opinterfaz.portalB.px); System.Threading.Thread.Sleep(100); opinterfaz.portalB.pushportal(dest); } } else if (tmp.celdatipo == LibreriaT3.CellType.ArrowN || tmp.celdatipo == LibreriaT3.CellType.ArrowNE || tmp.celdatipo == LibreriaT3.CellType.ArrowNW || tmp.celdatipo == LibreriaT3.CellType.ArrowS || tmp.celdatipo == LibreriaT3.CellType.ArrowSW || tmp.celdatipo == LibreriaT3.CellType.ArrowSE) //Hay una flecha abajo. Las flechas nunca traen petalos encima. Se mueve el petalo a la flecha, se le entrega la informcion, y el metodo push flecha decide que hacer con ella { tmp.pcolor = this.pcolor; tmp.ptipo = this.ptipo; opinterfaz.UI.MoveHex(this.py, this.px, ny, nx); pushflecha(this); } if (destruir == true) { opinterfaz.UI.HighLight(true, ny, nx); opinterfaz.UI.DeleteHex(ny, nx); tmp.pcolor = null; tmp.ptipo = null; } } #endregion }
/// <summary> /// Empuje característico de las flechas /// </summary> /// <param name="origen"></param> /// <param name="tipoIn"></param> /// <param name="colorIn"></param> public void pushflecha(Celda origen) // Recibida ya la informacion, empuja este pétalo { switch (this.celdatipo) { case LibreriaT3.CellType.ArrowN: this.NN.push2(this, false); this.NN.pcolor = this.pcolor; this.NN.ptipo = this.ptipo; opinterfaz.UI.MoveHex(this.py, this.px, this.py + 1, this.px); this.ptipo = null; this.pcolor = null; break; case LibreriaT3.CellType.ArrowNE: this.NE.push2(this, false); this.NE.pcolor = this.pcolor; this.NE.ptipo = this.ptipo; opinterfaz.UI.MoveHex(this.py, this.px, this.py, this.px + 1); this.ptipo = null; this.pcolor = null; break; case LibreriaT3.CellType.ArrowNW: this.NW.push2(this, false); this.NW.pcolor = this.pcolor; this.NW.ptipo = this.ptipo; opinterfaz.UI.MoveHex(this.py, this.px, this.py + 1, this.px - 1); this.ptipo = null; this.pcolor = null; break; case LibreriaT3.CellType.ArrowS: this.SS.push2(this, false); this.SS.pcolor = this.pcolor; this.SS.ptipo = this.ptipo; opinterfaz.UI.MoveHex(this.py, this.px, this.py - 1, this.px); this.ptipo = null; this.pcolor = null; break; case LibreriaT3.CellType.ArrowSE: this.SE.push2(this, false); this.SE.pcolor = this.pcolor; this.SE.ptipo = this.ptipo; opinterfaz.UI.MoveHex(this.py, this.px, this.py - 1, this.px + 1); this.ptipo = null; this.pcolor = null; break; case LibreriaT3.CellType.ArrowSW: this.SW.push2(this, false); this.SW.pcolor = this.pcolor; this.SW.ptipo = this.ptipo; opinterfaz.UI.MoveHex(this.py, this.px, this.py, this.px - 1); this.ptipo = null; this.pcolor = null; break; default: Console.WriteLine("ERROR : 000001"); break; } }
/// <summary> /// Este metodo solo es funcional si es llamado desde una celda base (h = 0, d = 0). En otro caso, originará una estructura erronea /// </summary> /// <param name="radio"></param> public void crearborde(int radio) //Creador del borde { #region if (radio > 0) { radio--; //---------- if (NN == null) { NN = new Celda(this.px, this.py + 1, listanodos); NN.celdatipo = LibreriaT3.CellType.Hole; listanodos.Add(NN); } //---------- if (NW == null) { NW = new Celda(this.px - 1, this.py + 1, listanodos); NW.celdatipo = LibreriaT3.CellType.Hole; listanodos.Add(NW); } //---------- if (NE == null) { NE = new Celda(this.px + 1, this.py, listanodos); NE.celdatipo = LibreriaT3.CellType.Hole; listanodos.Add(NE); } //---------- if (SS == null) { SS = new Celda(this.px, this.py - 1, listanodos); SS.celdatipo = LibreriaT3.CellType.Hole; listanodos.Add(SS); } //---------- if (SW == null) { SW = new Celda(this.px - 1, this.py, listanodos); SW.celdatipo = LibreriaT3.CellType.Hole; listanodos.Add(SW); } //---------- if (SE == null) { SE = new Celda(this.px + 1, this.py - 1, listanodos); SE.celdatipo = LibreriaT3.CellType.Hole; listanodos.Add(SE); } //---------- //Asignacion direcciones a los diversos nodos CW SW.SE = SS; SS.NE = SE; SE.NN = NE; NE.NW = NN; NN.SW = NW; NW.SS = SW; //Asignacion de direcciones a los diversos nodos CCW SW.NN = NW; NW.NE = NN; NN.SE = NE; NE.SS = SE; SE.SW = SS; SS.NW = SW; //Devoluciones al nodo original NN.SS = this; NE.SW = this; SE.NW = this; SS.NN = this; SW.NE = this; NW.SE = this; //Órdenes de crecimiento NN.crearborde(radio); NW.crearborde(radio); NE.crearborde(radio); SE.crearborde(radio); SS.crearborde(radio); SW.crearborde(radio); } #endregion }
/// <summary> /// Crea una celda del color correspondiente aqui mismo y empuja hasta pillar celda vacia, o elimina la celda en un agujero negro. /// </summary> /// <param name="origen"></param> /// <param name="colorIn"></param> /// <param name="tipoIn"></param> public void push1(Celda origen, LibreriaT3.PetalColor colorIn, LibreriaT3.PetalType tipoIn) { #region if (origen == this.NN) //Base, modificar y copiar segun cosas { if (this.SS != null) { if (this.SS.pcolor != null && this.SS.ptipo == LibreriaT3.PetalType.Normal && this.SS.celdatipo == LibreriaT3.CellType.Normal) { this.SS.push2(this, false); //envia la informacion que debe adoptar al siguiente nodo... opinterfaz.UI.MoveHex(this.py, this.px, this.py - 1, this.px); } else if (this.SS.celdatipo == LibreriaT3.CellType.Hole) //Hay un agujero abajo { opinterfaz.UI.MoveHex(this.py, this.px, this.py - 1, this.px); System.Threading.Thread.Sleep(100); opinterfaz.UI.DeleteHex(this.py - 1, this.px); } else if (this.SS.pcolor == null && this.SS.ptipo == null && this.SS.celdatipo == LibreriaT3.CellType.Normal) //Hay un nada abajo { this.SS.pcolor = this.pcolor; this.SS.ptipo = this.ptipo; opinterfaz.UI.MoveHex(this.py, this.px, this.py - 1, this.px); } else if (this.SS.celdatipo == LibreriaT3.CellType.PortalB || this.SS.celdatipo == LibreriaT3.CellType.PortalO) //Hay un portal abajo { if (this.SS.celdatipo == LibreriaT3.CellType.PortalB) //Entra en B, sale en O { opinterfaz.portalO.pcolor = this.pcolor; opinterfaz.portalO.ptipo = this.ptipo; opinterfaz.UI.MoveHex(this.py, this.px, opinterfaz.portalO.py, opinterfaz.portalO.px); opinterfaz.portalO.pushportal("SS"); } else // vic { opinterfaz.portalB.pcolor = this.pcolor; opinterfaz.portalB.ptipo = this.ptipo; opinterfaz.UI.MoveHex(this.py, this.px, opinterfaz.portalB.py, opinterfaz.portalB.px); System.Threading.Thread.Sleep(100); opinterfaz.portalB.pushportal("SS"); } } else if (this.SS.celdatipo == LibreriaT3.CellType.ArrowN || this.SS.celdatipo == LibreriaT3.CellType.ArrowNE || this.SS.celdatipo == LibreriaT3.CellType.ArrowNW || this.SS.celdatipo == LibreriaT3.CellType.ArrowS || this.SS.celdatipo == LibreriaT3.CellType.ArrowSW || this.SS.celdatipo == LibreriaT3.CellType.ArrowSE) //Hay una flecha abajo. Las flechas nunca traen petalos encima. Se mueve el petalo a la flecha, se le entrega la informcion, y el metodo push flecha decide que hacer con ella { this.SS.pcolor = this.pcolor; this.SS.ptipo = this.ptipo; opinterfaz.UI.MoveHex(this.py, this.px, this.py - 1, this.px); this.SS.pushflecha(this); } this.pcolor = colorIn; this.ptipo = tipoIn; opinterfaz.UI.CreateHex(this.py, this.px, (LibreriaT3.PetalType) this.ptipo, (LibreriaT3.PetalColor) this.pcolor); } } else if (origen == this.NW) // SS = SE , this.px -> this.px + 1, this.py -> this.py - 1 { if (this.SE != null) { if (this.SE.pcolor != null && this.SE.ptipo == LibreriaT3.PetalType.Normal && this.SE.celdatipo == LibreriaT3.CellType.Normal) { this.SE.push2(this, false); //envia la informacion que debe adoptar al siguiente nodo... opinterfaz.UI.MoveHex(this.py, this.px, this.py - 1, this.px + 1); } else if (this.SE.celdatipo == LibreriaT3.CellType.Hole) //Hay un agujero abajo { opinterfaz.UI.MoveHex(this.py, this.px, this.py - 1, this.px + 1); System.Threading.Thread.Sleep(100); opinterfaz.UI.DeleteHex(this.py - 1, this.px + 1); } else if (this.SE.pcolor == null && this.SE.ptipo == null && this.SE.celdatipo == LibreriaT3.CellType.Normal) //Hay un nada abajo { this.SE.pcolor = this.pcolor; this.SE.ptipo = this.ptipo; opinterfaz.UI.MoveHex(this.py, this.px, this.py - 1, this.px + 1); } else if (this.SE.celdatipo == LibreriaT3.CellType.PortalB || this.SE.celdatipo == LibreriaT3.CellType.PortalO) //Hay un portal abajo { if (this.SE.celdatipo == LibreriaT3.CellType.PortalB) //Entra en B, sale en O { opinterfaz.portalO.pcolor = this.pcolor; opinterfaz.portalO.ptipo = this.ptipo; opinterfaz.UI.MoveHex(this.py, this.px, opinterfaz.portalO.py, opinterfaz.portalO.px); opinterfaz.portalO.pushportal("SE"); } else // vic { opinterfaz.portalB.pcolor = this.pcolor; opinterfaz.portalB.ptipo = this.ptipo; opinterfaz.UI.MoveHex(this.py, this.px, opinterfaz.portalB.py, opinterfaz.portalB.px); System.Threading.Thread.Sleep(100); opinterfaz.portalB.pushportal("SE"); } } else if (this.SE.celdatipo == LibreriaT3.CellType.ArrowN || this.SE.celdatipo == LibreriaT3.CellType.ArrowNE || this.SE.celdatipo == LibreriaT3.CellType.ArrowNW || this.SE.celdatipo == LibreriaT3.CellType.ArrowS || this.SE.celdatipo == LibreriaT3.CellType.ArrowSW || this.SE.celdatipo == LibreriaT3.CellType.ArrowSE) //Hay una flecha abajo. Las flechas nunca traen petalos encima. Se mueve el petalo a la flecha, se le entrega la informcion, y el metodo push flecha decide que hacer con ella { this.SE.pcolor = this.pcolor; this.SE.ptipo = this.ptipo; opinterfaz.UI.MoveHex(this.py, this.px, this.py - 1, this.px + 1); this.SE.pushflecha(this); } this.pcolor = colorIn; this.ptipo = tipoIn; opinterfaz.UI.CreateHex(this.py, this.px, (LibreriaT3.PetalType) this.ptipo, (LibreriaT3.PetalColor) this.pcolor); } } else if (origen == this.NE) //SS = SW , this.px -> this.px - 1, this.py -> this.py { if (this.SW != null) { if (this.SW.pcolor != null && this.SW.ptipo == LibreriaT3.PetalType.Normal && this.SW.celdatipo == LibreriaT3.CellType.Normal) { this.SW.push2(this, false); //envia la informacion que debe adoptar al siguiente nodo... opinterfaz.UI.MoveHex(this.py, this.px, this.py, this.px - 1); } else if (this.SW.celdatipo == LibreriaT3.CellType.Hole) //Hay un agujero abajo { opinterfaz.UI.MoveHex(this.py, this.px, this.py, this.px - 1); System.Threading.Thread.Sleep(100); opinterfaz.UI.DeleteHex(this.py, this.px - 1); } else if (this.SW.pcolor == null && this.SW.ptipo == null && this.SW.celdatipo == LibreriaT3.CellType.Normal) //Hay un nada abajo { this.SW.pcolor = this.pcolor; this.SW.ptipo = this.ptipo; opinterfaz.UI.MoveHex(this.py, this.px, this.py, this.px - 1); } else if (this.SW.celdatipo == LibreriaT3.CellType.PortalB || this.SW.celdatipo == LibreriaT3.CellType.PortalO) //Hay un portal abajo { if (this.SW.celdatipo == LibreriaT3.CellType.PortalB) //Entra en B, sale en O { opinterfaz.portalO.pcolor = this.pcolor; opinterfaz.portalO.ptipo = this.ptipo; opinterfaz.UI.MoveHex(this.py, this.px, opinterfaz.portalO.py, opinterfaz.portalO.px); opinterfaz.portalO.pushportal("SW"); } else // vic { opinterfaz.portalB.pcolor = this.pcolor; opinterfaz.portalB.ptipo = this.ptipo; opinterfaz.UI.MoveHex(this.py, this.px, opinterfaz.portalB.py, opinterfaz.portalB.px); System.Threading.Thread.Sleep(100); opinterfaz.portalB.pushportal("SW"); } } else if (this.SW.celdatipo == LibreriaT3.CellType.ArrowN || this.SW.celdatipo == LibreriaT3.CellType.ArrowNE || this.SW.celdatipo == LibreriaT3.CellType.ArrowNW || this.SW.celdatipo == LibreriaT3.CellType.ArrowS || this.SW.celdatipo == LibreriaT3.CellType.ArrowSW || this.SW.celdatipo == LibreriaT3.CellType.ArrowSW) //Hay una flecha abajo. Las flechas nunca traen petalos encima. Se mueve el petalo a la flecha, se le entrega la informcion, y el metodo push flecha decide que hacer con ella { this.SW.pcolor = this.pcolor; this.SW.ptipo = this.ptipo; opinterfaz.UI.MoveHex(this.py, this.px, this.py, this.px - 1); this.SW.pushflecha(this); } this.pcolor = colorIn; this.ptipo = tipoIn; opinterfaz.UI.CreateHex(this.py, this.px, (LibreriaT3.PetalType) this.ptipo, (LibreriaT3.PetalColor) this.pcolor); } } else if (origen == this.SW) //SS = NE, this.px -> this.px + 1, this.py -> this.py { if (this.NE != null) { if (this.NE.pcolor != null && this.NE.ptipo == LibreriaT3.PetalType.Normal && this.NE.celdatipo == LibreriaT3.CellType.Normal) { this.NE.push2(this, false); //envia la informacion que debe adoptar al siguiente nodo... opinterfaz.UI.MoveHex(this.py, this.px, this.py, this.px + 1); } else if (this.NE.celdatipo == LibreriaT3.CellType.Hole) //Hay un agujero abajo { opinterfaz.UI.MoveHex(this.py, this.px, this.py, this.px + 1); System.Threading.Thread.Sleep(100); opinterfaz.UI.DeleteHex(this.py, this.px + 1); } else if (this.NE.pcolor == null && this.NE.ptipo == null && this.NE.celdatipo == LibreriaT3.CellType.Normal) //Hay un nada abajo { this.NE.pcolor = this.pcolor; this.NE.ptipo = this.ptipo; opinterfaz.UI.MoveHex(this.py, this.px, this.py, this.px + 1); } else if (this.NE.celdatipo == LibreriaT3.CellType.PortalB || this.NE.celdatipo == LibreriaT3.CellType.PortalO) //Hay un portal abajo { if (this.NE.celdatipo == LibreriaT3.CellType.PortalB) //Entra en B, sale en O { opinterfaz.portalO.pcolor = this.pcolor; opinterfaz.portalO.ptipo = this.ptipo; opinterfaz.UI.MoveHex(this.py, this.px, opinterfaz.portalO.py, opinterfaz.portalO.px); opinterfaz.portalO.pushportal("NE"); } else // vic { opinterfaz.portalB.pcolor = this.pcolor; opinterfaz.portalB.ptipo = this.ptipo; opinterfaz.UI.MoveHex(this.py, this.px, opinterfaz.portalB.py, opinterfaz.portalB.px); System.Threading.Thread.Sleep(100); opinterfaz.portalB.pushportal("NE"); } } else if (this.NE.celdatipo == LibreriaT3.CellType.ArrowN || this.NE.celdatipo == LibreriaT3.CellType.ArrowNE || this.NE.celdatipo == LibreriaT3.CellType.ArrowNW || this.NE.celdatipo == LibreriaT3.CellType.ArrowS || this.NE.celdatipo == LibreriaT3.CellType.ArrowSW || this.NE.celdatipo == LibreriaT3.CellType.ArrowNE) //Hay una flecha abajo. Las flechas nunca traen petalos encima. Se mueve el petalo a la flecha, se le entrega la informcion, y el metodo push flecha decide que hacer con ella { this.NE.pcolor = this.pcolor; this.NE.ptipo = this.ptipo; opinterfaz.UI.MoveHex(this.py, this.px, this.py, this.px + 1); this.NE.pushflecha(this); } this.pcolor = colorIn; this.ptipo = tipoIn; opinterfaz.UI.CreateHex(this.py, this.px, (LibreriaT3.PetalType) this.ptipo, (LibreriaT3.PetalColor) this.pcolor); } } else if (origen == this.SS) //SS = NN, this.px -> this.px, this.py -> this.py + 1 { if (this.NN != null) { if (this.NN.pcolor != null && this.NN.ptipo == LibreriaT3.PetalType.Normal && this.NN.celdatipo == LibreriaT3.CellType.Normal) { this.NN.push2(this, false); //envia la informacion que debe adoptar al siguiente nodo... opinterfaz.UI.MoveHex(this.py, this.px, this.py + 1, this.px); } else if (this.NN.celdatipo == LibreriaT3.CellType.Hole) //Hay un agujero abajo { opinterfaz.UI.MoveHex(this.py, this.px, this.py + 1, this.px); System.Threading.Thread.Sleep(100); opinterfaz.UI.DeleteHex(this.py + 1, this.px); } else if (this.NN.pcolor == null && this.NN.ptipo == null && this.NN.celdatipo == LibreriaT3.CellType.Normal) //Hay un nada abajo { this.NN.pcolor = this.pcolor; this.NN.ptipo = this.ptipo; opinterfaz.UI.MoveHex(this.py, this.px, this.py + 1, this.px); } else if (this.NN.celdatipo == LibreriaT3.CellType.PortalB || this.NN.celdatipo == LibreriaT3.CellType.PortalO) //Hay un portal abajo { if (this.NN.celdatipo == LibreriaT3.CellType.PortalB) //Entra en B, sale en O { opinterfaz.portalO.pcolor = this.pcolor; opinterfaz.portalO.ptipo = this.ptipo; opinterfaz.UI.MoveHex(this.py, this.px, opinterfaz.portalO.py, opinterfaz.portalO.px); opinterfaz.portalO.pushportal("NN"); } else // vic { opinterfaz.portalB.pcolor = this.pcolor; opinterfaz.portalB.ptipo = this.ptipo; opinterfaz.UI.MoveHex(this.py, this.px, opinterfaz.portalB.py, opinterfaz.portalB.px); System.Threading.Thread.Sleep(100); opinterfaz.portalB.pushportal("NN"); } } else if (this.NN.celdatipo == LibreriaT3.CellType.ArrowN || this.NN.celdatipo == LibreriaT3.CellType.ArrowNE || this.NN.celdatipo == LibreriaT3.CellType.ArrowNW || this.NN.celdatipo == LibreriaT3.CellType.ArrowS || this.NN.celdatipo == LibreriaT3.CellType.ArrowSW || this.NN.celdatipo == LibreriaT3.CellType.ArrowN) //Hay una flecha abajo. Las flechas nunca traen petalos encima. Se mueve el petalo a la flecha, se le entrega la informcion, y el metodo push flecha decide que hacer con ella { this.NN.pcolor = this.pcolor; this.NN.ptipo = this.ptipo; opinterfaz.UI.MoveHex(this.py, this.px, this.py + 1, this.px); this.NN.pushflecha(this); } this.pcolor = colorIn; this.ptipo = tipoIn; opinterfaz.UI.CreateHex(this.py, this.px, (LibreriaT3.PetalType) this.ptipo, (LibreriaT3.PetalColor) this.pcolor); } } else if (origen == this.SE) //SS = NW , this.px -> this.px - 1, this.py -> this.py + 1 { if (this.NW != null) { if (this.NW.pcolor != null && this.NW.ptipo == LibreriaT3.PetalType.Normal && this.NW.celdatipo == LibreriaT3.CellType.Normal) { this.NW.push2(this, false); //envia la informacion que debe adoptar al siguiente nodo... opinterfaz.UI.MoveHex(this.py, this.px, this.py + 1, this.px - 1); } else if (this.NW.celdatipo == LibreriaT3.CellType.Hole) //Hay un agujero abajo { opinterfaz.UI.MoveHex(this.py, this.px, this.py + 1, this.px - 1); System.Threading.Thread.Sleep(100); opinterfaz.UI.DeleteHex(this.py + 1, this.px - 1); } else if (this.NW.pcolor == null && this.NW.ptipo == null && this.NW.celdatipo == LibreriaT3.CellType.Normal) //Hay un nada abajo { this.NW.pcolor = this.pcolor; this.NW.ptipo = this.ptipo; opinterfaz.UI.MoveHex(this.py, this.px, this.py + 1, this.px - 1); } else if (this.NW.celdatipo == LibreriaT3.CellType.PortalB || this.NW.celdatipo == LibreriaT3.CellType.PortalO) //Hay un portal abajo { if (this.NW.celdatipo == LibreriaT3.CellType.PortalB) //Entra en B, sale en O { opinterfaz.portalO.pcolor = this.pcolor; opinterfaz.portalO.ptipo = this.ptipo; opinterfaz.UI.MoveHex(this.py, this.px, opinterfaz.portalO.py, opinterfaz.portalO.px); opinterfaz.portalO.pushportal("NW"); } else // vic { opinterfaz.portalB.pcolor = this.pcolor; opinterfaz.portalB.ptipo = this.ptipo; opinterfaz.UI.MoveHex(this.py, this.px, opinterfaz.portalB.py, opinterfaz.portalB.px); System.Threading.Thread.Sleep(100); opinterfaz.portalB.pushportal("NW"); } } else if (this.NW.celdatipo == LibreriaT3.CellType.ArrowN || this.NW.celdatipo == LibreriaT3.CellType.ArrowNE || this.NW.celdatipo == LibreriaT3.CellType.ArrowNW || this.NW.celdatipo == LibreriaT3.CellType.ArrowS || this.NW.celdatipo == LibreriaT3.CellType.ArrowSW || this.NW.celdatipo == LibreriaT3.CellType.ArrowNW) //Hay una flecha abajo. Las flechas nunca traen petalos encima. Se mueve el petalo a la flecha, se le entrega la informcion, y el metodo push flecha decide que hacer con ella { this.NW.pcolor = this.pcolor; this.NW.ptipo = this.ptipo; opinterfaz.UI.MoveHex(this.py, this.px, this.py + 1, this.px - 1); this.NW.pushflecha(this); } this.pcolor = colorIn; this.ptipo = tipoIn; opinterfaz.UI.CreateHex(this.py, this.px, (LibreriaT3.PetalType) this.ptipo, (LibreriaT3.PetalColor) this.pcolor); } } #endregion }
/// <summary> /// Crea una estructura de radio r a partir de una celda. Este metodo solo es funcional si es llamado desde una celda base (h = 0, d = 0). En otro caso, originará una estructura erronea. /// </summary> /// <param name="radio"></param> public void crecer(int radio) { if (radio > 0) { radio--; //---------- if (NN == null) { NN = new Celda(this.px, this.py + 1, listanodos); listanodos.Add(NN); } //---------- if (NW == null) { NW = new Celda(this.px - 1, this.py + 1, listanodos); listanodos.Add(NW); } //---------- if (NE == null) { NE = new Celda(this.px + 1, this.py, listanodos); listanodos.Add(NE); } //---------- if (SS == null) { SS = new Celda(this.px, this.py - 1, listanodos); listanodos.Add(SS); } //---------- if (SW == null) { SW = new Celda(this.px - 1, this.py, listanodos); listanodos.Add(SW); } //---------- if (SE == null) { SE = new Celda(this.px + 1, this.py - 1, listanodos); listanodos.Add(SE); } //---------- //Asignacion direcciones a los diversos nodos CW SW.SE = SS; SS.NE = SE; SE.NN = NE; NE.NW = NN; NN.SW = NW; NW.SS = SW; //Asignacion de direcciones a los diversos nodos CCW SW.NN = NW; NW.NE = NN; NN.SE = NE; NE.SS = SE; SE.SW = SS; SS.NW = SW; //Devoluciones al nodo original NN.SS = this; NE.SW = this; SE.NW = this; SS.NN = this; SW.NE = this; NW.SE = this; //Órdenes de crecimiento NN.crecer(radio); NW.crecer(radio); NE.crecer(radio); SE.crecer(radio); SS.crecer(radio); SW.crecer(radio); } }