/// <summary> /// Main method for adding squares in system /// </summary> /// <param name="width">width of square</param> /// <param name="height">height of square</param> /// <param name="x">X of posiiton</param> /// <param name="y">Y of posiiton</param> /// <param name="team">team 0-blue, 1-pink, 2-error</param> /// <param name="rotate">is it rotated? 0 - no, 1 - yes</param> public void addSquare(int width, int height, int rotate, int team, int x, int y) { Point coords = new Point(x, y); if (isItFit(width, height, x, y, rotate, team) == 0) { Square.SquareInfo el = new Square.SquareInfo(coords, height.ToString() + "-" + width.ToString(), rotate, team); squaresList.Add(el); el = null; if (squaresList.Count % 2 == 1) { sumOfSquaresBlue += height * width; } else { sumOfSquaresPink += height * width; } if (rotate == 1) { y += 1 - width; int temp = width; width = height; height = temp; } for (int j = y; j < y + height; j++) { for (int i = x; i < x + width; i++) { gridArray[j, i] = squaresList.Count; } } } }
/// <summary> /// Draw squares from squares list /// </summary> /// <param name="spriteBatch">Sprite Batch</param> public void DrawSquares(SpriteBatch spriteBatch) { for (int n = 0; n < squaresList.Count; n++) { Square sq = new Square(spriteBatch); Square.SquareInfo el = squaresList[n]; sq.Draw(el.name, el.rotate, el.team, el.position); sq = null; } }
/// <summary> /// initialize variables and some display settings /// </summary> protected override void Initialize() { graphics.PreferredBackBufferWidth = GraphicsAdapter.DefaultAdapter.CurrentDisplayMode.Width; graphics.PreferredBackBufferHeight = GraphicsAdapter.DefaultAdapter.CurrentDisplayMode.Height; graphics.ApplyChanges(); graphics.ToggleFullScreen(); gridSystem = new GridSystem(); dice = new Dice(); dice2 = new Dice(); GraphicsDevice.Clear(Color.White); placingSquare = new Square.SquareInfo(new Point(0, 0), "1-1", 0, 0); base.Initialize(); }