/// <summary> /// Primer push: Solo se puede hacer en una celda que no contenga un pétalo /// </summary> /// <param name="colorIn"></param> /// <param name="tipoIn"></param> /// <returns></returns> public bool push0(LibreriaT3.PetalColor colorIn, LibreriaT3.PetalType tipoIn) { Celda[] celdas = { NN, NW, NE, SW, SE, SS }; if ((this.celdatipo == LibreriaT3.CellType.Normal || this.celdatipo == LibreriaT3.CellType.Hole) && this.pcolor == null) { foreach (Celda cell in celdas) { if (cell != null) { if ((cell.celdatipo == LibreriaT3.CellType.Normal) && (cell.ptipo == LibreriaT3.PetalType.Normal && cell.pcolor != null)) //Solo crea petalo si ya hay otro { cell.push1(this, colorIn, tipoIn); } } } } return(false); }
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); } } } }
/// <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 }