public void fillMap() { circle.X = 0; circle.Y = 0; for (int i = 0; i < 11; i++) { for (int j = 0; j < 5; j++) { arr[j, i] = cMap.levelMap.mapArray[j, i]; } } pieces = cMap.getInitialPieces(); Console.WriteLine(pieces.Count); foreach (PuzzlePiece item in pieces) { Sprite2 sprite = new Sprite2(item.getLocX(), item.getLocY(), 60, item); sprite.draw(gObject); } SendToBack(); }
private void button4_Click(object sender, EventArgs e) { if (builder.getHint() == null) { MessageBox.Show("There is no hint"); } else { if (currentHint < builder.getHint().Count) { Graphics g = this.CreateGraphics(); Sprite2 sprite2 = new Sprite2(builder.getIndexedHint(currentHint).getLocX(), builder.getIndexedHint(currentHint).getLocY(), 60, builder.hintPuzzleList[currentHint]); int x = 0; for (int i = 0; x < length; i++) { if (sprite1[i].getLocX() == builder.getIndexedHint(currentHint).oldX&& sprite1[i].getLocY() == builder.getIndexedHint(currentHint).oldY) { selectedPiece = i; sprite1[selectedPiece].chooseSelected(true); Invalidate(); sprite1[selectedPiece].setLocX(builder.getIndexedHint(currentHint).getLocX()); sprite1[selectedPiece].setLocY(builder.getIndexedHint(currentHint).getLocY()); sprite1[selectedPiece].isMovable = false; Region rgn = new Region(sprite1[selectedPiece].gp); rgn.Union(sprite1[selectedPiece].gp); Invalidate(rgn, false); panel1.Invalidate(); sprite1[selectedPiece].draw(g); x = 30; } x++; } currentHint++; } else { MessageBox.Show("You have no more hint"); } } }
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(); }
public void fillCanvas() { circle.X = 0; circle.Y = 0; for (int i = 0; i < 11; i++) { for (int j = 0; j < 5; j++) { arr[j, i] = 0; } } for (int i = 0; i < 11; i++) { for (int j = 0; j < 5; j++) { arr[j, i] = lMap.getMapArray()[j, i]; } } pieces = lMap.getMapPuzzlePieces(); foreach (PuzzlePiece item in pieces) { Sprite2 sprite = new Sprite2(item.getLocX(), item.getLocY(), 60, item); sprite.draw(gObject); } /* foreach (PuzzlePiece item in pieces) * { * Console.WriteLine(item.getLocX()); * circle.X = item.getLocX(); * circle.Y = item.getLocY(); * bool[,] pieceArray = item.getPieceArray(); * int s = 0; * * for (int i = 0; i < 4; i++) * { * for (int j = 0; j < 4; j++) * { * if (pieceArray[i, j]) * { * * gp.AddEllipse(circle); * locXa[s] = circle.X; * locYa[s] = circle.Y; * * s++; * } * circle.X += 60; * } * circle.X -= 240; * circle.Y += 60; * } * * * gObject.DrawPath(item.getColor(), gp); * * gObject.FillPath(item.getBrush(), gp); * }*/ /* int count11 = 0; * int count9 = 0; * PuzzlePiece piece = null; * for (int i = 0; i < 11; i++) * { * circle.Y = 0; * circle.X = (i) * 60; * for (int j = 0; j < 5; j++) * { * * if (arr[j, i] == 11 && count11 == 0) * { * circle.Y = (j) * 60; * piece = new PuzzlePiece(11, 11, false); * Sprite2 sprite = new Sprite2(circle.X, circle.Y,60,piece); * sprite.drawing(gp); * count11++; * * /*PuzzlePiece piece = new PuzzlePiece(11,11,false); * gObject.DrawPath(piece.getColor(),gp); * gObject.FillPath(piece.getBrush(), gp);*/ // pieces.Add(piece); /* gObject.DrawEllipse(pink, circle); * gObject.FillEllipse(fillpink, circle); * * * } * else if (arr[j, i] == 9 &&count9 == 0) * { * circle.Y = (j) * 60; * piece = new PuzzlePiece(9, 9, false); * Sprite2 sprite = new Sprite2(circle.X, circle.Y, 60, piece); * sprite.drawing(gp); * count9++; * /*circle.Y = (j) * 60; * PuzzlePiece piece = new PuzzlePiece(9, 9, false); * Sprite2 sprite = new Sprite2(circle.X, circle.Y, 60, piece); * sprite.draw(gObject);*/ /* circle.Y = (j) * 60; * gObject.DrawEllipse(blue, circle); * gObject.FillEllipse(fillblue, circle); * * } * else if (arr[j, i] == 7) * { * circle.Y = (j) * 60; * gObject.DrawEllipse(yellow, circle); * gObject.FillEllipse(fillyellow, circle); * * } * else if (arr[j, i] == 8) * { * circle.Y = (j) * 60; * gObject.DrawEllipse(orange, circle); * gObject.FillEllipse(fillorange, circle); * * } * else if (arr[j, i] == 4) * { * circle.Y = (j) * 60; * gObject.DrawEllipse(green, circle); * gObject.FillEllipse(fillgreen, circle); * * } * else if (arr[j, i] == 1) * { * circle.Y = (j) * 60; * gObject.DrawEllipse(skyblue, circle); * gObject.FillEllipse(fillskyblue, circle); * * } * else if (arr[j, i] == 10) * { * circle.Y = (j) * 60; * gObject.DrawEllipse(violet, circle); * gObject.FillEllipse(fillviolet, circle); * * } * else if (arr[j, i] == 3) * { * circle.Y = (j) * 60; * gObject.DrawEllipse(darkblue, circle); * gObject.FillEllipse(filldarkblue, circle); * * } * else if (arr[j, i] == 2) * { * circle.Y = (j) * 60; * gObject.DrawEllipse(darkred, circle); * gObject.FillEllipse(filldarkred, circle); * * } * else if (arr[j, i] == 5) * { * circle.Y = (j) * 60; * gObject.DrawEllipse(red, circle); * gObject.FillEllipse(fillred, circle); * * } * else if (arr[j, i] == 6) * { * circle.Y = (j) * 60; * gObject.DrawEllipse(lightgreen, circle); * gObject.FillEllipse(filllightgreen, circle); * * } * else if (arr[j, i] == 12) * { * circle.Y = (j) * 60; * gObject.DrawEllipse(turquoise, circle); * gObject.FillEllipse(fillturquoise, circle); * * } * else * { * * } * * } * * * } * circle.X = 0; * circle.Y = 0; * gObject.DrawPath(piece.getColor(),gp); * gObject.FillPath(piece.getBrush(),gp);*/ SendToBack(); }
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(); }
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(); }