Example #1
0
 public void FinishTileButton(TileButton oThisTileButton)
 {
     oThisTileButton.Location   = new System.Drawing.Point(12 + (oThisTileButton.IXPos * 40), 60 + (oThisTileButton.IYPos * 40));
     oThisTileButton.BackColor  = System.Drawing.Color.Transparent;
     oThisTileButton.Size       = new System.Drawing.Size(40, 40);
     oThisTileButton.Image      = Image.FromFile(oThisTileButton.SImage);
     oThisTileButton.ImageAlign = ContentAlignment.TopLeft;
     oThisTileButton.TabStop    = false;
     oThisTileButton.FlatStyle  = FlatStyle.Flat;
     oThisTileButton.FlatAppearance.BorderSize = 0;
     oThisTileButton.Enabled     = true;
     oThisTileButton.AutoSize    = true;
     oThisTileButton.Margin      = new Padding(0, 0, 0, 0);
     oThisTileButton.Padding     = new Padding(0, 0, 0, 0);
     oThisTileButton.IOccupantId = 0;
     oThisTileButton.Click      += new EventHandler(Map_Click);
 }
Example #2
0
        private void Map_Click(object sender, EventArgs e)
        {
            TileButton oTB    = (TileButton)sender;
            string     sStats = "STATS";

            sStats += System.Environment.NewLine;
            sStats += "x: " + oTB.IXPos.ToString();
            sStats += System.Environment.NewLine;
            sStats += "y: " + oTB.IYPos.ToString();
            sStats += System.Environment.NewLine;
            sStats += "N: " + oTB.BNorthOpen.ToString();
            sStats += System.Environment.NewLine;
            sStats += "E: " + oTB.BEastOpen.ToString();
            sStats += System.Environment.NewLine;
            sStats += "S: " + oTB.BSouthOpen.ToString();
            sStats += System.Environment.NewLine;
            sStats += "W: " + oTB.BWestOpen.ToString();
            sStats += System.Environment.NewLine;
            sStats += "Image: " + oTB.SImage;
            MessageBox.Show(sStats);
        }
        public bool TileGoesOutOfBounds(TileButton oThisTileButton, int xSize, int ySize)
        {
            bool bGoesOutOfBounds = false;

            // check east side on x = 1
            if (oThisTileButton.IXPos == 1)
            {
                if (oThisTileButton.BEastOpen)
                {
                    return(true);
                }
            }
            // check west side on x = xSize
            if (oThisTileButton.IXPos == xSize)
            {
                if (oThisTileButton.BWestOpen)
                {
                    return(true);
                }
            }
            // check north side on y = 1
            if (oThisTileButton.IYPos == 1)
            {
                if (oThisTileButton.BNorthOpen)
                {
                    return(true);
                }
            }
            // check east side on y = ySize
            if (oThisTileButton.IYPos == ySize)
            {
                if (oThisTileButton.BSouthOpen)
                {
                    return(true);
                }
            }
            return(bGoesOutOfBounds);
        }
Example #4
0
        public TileButton NewRandomTile(int iXpos, int iYpos, string sColor)
        {
            int    iIndex     = 0;
            string sImageName = "";
            int    iPrevX     = 0;
            int    iPrevY     = 0;
            int    iNextX     = 0;
            int    iNextY     = 0;

            string[]   sSplitter;
            TileButton oThisTileButton = new TileButton();

            oThisTileButton.BNorthOpen = false;
            oThisTileButton.BSouthOpen = false;
            oThisTileButton.BEastOpen  = false;
            oThisTileButton.BWestOpen  = false;
            oThisTileButton.Location   = new System.Drawing.Point(12 + (iXpos * 40), 60 + (iYpos * 40));
            iIndex = lCoords.IndexOf(PathBuilder.MakeCoords(iXpos, iYpos));
            if ((iIndex > 0) && (iIndex < (lCoords.Count - 2)))
            {
                // path is made, use what is in the pathbuilder.
                // ignore first and last items
                // find neighbors
                sImageName = "solid.BMP";
                //lCoords.RemoveAt(iIndex - 1);
                sSplitter = lCoords[iIndex - 1].Split(',');
                iPrevX    = Int32.Parse(sSplitter[0]);
                iPrevY    = Int32.Parse(sSplitter[1]);
                sSplitter = lCoords[iIndex + 1].Split(',');
                iNextX    = Int32.Parse(sSplitter[0]);
                iNextY    = Int32.Parse(sSplitter[1]);
                // previous tile had x-axis (left/right) movement
                if (iPrevY == iYpos)
                {
                    if (iPrevX > iXpos)
                    {
                        // east must be open
                        oThisTileButton.BEastOpen = true;
                    }
                    else
                    {
                        // west must be open
                        oThisTileButton.BWestOpen = true;
                    }
                }
                else
                {
                    if (iPrevX > iXpos)
                    {
                        // south must be open
                        oThisTileButton.BSouthOpen = true;
                    }
                    else
                    {
                        // north must be open
                        oThisTileButton.BNorthOpen = true;
                    }
                }
                if (iNextY == iYpos)
                {
                    if (iNextX > iXpos)
                    {
                        // east must be open
                        oThisTileButton.BEastOpen = true;
                    }
                    else
                    {
                        // west must be open
                        oThisTileButton.BWestOpen = true;
                    }
                }
                else
                {
                    if (iNextX > iXpos)
                    {
                        // south must be open
                        oThisTileButton.BSouthOpen = true;
                    }
                    else
                    {
                        // north must be open
                        oThisTileButton.BNorthOpen = true;
                    }
                }

                if ((oThisTileButton.BNorthOpen) && (oThisTileButton.BEastOpen))
                {
                    sImageName = "L.BMP";
                }

                if ((oThisTileButton.BNorthOpen) && (oThisTileButton.BWestOpen))
                {
                    sImageName = "L2.BMP";
                }

                if ((oThisTileButton.BSouthOpen) && (oThisTileButton.BWestOpen))
                {
                    sImageName = "L3.BMP";
                }

                if ((oThisTileButton.BSouthOpen) && (oThisTileButton.BEastOpen))
                {
                    sImageName = "L4.BMP";
                }

                if ((oThisTileButton.BSouthOpen) && (oThisTileButton.BNorthOpen))
                {
                    sImageName = "ntos.BMP";
                }

                if ((oThisTileButton.BWestOpen) && (oThisTileButton.BEastOpen))
                {
                    sImageName = "etow.BMP";
                }
            }
            else
            {
                sImageName = "solid.BMP";
            }
            //switch (_myRandom.Next(50) % 7)
            //{
            //    case 0:
            //        sImageName = "L.BMP";
            //        oThisTileButton.BNorthOpen = true;
            //        oThisTileButton.BSouthOpen = false;
            //        oThisTileButton.BEastOpen = true;
            //        oThisTileButton.BWestOpen = false;
            //        break;
            //    case 1:
            //        sImageName = "L2.BMP";
            //        oThisTileButton.BNorthOpen = true;
            //        oThisTileButton.BSouthOpen = false;
            //        oThisTileButton.BEastOpen = false;
            //        oThisTileButton.BWestOpen = true;
            //        break;
            //    case 2:
            //        sImageName = "L3.BMP";
            //        oThisTileButton.BNorthOpen = false;
            //        oThisTileButton.BSouthOpen = true;
            //        oThisTileButton.BEastOpen = false;
            //        oThisTileButton.BWestOpen = true;
            //        break;
            //    case 3:
            //        sImageName = "L4.BMP";
            //        oThisTileButton.BNorthOpen = false;
            //        oThisTileButton.BSouthOpen = true;
            //        oThisTileButton.BEastOpen = true;
            //        oThisTileButton.BWestOpen = false;
            //        break;
            //    case 4:
            //        sImageName = "ntos.BMP";
            //        oThisTileButton.BNorthOpen = true;
            //        oThisTileButton.BSouthOpen = true;
            //        oThisTileButton.BEastOpen = false;
            //        oThisTileButton.BWestOpen = false;
            //        break;
            //    case 5:
            //        sImageName = "etow.BMP";
            //        oThisTileButton.BNorthOpen = false;
            //        oThisTileButton.BSouthOpen = false;
            //        oThisTileButton.BEastOpen = true;
            //        oThisTileButton.BWestOpen = true;
            //        break;
            //    case 6:
            //        sImageName = "solid.BMP";
            //        oThisTileButton.BNorthOpen = false;
            //        oThisTileButton.BSouthOpen = false;
            //        oThisTileButton.BEastOpen = false;
            //        oThisTileButton.BWestOpen = false;
            //        break;
            //}
            // catch the first and last items to ensure that they are castles
            if (((iXpos == 0) && (iYpos == 0)) || ((iXpos == (iXSize - 1)) && (iYpos == (iYSize - 1))))
            {
                sImageName = "castle.bmp";
                if ((iXpos == 0) && (iYpos == 0))
                {
                }
                else
                {
                }
            }
            oThisTileButton.IXPos = iXpos;
            oThisTileButton.IYPos = iYpos;
            string sPath = @"..\..\Resources\Images\" + sColor + @"\" + sImageName;

            oThisTileButton.SImage = sPath;
            return(oThisTileButton);
        }