Beispiel #1
0
 public void initializePuzzle(int level, Graphics g)
 {
     this.level = level;
     mapBuilder = new MapBuilder(level);
     int[,] map = mapBuilder.getMapArray();
     mapSprite  = new MapSprite(level, g);               // init MapSprite
     pieces     = mapBuilder.getInventoryPuzzlePieces(); // init pieces
     hints      = mapBuilder.getHint();                  // init hints
     stopwatch.Start();
     numberOfMoves = 0;
     boardHeight   = 5;
     boardWidth    = 11;
     currentHint   = 1;
 }
        private void panel1_Paint(object sender, PaintEventArgs e)
        {
            Graphics toPass = panel1.CreateGraphics();

            this.e    = e;
            spriteMap = new MapSprite(level, toPass);
            g         = this.CreateGraphics();
            if (selectedPiece < length && sprite1[selectedPiece].isMovable)
            {
                sprite1[selectedPiece].chooseSelected(true);
            }
            if (selectedPiece < length && !sprite1[selectedPiece].isMovable)
            {
                sprite1[selectedPiece].chooseSelected(false);
            }
            for (int i = 0; i < length; i++)
            {
                sprite1[i].draw(toPass);
            }
        }
        private void button6_Click(object sender, EventArgs e)
        {
            currentHint = 0;
            spriteMap2  = new MapSprite(level, g);
            length      = gameManager.numberOfPuzzlePiece();
            pieceArray  = gameManager.getInventoryPuzzlePieces();
            locXarray   = new int[length];
            locYarray   = new int[length];
            builder     = new MapBuilder(level);
            timer1      = new Timer();
            timer2      = new Timer();
            timer3      = new Timer();

            Form1_Load(sender, formE);

            timer1.Start(); timer2.Start(); timer3.Start();
            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;
                }
            }



            for (int i = 0; i < sprite1.Length; i++)
            {
                sprite1[i].setLocX(locXarray[i]);
                sprite1[i].setLocY(locYarray[i]);
            }

            Invalidate();


            sprite1       = new Sprite2[length];
            selectedPiece = 30;
            for (int i = 0; i < length; i++)
            {
                sprite1[i] = new Sprite2(locXarray[i], locYarray[i], 60, pieceArray[i]);
            }
        }
        public Form2(int level)
        {
            initial = true;
            timer1  = new Timer();
            timer2  = new Timer();
            timer3  = new Timer();

            label1 = new Label();
            label2 = new Label();
            label3 = new Label();

            SetStyle(ControlStyles.OptimizedDoubleBuffer, true);
            currentHint = 0;
            gameManager = new GameManager();
            this.level  = gameManager.getLevel(level);
            g           = this.CreateGraphics();
            gameManager.initializePuzzle(level, g);
            spriteMap2 = new MapSprite(level, g);
            length     = gameManager.numberOfPuzzlePiece();
            pieceArray = gameManager.getInventoryPuzzlePieces();
            locXarray  = new int[length];
            locYarray  = new int[length];
            builder    = new MapBuilder(level);


            timer1.Start(); timer2.Start(); timer3.Start();

            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;
                }
            }



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



            InitializeComponent();
        }