Example #1
0
        public void BindNeighboursShouldOverrideNeighbourWhenAlreadySet()
        {
            Tile newNeighbour = new Tile();
            Direction directionFromTileToNeighbour = Direction.NORTH;

            this.tile.BindNeighbours(neighbour, directionFromTileToNeighbour);

            Assert.AreEqual(this.neighbour, this.tile.GetNeighbour(directionFromTileToNeighbour));

            this.tile.BindNeighbours(newNeighbour, directionFromTileToNeighbour);
            Assert.AreEqual(newNeighbour, this.tile.GetNeighbour(directionFromTileToNeighbour));
        }
Example #2
0
        private void InitialiseGameBoard()
        {
            GameBoard = new Tile[Width, Height];

            for (var x = 0; x < Width; x++)
            {
                for (var y = 0; y < Height; y++)
                {
                    GameBoard[x, y] = new Tile(x, y);
                }
            }

            AllTiles.ToList().ForEach(o => o.FindNeighbours(GameBoard));
        }
Example #3
0
        /* Reads a 42 x 42 map from a text file.
         *
         * Parameter: mapFile - name of a text file
         */
        private void ReadMap(string mapFile)
        {
            StreamReader st = null;

            /* Try to open a text file */
            try
            {
                st = new System.IO.StreamReader(mapFile);
            }
            catch (FileNotFoundException e)
            {
                Console.WriteLine(e.Message);
            }

            /* Read each line of a text file that defines a map. */
            for (int j = 0; j < 42; j++)
            {
                /* Read line */
                string line = st.ReadLine();
                _map[j] = new Tile[MAXTILES];
                /* Creates tiles */
                for (int k = 0; k < line.Length; k++)
                {
                    _map[j][k] = new Tile(line[k] , j, k , this);
                    Helper.PutGround(j, k, line[k]);

                }
            }

            /* Close files */
            st.Close();
        }
Example #4
0
        public TileImage(Tile tl, int x , int y)
        {
            this.Width = prop;
            this.Height = prop;
            this.Location = new Point(x, y);
            this.tile = tl;
            this.tile.listUpdView += UpdateTile;

            InitLayout();
        }
Example #5
0
 public void SetUp()
 {
     this.tile = new Tile();
     this.neighbour = new Tile();
 }