Example #1
0
 public Grid()
 {
     m_field = new Square[NumberOfRows, NumberOfColumns];
     for (int r = 0; r < NumberOfRows; ++r)
         for (int c = 0; c < NumberOfColumns; ++c)
             m_field[r, c] = new Square(r, c);
 }
Example #2
0
        public SquareGrid(int[,] map, float squareSize)
        {
            int nodeCountX = map.GetLength(0);
            int nodeCountY = map.GetLength(1);
            float mapWidth = nodeCountX * squareSize;
            float mapHeight = nodeCountY * squareSize;

            ControlNode[,] controlNodes = new ControlNode[nodeCountX, nodeCountY];

            for (int x = 0; x < nodeCountX; x++)
            {
                for (int y = 0; y < nodeCountY; y++)
                {
                    Vector3 pos = new Vector3(-mapWidth / 2 + x * squareSize + squareSize / 2, 0, -mapHeight / 2 + y * squareSize + squareSize / 2);
                    controlNodes[x, y] = new ControlNode(pos, map[x, y] == 1, squareSize);
                }
            }

            Squares = new Square[nodeCountX - 1, nodeCountY - 1];
            for (int x = 0; x < nodeCountX - 1; x++)
            {
                for (int y = 0; y < nodeCountY - 1; y++)
                {
                    Squares[x, y] = new Square(controlNodes[x, y + 1], controlNodes[x + 1, y + 1], controlNodes[x + 1, y], controlNodes[x, y]);
                }
            }
        }
Example #3
0
    private bool done = false; // true when game is over                 

    // initialize variables and thread for connecting to server
    private void TicTacToeClientForm_Load(object sender, EventArgs e)
    {
        board = new Square[3, 3];

        // create 9 Square objects and place them on the board
        board[0, 0] = new Square(board0Panel, ' ', 0);
        board[0, 1] = new Square(board1Panel, ' ', 1);
        board[0, 2] = new Square(board2Panel, ' ', 2);
        board[1, 0] = new Square(board3Panel, ' ', 3);
        board[1, 1] = new Square(board4Panel, ' ', 4);
        board[1, 2] = new Square(board5Panel, ' ', 5);
        board[2, 0] = new Square(board6Panel, ' ', 6);
        board[2, 1] = new Square(board7Panel, ' ', 7);
        board[2, 2] = new Square(board8Panel, ' ', 8);

        // create a SolidBrush for writing on the Squares
        brush = new SolidBrush(Color.Black);

        // make connection to server and get the associated
        // network stream                                  
        connection = new TcpClient("127.0.0.1", 50000);
        stream = connection.GetStream();
        writer = new BinaryWriter(stream);
        reader = new BinaryReader(stream);

        // start a new thread for sending and receiving messages
        outputThread = new Thread(new ThreadStart(Run));
        outputThread.Start();
    } // end method TicTacToeClientForm_Load
 internal BoardCreator (Square[,] grid) {
     Debug.Assert (grid != null);
     this.grid = grid;
     this.board = new Board (grid);
     this.width = board.Width;
     this.height = board.Height;
 }
Example #5
0
        private Square[,] m_field; //dvodimenzijalno polje

        #endregion Fields

        #region Constructors

        //konstruktor klase
        public Grid()
        {
            m_field = new Square[NumberOfRows, NumberOfColumns];
            for (int r = 0; r < 10; ++r) //rows
                for (int c = 0; c < 10; ++c) //columns
                    m_field[r, c] = new Square(r, c); //inicijalizacija
        }
Example #6
0
File: Form.cs Project: huzi96/Game0
        public MainForm()
        {
            InitializeComponent();
            controller = new Controller(this);

            int panelWidth = this.MainBoard.Width;
            int squareMargin = 10;
            int width = panelWidth / 4;
            int size = 150;
            blocks = new Square[4, 4];
            for (int i = 0; i < 4; i++)
            {
                for (int j = 0; j < 4; j++)
                {
                    Square block = new Square();
                    blocks[i, j] = block;
                    block.Left = j * size;
                    block.Top = i * size;
                    block.Width = size;
                    block.Height = size;
                    block.Visible = true;
                    block.BackColor = Color.FromArgb(0, 100, 100, 100);
                    block.Margin = new Padding(squareMargin);
                    MainBoard.Controls.Add(block);
                }
            }
        }
Example #7
0
        public AutoBoard(Difficulty difficulty)
        {
            _board = new Square[difficulty.Height,difficulty.Width];
            CurrentState = State.Playing;
            CurrentDifficulty = difficulty;

            AddRandomMines(CurrentDifficulty.Mines);
        }
Example #8
0
 public GameEngine(int rows, int columns, int numberOfMines)
 {
     this.rows = rows;
     this.columns = columns;
     this.numberOfMines = numberOfMines;
     squares = new Square[rows, columns];
     tiles = new ITile[rows,columns];
 }
Example #9
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Board"/> class.
 /// </summary>
 /// <param name="width">
 /// The width of the board
 /// </param>
 /// <param name="height">
 /// The height of the board
 /// </param>
 /// <param name="floorTexture">
 /// The floor Texture.
 /// </param>
 public Board(int width, int height, Texture2D floorTexture)
 {
     Contract.Requires(width > 1 && height > 1);
     bounds = new Rectangle(0, 0, width, height);
     board = new Square[width, height];
     canSpawn = new bool[width, height];
     this.floorTexture = floorTexture;
     revealedAreas.Add(0);
 }
Example #10
0
        private List<Unit> units; // list of your units on map

        #endregion Fields

        #region Constructors

        /* constructor - note that we probably won't use this one much in the final game.
         * Rather, we will usually use the default constructor (which initializes all the variables as nulls)
         * and then use the Load method to get all the info from a text file
         * */
        public Map(Square[,] squares, List<Unit> enemies, int rows, int cols)
        {
            this.squares = squares;
            this.enemies = enemies;
            this.rows = rows;
            this.cols = cols;
            this.offset = Vector2.Zero;
            this.units = new List<Unit>();
        }
Example #11
0
 /// <summary>
 /// Initialises a new instance of the ChessBoard class.
 /// </summary>
 public ChessBoard()
 {
     this.Round = 1;
     this.squares = new Square[8, 8];
     for (int i = 0; i < 8; i++) {
         for (int j = 0; j < 8; j++) {
             this.squares[i, j] = new Square();
         }
     }
 }
Example #12
0
 public void DrawGrid()
 {
     squares = new Square[row, col];
     for (int i = 0; i < row; i++)
         for (int j = 0; j < col; j++)
         {
             Square sqr = new Square(this, i, j);   //this is sending the game, probably can send the panel from game.Panel
             squares[i, j] = sqr;
         }
 }
Example #13
0
        public Minesweeper(int rows, int columns, int mines)
        {
            Rows = rows;
            Columns = columns;
            Mines = mines;

            _grid = new Square[Rows,Columns];
            _minesLocation = new HashSet<int>();

            ResetGrid();
        }
Example #14
0
        /**
         * Basic constructor. Does not conduct any dimension
         * checks.
         */
        public Tour(int width, int height)
        {
            Board = new Square[width, height];

            for (int x = 0; x < width; x++)
                for (int y = 0; y < height; y++)
                    Board[x, y] = new Square(x, y);

            Width = width;
            Height = height;
        }
Example #15
0
 public void DrawGrid()
 {
     squares = new Square[row, col];
     for (int i = 0; i < row; i++)
     {
         for (int j = 0; j < col; j++)
         {
             Square sqr = new Square(this, i, j);   //this is sending the game, probably can send the panel from game.Panel
             squares[i, j] = sqr;
         }
     }
 }
Example #16
0
        public Chessboard()
        {
            squares = new Square[FilesNumber, RanksNumber];

            for (int i = 0; i < FilesNumber; i++)
            {
                for (int j = 0; j < RanksNumber; j++)
                {
                    squares[i, j] = new Square(Char.Parse(Enum.GetName(typeof(fileNames), i)), j + 1, (i + j) % 2 == 0 ? blackColor : whiteColor);
                }
            }
        }
Example #17
0
 public ChessBoardSnapshot(int turn, Square[,] squares)
 {
     this.turn      = turn;
     pieceSnapshots = new List <PieceSnapshot>();
     foreach (Square square in squares)
     {
         if (square.piece != null)
         {
             pieceSnapshots.Add(new PieceSnapshot(square.piece));
         }
     }
 }
Example #18
0
 /// <summary>
 /// Instantiate <see cref="Board"/>
 /// </summary>
 public Board()
 {
     _squares = new Square[Size, Size];
     for (int file = 1; file <= Size; file++)
     {
         for (int rank = 1; rank <= Size; rank++)
         {
             var fileEnum = (File) file;
             this[Square.GetId(fileEnum, rank)] = new Square(fileEnum, rank);
         }
     }
 }
Example #19
0
 private void CreateSquares(BoardArray board)
 {
     squares = new Square[countY, countX];
     for (int i = 0; i < countY; i++)
     {
         for (int j = 0; j < countX; j++)
         {
             CreateSquare(i, j, board.rows[i].row[j]);
         }
     }
     StartCoroutine(ShowCreatedSquares());
 }
Example #20
0
 /// <summary>
 /// Instantiate <see cref="Board"/>
 /// </summary>
 public Board()
 {
     _squares = new Square[Size, Size];
     for (int file = 1; file <= Size; file++)
     {
         for (int rank = 1; rank <= Size; rank++)
         {
             var fileEnum = (File)file;
             this[Square.GetId(fileEnum, rank)] = new Square(fileEnum, rank);
         }
     }
 }
Example #21
0
        public SquareMatrix(SquareEdgeNodeMatrix edgeNodes)
        {
            squares = new Square[edgeNodes.Width - 1, edgeNodes.Height - 1];

            for (var x = 0; x < edgeNodes.Width - 1; x++)
            {
                for (var y = 0; y < edgeNodes.Height - 1; y++)
                {
                    squares[x, y] = CreateSquare(edgeNodes, x, y);
                }
            }
        }
Example #22
0
File: Ai.cs Project: hetag34/ship34
        public Square finishShip(Board board)
        {
            Square[,] squares = board.AllSquares();
            //SIMPLIFY
            for (int i = 0; i < squares.GetLength(0); i++)
            {
                for (int j = 0; j < squares.GetLength(1); j++)
                {
                    if (board.IsShipShotNotSunk(i, j))
                    {
                        if (i + 1 < squares.GetLength(0) && board.IsShipShotNotSunk(i + 1, j))
                        {
                            int index = i + 2;
                            while (index < squares.Length && board.IsShipShotNotSunk(index, j))
                            {
                                index++;
                            }
                            return(squares[index, j]);
                        }

                        if (i - 1 > 0 && board.IsShipShotNotSunk(i - 1, j))
                        {
                            int index = i - 2;
                            while (index > 0 && board.IsShipShotNotSunk(index, j))
                            {
                                index--;
                            }
                            return(squares[index, j]);
                        }

                        if (j + 1 < squares.GetLength(1) && board.IsShipShotNotSunk(i, j + 1))
                        {
                            int index = j + 2;
                            while (index < squares.Length && board.IsShipShotNotSunk(i, index))
                            {
                                index++;
                            }
                            return(squares[i, index]);
                        }
                        if (j - 1 > 0 && board.IsShipShotNotSunk(i, j - 1))
                        {
                            int index = j - 2;
                            while (index > 0 && board.IsShipShotNotSunk(i, index))
                            {
                                index--;
                            }
                            return(squares[i, index]);
                        }
                    }
                }
            }
            return(null);
        }
Example #23
0
 public Board(bool pb)
 {
     playerBoard = pb;
     grid        = new Square[10, 10];
     for (int i = 0; i < 10; i++)
     {
         for (int j = 0; j < 10; j++)
         {
             grid[i, j] = new Square(pb);
         }
     }
 }
Example #24
0
 private static void backRank(Colour inColour, int y, ref Square[,] inBoard)
 {
     //Ew
     inBoard[0, y] = new Square('A', y + 1, new Rook(inColour));
     inBoard[1, y] = new Square('B', y + 1, new Knight(inColour));
     inBoard[2, y] = new Square('C', y + 1, new Bishop(inColour));
     inBoard[3, y] = new Square('D', y + 1, new Queen(inColour));
     inBoard[4, y] = new Square('E', y + 1, new King(inColour));
     inBoard[5, y] = new Square('F', y + 1, new Bishop(inColour));
     inBoard[6, y] = new Square('G', y + 1, new Knight(inColour));
     inBoard[7, y] = new Square('H', y + 1, new Rook(inColour));
 }
Example #25
0
        public Board(int matrixSize)
        {
            Matrix = new Square[matrixSize + 2, matrixSize + 2];

            for (uint x = 0; x <= matrixSize + 1; x++)
            {
                for (uint y = 0; y <= matrixSize + 1; y++)
                {
                    Matrix[x, y] = new Square(x, y);
                }
            }
        }
Example #26
0
        public Gameboard()
        {
            gameSquares = new Square[GAMEBOARD_HEIGHT, GAMEBOARD_WIDTH];

            for (int _row = 0; _row < GAMEBOARD_HEIGHT; ++_row)
            {
                for (int _column = 0; _column < GAMEBOARD_WIDTH; ++_column)
                {
                    gameSquares[_row, _column] = new Square(_row, _column);
                }
            }
        }
Example #27
0
    private void CreateMap(int x, int y)
    {
        array = new Square[x, y];

        for (int i = 0; i < x; i++)
        {
            for (int j = 0; j < y; j++)
            {
                array[i, j] = new Square();
            }
        }
    }
Example #28
0
 //constructor method
 public Puzzle(int size)
 {
     N    = size;
     grid = new Square[size, size];
     for (int i = 0; i < this.N; i++) // looping through the 2-D array and creating all the nessacary instances of the square class
     {
         for (int j = 0; j < this.N; j++)
         {
             grid[i, j] = new Square();
         }
     }
 }
Example #29
0
    public override void Evaluate(Square[,] b)
    {
        Square[,] board = null;
        if (b == null)
        {
            board = Board.Instance.SquareMatrix;
        }
        else
        {
            board = b;
        }
        possibleMoves.Clear();
        int  actualX = this.actualSquare.X;
        int  actualY = this.actualSquare.Y;
        bool right = true, left = true, up = true, down = true;
        bool rightUp = true, rightDown = true, leftUp = true, leftDown = true;

        int i = 1;

        if (rightUp)
        {
            EvaluateBoardInPosition(board, actualX + i, actualY + i, out rightUp);
        }
        if (rightDown)
        {
            EvaluateBoardInPosition(board, actualX + i, actualY - i, out rightDown);
        }
        if (leftDown)
        {
            EvaluateBoardInPosition(board, actualX - i, actualY - i, out leftDown);
        }
        if (leftUp)
        {
            EvaluateBoardInPosition(board, actualX - i, actualY + i, out leftUp);
        }

        if (right)
        {
            EvaluateBoardInPosition(board, actualX + i, actualY, out right);
        }
        if (left)
        {
            EvaluateBoardInPosition(board, actualX - i, actualY, out left);
        }
        if (up)
        {
            EvaluateBoardInPosition(board, actualX, actualY + i, out up);
        }
        if (down)
        {
            EvaluateBoardInPosition(board, actualX, actualY - i, out down);
        }
    }
        public void StartCustomGame(int width, int height, int mines)
        {
            playField = gameManager.NewCustomGame(width, height, mines);

            previousGameMode     = "custom";
            previousCustomWidth  = width;
            previousCustomHeight = height;
            previousCustomMines  = mines;
            //previousCustomMineSaturation = saturation;

            DrawPlayField(playField);
        }
Example #31
0
 public static void PrintResult(int rows, int columns, Square[,] squares)
 {
     for (int i = 0; i < rows; i++)
     {
         Console.Write("\r\n");
         for (int j = 0; j < columns; j++)
         {
             Console.Write(squares[i, j].ToString());
         }
     }
     Console.Write("\r\n");
 }
Example #32
0
 internal BoardGame(short size)
 {
     this.m_Size = size;
     m_Board     = new Square[this.m_Size, this.m_Size];
     for (int i = 0; i < this.m_Size; i++)
     {
         for (int j = 0; j < this.m_Size; j++)
         {
             m_Board[i, j] = new Square(Square.eSquareType.None, i, j);
         }
     }
 }
Example #33
0
 private void CreateSquares()
 {
     squares = new Square[countY, countX];
     for (int i = 0; i < countY; i++)
     {
         for (int j = 0; j < countX; j++)
         {
             CreateSquare(i, j);
         }
     }
     StartCoroutine(ShowCreatedSquares());
 }
Example #34
0
 /// <summary>
 /// Generate a 1-1 copy of the given board
 /// </summary>
 /// <param name="board"></param>
 /// <returns></returns>
 public Square[,] GenerateBoardCopy(Square[,] board)
 {
     Square[,] copy = new Square[8, 8];
     for (int i = 0; i < 8; i++)
     {
         for (int j = 0; j < 8; j++)
         {
             copy[i, j] = new Square(board[i, j]);
         }
     }
     return(copy);
 }
Example #35
0
        /// <summary>
        /// moves player left one square (if this is within the bounds of the squares)
        /// </summary>
        /// <param name="squares"></param>
        public void moveLeft(Square[,] squares)
        {
            int newCol = column - 1;

            if (newCol >= 0)//checks this move is allowed
            {
                savePath();
                hide(squares);
                column = newCol;
                show(squares);
            }
        }
Example #36
0
        /// <summary>
        /// moves player down one square (if move is within the bounds of the grid)
        /// </summary>
        /// <param name="squares"></param>
        public void moveDown(Square[,] squares)
        {
            int newRow = row + 1;

            if (newRow < squares.GetLength(0))//check move is allowed
            {
                savePath();
                hide(squares);
                row = newRow;
                show(squares);
            }
        }
Example #37
0
 public Player(Player other, Square[,] newBoard)
 {
     iD = other.iD;
     this.modSquareTableValue = other.modSquareTableValue;
     this.type = other.type;
     pieces    = new List <Piece>();
     for (int i = 0; i < other.pieces.Count; i++)
     {
         var newPiece = other.pieces[i].Copy(newBoard[other.pieces[i].ActualSquare.Y, other.pieces[i].ActualSquare.X]);
         newPiece.SetPropietary(this);
     }
 }
Example #38
0
        // used to draw the game
        public void OnDrawing(Tetris.GameBase.TetrisGame game,
                              Tetris.GameBase.TetrisGame.DrawEventArgs e)
        {
            Square[,] image = game.Image;
            if (imageCache == null)
            {
                imageCache = new int[image.GetUpperBound(0) + 1, image.GetUpperBound(1) + 1];
                Array.Clear(imageCache, 0, (image.GetUpperBound(0) + 1) * (image.GetUpperBound(1) + 1));
            }
            int i, j;

            for (i = 0; i < game.Height; i++)
            {
                for (j = 0; j < game.Width; j++)
                {
                    // only draw the changed part
                    if ((image[i, j] == null && imageCache[i, j] != 0) || (image[i, j] != null && image[i, j].Color + image[i, j].SubId != imageCache[i, j]))
                    {
                        imageCache[i, j] = image[i, j] == null ? 0 : image[i, j].Color + image[i, j].SubId;
                        try
                        {
                            squaresMatrix[i, j].Dispatcher.Invoke(
                                new Action(
                                    delegate
                            {
                                /*
                                 * squaresMatrix[i, j].Fill =
                                 *  new SolidColorBrush(
                                 *      colorMap[
                                 *          image[i, j] == null
                                 *              ? 0
                                 *              : (image[i, j].Color < colorMap.Length
                                 *                  ? image[i, j].Color
                                 *                  : colorMap.Length - 1)]);
                                 */
                                squaresMatrix[i, j].Fill = SquareGenerator.brushClone(
                                    brushesMap[
                                        image[i, j] == null
                                                    ? 0
                                                        : (image[i, j].Color + image[i, j].SubId
                                                           < brushesMap.Length
                                                            ? image[i, j].Color + +image[i, j].SubId
                                                            : brushesMap.Length - 1)]);
                            }
                                    ));
                        }
                        catch
                        {
                        }
                    }
                }
            }
        }
Example #39
0
    public void RunMiniMax(Player maxPlayer, Player minPlayer, Square[,] board)
    {
        vueltas = 0;
        int maxValue = MiniMaxFunctionRoot(maxPlayer, minPlayer, board);

        Debug.Log("Total Boards Evaluated: " + vueltas.ToString());
        pieceToMove.Move(bestMove.Square.RelatedBehaviour);
        bestMove.RunCallback();

        GameController.Instance.ChangeTurns();
        GameController.Instance.EvaluatePlayers();
    }
Example #40
0
 private void printTheGrid(int maxX, int maxY, Square[,] grid)
 {
     for (int x = 0; x < maxX; x++)
     {
         for (int y = 0; y < maxY; y++)
         {
             Console.Write(grid[x, y].ID);
         }
         Console.Write("\n");
     }
     Console.ReadLine();
 }
Example #41
0
 public static void printBoard(Square[,] board)
 {
     for (int y = 0; y < Board.ySize; y++)
     {
         string s = "";
         for (int x = 0; x < Board.xSize; x++)
         {
             s += board[x, y].playerSign + "\t";
         }
         Console.WriteLine(s);
     }
 }
Example #42
0
 public void CreateZone(Square [,] square)
 {
     for (int i = 0; i < 10; i++)
     {
         for (int a = 0; a < 10; a++)
         {
             square[i, a].y    = i;
             square[i, a].x    = a;
             square[i, a].data = " ";
         }
     }
 }
Example #43
0
        /// <summary>
        /// Moves player right one square (if move is within grid)
        /// </summary>
        /// <param name="squares"></param>
        public void moveRight(Square[,] squares)
        {
            int newCol = column + 1;

            if (newCol < squares.GetLength(0))//checks move is allowed
            {
                savePath();
                hide(squares);
                column = newCol;
                show(squares);
            }
        }
Example #44
0
        /// <summary>
        /// Moves player up one square (checks if move is allowed first)
        /// </summary>
        /// <param name="squares"></param>
        public void moveUp(Square[,] squares)
        {
            int newRow = row - 1;

            if (newRow >= 0)//check if move is allowed
            {
                savePath();
                hide(squares);
                row = newRow;
                show(squares);
            }
        }
Example #45
0
        public static Bitmap drawBoard(Square[,] bord)
        {
            Bitmap bob = new Bitmap(50, 100);

            for (int i = 1; i < 50; i++)
            {
                for (int j = 1; j < 100; j++)
                {
                    if (bord[i / 10, j / 10] == null)
                    {
                        bob.SetPixel(i, 100 - j, Color.Black);
                    }
                    else if (bord[i / 10, j / 10].color == 1)
                    {
                        bob.SetPixel(i, 100 - j, Color.Red);
                    }
                    else if (bord[i / 10, j / 10].color == 2)
                    {
                        bob.SetPixel(i, 100 - j, Color.Green);
                    }
                    else if (bord[i / 10, j / 10].color == 3)
                    {
                        bob.SetPixel(i, 100 - j, Color.Purple);
                    }
                    else
                    {
                        bob.SetPixel(i, 100 - j, Color.Black);
                    }
                }
            }
            return(bob);

            /*Graphics g = Graphics.FromImage(bob);
             * Brush wb = Brushes.White;
             * Brush rb = Brushes.Red;
             * Brush gb = Brushes.Green;
             * Brush pb = Brushes.Purple;
             * for (int i = 0; i < 5; i++)
             * {
             *  for (int j = 0; j < 10; j++)
             *  {
             *      if (bord[i,j] == null) { g.FillRectangle(wb, i * 5, j * 5, i * (5 + 1), j * (5 + 1)); }
             *      else if (bord[i, j].color == 1) { g.FillRectangle(rb, i * 5, j * 5, i * (5 + 1), j * (5 + 1)); }
             *      else if (bord[i, j].color == 2) { g.FillRectangle(gb, i * 5, j * 5, i * (5 + 1), j * (5 + 1)); }
             *      else if (bord[i, j].color == 3) { g.FillRectangle(pb, i * 5, j * 5, i * (5 + 1), j * (5 + 1)); }
             *  }
             * }
             *
             * bob.Save("myimage.png");*/

            //return false;
        }
Example #46
0
 // Constructor
 public Grid(int width, int height)
 {
     this.width = width;
     this.height = height;
     grid = new Square[(int)width, (int)height];
     for(int i = 0; i < width; i++) {
         for(int j = 0; j < height; j++) {
             Vector2 loc = new Vector2(i, j);
             Square sq = new Square(this, loc, new Vector3(i, j, 0.0f));
             grid[i, j] = sq;
         }
     }
 }
 public void GenerateEmpty(int hauteurArg, int largeurArg, bool stockReferences = false)
 {
     Square[,] tab = new Square[hauteurArg, largeurArg];
     this.transform.position = new Vector3(0.5f,0.5f,0);
     for (int i= 0; i<hauteurArg; i++)
     {
         for(int j = 0; j<largeurArg; j++)
         {
             tab[i,j] = (Square) Instantiate (emptySquare, new Vector3(this.transform.position.x + j, this.transform.position.y + i, 0), Quaternion.identity);
             tab[i,j].transform.SetParent(this.transform);
         }
     }
     mapSquares = tab;
 }
        public Grid(List<List<Square>> squares)
        {
            _grid = new Square[squares.Count, squares.Count];

            var size = squares.Count;

            for (var x = 0; x < size; x++)
            {
                for (var y = 0; y < size; y++)
                {
                    _grid[x, y] = squares[y][x];
                }
            }
        }
Example #49
0
        public Board(int size)
        {
            RowSize = size;

            // Create the array to store the squares.
            _board = new Square[RowSize, RowSize];
            // Populate the board with Square objects.
            for (int i = 0; i < RowSize; ++i)
            {
                for (int j = 0; j < RowSize; ++j)
                {
                    _board[i, j] = new Square(i, j);
                }
            }
        }
Example #50
0
        public Card(int rows)
        {
            _rows = rows;
            _card = new Square[rows, 5];

            int currentStart = 1;
            for (int col = 0; col < 5; col++)
            {
                var randomise = Randomizer.Randomize(currentStart, currentStart + rows - 1);

                for (int row = 0; row < rows; row++)
                    _card[row, col] = new Square(randomise[row]);

                currentStart = currentStart + rows;
            }
        }
 public MapManager(int size, MapTextures mapTex, CowPiece head, Game1 game)
 {
     this.size = size;
     map = new Square[size,size];
     this.grassTexture = mapTex.grassTexture;
     this.hedgeTexture = mapTex.hedgeTexture;
     this.hedgeVertTexture = mapTex.hedgeVertTexture;
     this.hedgeCornerTexturetl = mapTex.hedgeCornerTexturetl;
     this.hedgeCornerTexturetr = mapTex.hedgeCornerTexturetr;
     this.hedgeCornerTexturebl = mapTex.hedgeCornerTexturebl;
     this.hedgeCornerTexturebr = mapTex.hedgeCornerTexturebr;
     this.hedgeCrossTexture = mapTex.hedgeCrossTexture;
     this.foodTexture = mapTex.foodTexture;
     headPiece = head;
     this.game = game;
     createMap();
 }
Example #52
0
 //reads all the info for a map from a text file.
 public void Load(string filename)
 {
     StreamReader stream = new StreamReader(filename);
     string line = stream.ReadLine();
     this.rows = int.Parse(line); // first line is the # of rows
     line = stream.ReadLine();
     this.cols = int.Parse(line); // second line is the # of columns
     this.squares = new Square[rows, cols];
     for (int i = 0; i < rows; i++)
     {
         for (int j = 0; j < cols; j++)  // rest of the lines are each one square
         {
             line = stream.ReadLine();
             squares[i, j].Load(line);
         }
     }
 }
        private void SetupEntityGrid()
        {
            GameUniformGrid.Children.Clear();
            GameBoard = new Square[25, 25];

            for (int x = 0; x < 25; x++)
            {
                for (int y = 0; y < 25; y++)
                {
                    Square r = new Square { Background = Brushes.MintCream };
                    GameBoard[x, y] = r;
                    GameBoard[x, y].Margin = new Thickness(1);
                    GameUniformGrid.Children.Add(GameBoard[x, y]);
                    Console.WriteLine(GameBoard[x,y]);

                }
            }
        }
	// Use this for initialization
	void Start () {
		//if suggesting, make a pool
		if (suggesting) {
			pool = new ArrayList ();
			for (int i = 0; i < size * size; i++) {
				pool.Add (i / size + 1);
			}
		}
		grid = new Square [size, size];
//		counter = new int[10];

		//very hacky way of filling the grid
		//use overlap spheres to find which square is at each position
		//may change later

		for (int i = 0; i < size; i++) {
			for (int j = 0; j < size; j++) {
				grid[i,j] = (Physics.OverlapSphere(new Vector3((-1 * size + 1 + 2f*i), (-1 * size + 1 + 2f*j), 0f), 0.01f))[0].gameObject.GetComponent<Square>();
//				grid [i, j].active = true;
//				counter[grid[i,j].number]++;
				if (suggesting && grid [i, j].number != 0) {
					pool.Remove (grid [i, j].number);
				}
			}
		}
	
		//if suggesting, generate the nums for the first round
		if (suggesting) {
			Debug.Log ("GENERATING NEW SET");
			suggestions = generateNums ();
			string numBuf = "";
			for (int i = 0; i < numSuggestions; i++) {
				numBuf = numBuf + " | " + suggestions [i];
			}
			Debug.Log(numBuf + " | ");
			suggestionTimer = 0f;
			suggestionIndex = 0;
		}


//		totalNumsPlaced = 0;
			
	}
Example #55
0
        private Board()
        {
            matrix = new Square[NUM_ROWS, NUM_ROWS];
            whitePieces = new List();
            blackPieces = new List();

            this.Size = new Size(480, 480);
            this.Location = new Point(30, 30);

            // Create the squares

            int h;
            int v = 0;

            for (int i = 0; i < NUM_ROWS; i++)
            {
                h = 0;

                for (int j = 0; j < NUM_ROWS; j++)
                {
                    matrix[i, j] = new Square(new Position(i, j));

                    if ((i + j) % 2 == 0)
                    {
                        matrix[i, j].BackgroundImage = Image.FromFile(path + "//WhiteWood.gif");
                    }
                    else {
                        matrix[i, j].BackgroundImage = Image.FromFile(path + "//BlackWood.gif");
                    }

                    matrix[i, j].Name = "square" + i + "" + j; //square00, square01, etc.
                    matrix[i, j].Location = new Point(h, v);
                    matrix[i, j].Click += new System.EventHandler(this.square_Click);
                    h += 60;
                    matrix[i, j].Size = new Size(60, 60);
                    this.Controls.Add(matrix[i, j]);
                }

                v += 60;
            }
        }
Example #56
0
        public BoardControl(int row, int col, int mines)
        {
            this.Dock = DockStyle.Fill;
            this.BorderStyle = BorderStyle.Fixed3D;
            this.DoubleBuffered = true;
            this.ResizeRedraw = true;
            this.columns = col;
            this.rows = row;
            //this.MouseMove += new MouseEventHandler(BoardControl_MouseMove);
            //this.Paint += new PaintEventHandler(OnPaint);

            squares = new Square[row, col];
            for (int x = 0; x < row; x++)
            {
                for (int y = 0; y < col; y++)
                {
                    squares[x, y] = new Square();
                    squares[x, y].Bounds = new Rectangle(x * SQUARE_SIZE, y * SQUARE_SIZE, SQUARE_SIZE, SQUARE_SIZE);
                }
            }
        }
Example #57
0
        public VisualDisplay(GameWindow window) {
            this.window = window;

            window.UpdateFrame += window_UpdateFrame;
            window.RenderFrame += window_RenderFrame;
            window.Resize += window_Resize;
            window.KeyPress += window_KeyPress;
            window.Closed += window_Closed;
            window.Load += window_Load;
            window.MouseUp += window_MouseUp;

            board = new Square[14, 14];
            colors = new Color[6];
            GridSize = window.Height / 15f;
            GridPosX = window.Width / 20f;
            GridPosY = window.Height / 20f;
            ControlSize = window.Height / 10f;
            ControlPosX = window.Width * (0.7f);
            ControlPosY = window.Height * (0.2f);
            setupBoard();
        }
        public Maze(int w, int h, int s)
        {
            width = w;
            height = h;
            spacing = s;

            random = new Random();

            List<int> randomList = CreateSloppyRandomList(width * height);
            randomUnblockedSquares = new List<Square>();

            // initialize all squares
            squares = new Square[height, width];
            int i = 0;
            for (int r = 0; r < height; ++r) {
                for (int c = 0; c < width; ++c) {
                    squares[r, c] = new Square(r, c, this);
                    squares[r, c].Id = randomList[i];
                    i++;
                }
            }
        }
Example #59
0
    // Use this for initialization
    void Start()
    {
        mTerrain = this.GetComponent <Terrain>();
        /*lineRenderer = gameObject.AddComponent<LineRenderer>();

        lineRenderer.SetVertexCount(5);
        if(lineRenderer == null)
        {
            Debug.Log ("null lineRenderer");
        }else {Debug.Log("lineRenderer");}*/

        mTData = mTerrain.terrainData;

        mTerrainWidth = (int)mTData.size.x;
        mTerrainLength = (int)mTData.size.z;

        mTileWidth = (mTerrainWidth / mXCells);
        mTileLength = (mTerrainLength / mYCells);

        mSquare = new Square[mXCells, mYCells];

        //legger object i den todimensjonale Square tabellen
        GL.Begin(GL.LINES);
        for (int i = 0; i < mXCells; i++)
        {
            for (int j = 0; j < mYCells; j++)
            {

                mSquare[i,j] =new Square( (i*mTileWidth), (j*mTileLength), mTileWidth, mTileLength, this.gameObject);
            }
        }
        //Writing out the toString for every Square object
        for(int i =0; i<mXCells; i++)
        {
            for(int j = 0; j<mYCells; j++)
            {
            }
        }
    }
Example #60
0
        private void CreateSquares(ByteMatrix byteMatrix, int squareSize)
        {
            squares = new Square[(byteMatrix.Width / squareSize) + 1, (byteMatrix.Height / squareSize) + 1];

            for (int y = 0, cntY = 0; y < byteMatrix.Height; y+=squareSize, cntY++)
            {
                for (int x = 0, cntX = 0; x < byteMatrix.Width; x+=squareSize, cntX++)
                {
                    Color clr;
                    if (byteMatrix.Array[x][y] == 0)
                        clr = Color.Black;
                    else
                        clr = Color.White;

                    squares[cntX, cntY] = new Square(
                        new Size(squareSize, squareSize),
                        new System.Drawing.Point(cntX * squareSize, cntY * squareSize)
                        );
                    squares[cntX, cntY].Color = clr;
                }
            }
        }