Beispiel #1
0
 public CustomMapSprite(int userID, int mapID, Graphics g)
 {
     Console.WriteLine("kxjhscgc");
     arr     = new int[5, 11];
     gp      = new GraphicsPath();
     gObject = g;
     cMap    = new customMapBuilder(userID, mapID);
     circle  = new Rectangle(locX, locY, 60, 60);
     pieces  = new List <PuzzlePiece>();
     locXa   = new int[5];
     locYa   = new int[5];
     this.setUpMap();
     this.fillMap();
 }
Beispiel #2
0
 public CustomMapCreation()
 {
     cMap = new customMapBuilder(1, 1);
     SetStyle(ControlStyles.OptimizedDoubleBuffer, true);
     gp            = new GraphicsPath();
     gObject       = this.CreateGraphics();
     pieceArray    = cMap.getInitialPieces();
     customArr     = new List <PuzzlePiece>();
     invArr        = pieceArray;
     selectedPiece = 30;
     length        = pieceArray.Count;
     sprite1       = new Sprite2[length];
     for (int i = 0; i < length; i++)
     {
         sprite1[i] = new Sprite2(pieceArray[i].getLocX(), pieceArray[i].getLocY(), 60, pieceArray[i]);
     }
     InitializeComponent();
 }
Beispiel #3
0
        public CustomMap()
        {
            initial = true;
            SetStyle(ControlStyles.OptimizedDoubleBuffer, true);
            g = this.CreateGraphics();

            cMap       = new customMapBuilder(1, 1);
            gp         = new GraphicsPath();
            gObject    = this.CreateGraphics();
            pieceArray = cMap.inventoryPuzzlePieces;
            locXarray  = new int[length];
            locYarray  = new int[length];

            invArr = pieceArray;

            if (length > 3)
            {
                for (int i = 0; i < length - 3; i++)
                {
                    locYarray[i] = 400;
                }
                for (int i = length - 3; i < length; i++)
                {
                    locYarray[i] = 500;
                }
                for (int i = 0; i < length - 3; i++)
                {
                    locXarray[i] += i * 300;
                }
                for (int i = length - 3; i < length; i++)
                {
                    locXarray[i] += (i - (length - 3)) * 300;
                }
            }
            else
            {
                for (int i = 0; i < length; i++)
                {
                    locYarray[i] = 400;
                }
                for (int i = 0; i < length; i++)
                {
                    locXarray[i] += i * 300;
                }
            }



            if (length > 3)
            {
                for (int i = 0; i < length - 3; i++)
                {
                    locYarray[i] = 400;
                }
                for (int i = length - 3; i < length; i++)
                {
                    locYarray[i] = 500;
                }
                for (int i = 0; i < length - 3; i++)
                {
                    locXarray[i] += i * 300;
                }
                for (int i = length - 3; i < length; i++)
                {
                    locXarray[i] += (i - (length - 3)) * 300;
                }
            }
            else
            {
                for (int i = 0; i < length; i++)
                {
                    locYarray[i] = 400;
                }
                for (int i = 0; i < length; i++)
                {
                    locXarray[i] += i * 300;
                }
            }


            selectedPiece = 30;
            length        = pieceArray.Count;
            sprite1       = new Sprite2[length];
            for (int i = 0; i < length; i++)
            {
                sprite1[i] = new Sprite2(locXarray[i], locYarray[i], 60, pieceArray[i]);
            }



            InitializeComponent();
        }
Beispiel #4
0
        private void panel1_MouseUp_1(object sender, MouseEventArgs e)
        {
            bool             allAvailable = true;
            bool             done         = false;
            customMapBuilder mapa         = new customMapBuilder(1, 1);

            int[,] arrr = mapa.levelMap.mapArray;

            if (selectedPiece < length)
            {
                int d = (sprite1[selectedPiece].getLocX()) / 60;
                int f = (sprite1[selectedPiece].getLocY()) / 60;

                int x1 = (int)d;
                int y1 = (int)f;
                Console.WriteLine(sprite1[selectedPiece].getLocX());
                Console.WriteLine(sprite1[selectedPiece].getLocY());
                for (int i = 0; i < 4; i++)
                {
                    for (int j = 0; j < 4; j++)
                    {
                        if (sprite1[selectedPiece].pieceArray[i, j] && f < 5 && d < 11)
                        {
                            if (arrr[f, d] == -1)
                            {
                                allAvailable = true;
                            }
                            else
                            {
                                allAvailable = false;
                                break;
                            }
                            if (!allAvailable)
                            {
                                break;
                            }
                        }

                        d++;
                    }

                    d = d - 4;
                    if (!allAvailable)
                    {
                        break;
                    }

                    f++;
                }

                if (!allAvailable && selectedPiece < length)
                {
                    sprite1[selectedPiece].setLocX(locXarray[selectedPiece]);
                    sprite1[selectedPiece].setLocY(locYarray[selectedPiece]);
                }
                else
                {
                    sprite1[selectedPiece].setLocX(x1 * 60);
                    sprite1[selectedPiece].setLocY(y1 * 60);
                    for (int i = 0; i < 4; i++)
                    {
                        for (int j = 0; j < 4; j++)
                        {
                            if (sprite1[selectedPiece].pieceArray[j, i] && (x1 + i) < 11 && (y1 + j) < 5)
                            {
                                spriteMap2.arr[(y1 + j), (x1 + i)] = selectedPiece;
                            }
                        }
                    }


                    for (int i = 0; i < 5; i++)
                    {
                        for (int j = 0; j < 11; j++)
                        {
                            Console.Write(" | " + spriteMap2.arr[i, j]);
                        }
                        Console.WriteLine("");
                    }
                }


                if (isGameOver(spriteMap2.arr))
                {
                    MessageBox.Show("Game Over");
                }
            }

            if (selectedPiece < length)
            {
                Region rgn = new Region(sprite1[selectedPiece].gp);
                rgn.Union(sprite1[selectedPiece].gp);
                Invalidate(rgn, false);
                panel1.Invalidate();
                sprite1[selectedPiece].draw(g);
            }

            dragging = false;
        }