/// <summary>
        /// build out the console veiw for a given cell based on type and access
        /// </summary>
        /// <param name="cell">specify cell to build out</param>
        private char[,] BuildCellView(Cell cell)
        {
            //
            // a character array that represents a cell visually in the console window
            //
            char[,] _cellView = new char[5, 5];

            //
            // fill cell view matrix with '*'
            //
            for (int i = 0; i < NUMBER_OF_CELL_ROWS; i++)
            {
                for (int j = 0; j < NUMBER_OF_CELL_COLOMNS; j++)
                {
                    _cellView[i, j] = '*';
                }
            }

            //
            // fill non-wall area with spaces
            //
            // cell is a Room
            if (cell.Type == Cell.TypeName.Room)
            {
                for (int i = 1; i < NUMBER_OF_CELL_ROWS - 1; i++)
                {
                    for (int j = 1; j < NUMBER_OF_CELL_COLOMNS - 1; j++)
                    {
                        _cellView[i, j] = ' ';
                    }
                }
            }
            // cell is a Coridor
            else if (cell.Type == Cell.TypeName.Corridor)
            {
                _cellView[2, 2] = ' ';
            }

            //
            // fill access areas with spaces (note: "magic numbers" used for readability)
            //
            if (cell.NorthAccess == true)
            {
                _cellView[0, 2] = ' ';
                if (cell.Type == Cell.TypeName.Corridor)
                {
                    _cellView[1, 2] = ' ';
                }
            }
            if (cell.EastAccess == true)
            {
                _cellView[2, 4] = ' ';
                if (cell.Type == Cell.TypeName.Corridor)
                {
                    _cellView[2, 3] = ' ';
                }
            }
            if (cell.SouthAccess == true)
            {
                _cellView[4, 2] = ' ';
                if (cell.Type == Cell.TypeName.Corridor)
                {
                    _cellView[3, 2] = ' ';
                }
            }
            if (cell.WestAccess == true)
            {
                _cellView[2, 0] = ' ';
                if (cell.Type == Cell.TypeName.Corridor)
                {
                    _cellView[2, 1] = ' ';
                }
            }

            return _cellView;
        }
Пример #2
0
        private void InitializeMap()
        {

            #region MAP DATA

            //
            // intialize cell types in array
            //
            _mapSet[0, 0] = new Cell
            {
                Name = "The Grand Room",
                Type = Cell.TypeName.Room,
                Access = Cell.AccessCode.COCC,
                Location = new MapPosition(0, 0),
                Description = "You are in the Grand Room and at the beginning of your journey." +
                                "From here you must proceed to your east as this is the only exit."
            };
            _mapSet[0, 1] = new Cell
            {
                Name = "Corridor",
                Type = Cell.TypeName.Corridor,
                Access = Cell.AccessCode.COCO,
                Location = new MapPosition(0, 1),
                Description = "You are in a long dark corridor."
            };
            _mapSet[0, 2] = new Cell
            {
                Name = "The Blue Room",
                Type = Cell.TypeName.Room,
                Access = Cell.AccessCode.CCOO,
                Location = new MapPosition(0, 2),
                Description = "You are in the Blue Room."
            };
            _mapSet[0, 3] = new Cell
            {
                Name = "The Round Room",
                Type = Cell.TypeName.Room,
                Access = Cell.AccessCode.CCOC,
                Location = new MapPosition(0, 3),
                Description = "You are in the Round Room."
            };

            _mapSet[1, 0] = new Cell
            {
                Name = "Empty Space",
                Type = Cell.TypeName.Empty,
                Access = Cell.AccessCode.CCCC,
                Location = new MapPosition(1, 0),
                Description = ""
            };
            _mapSet[1, 1] = new Cell
            {
                Name = "Empty Space",
                Type = Cell.TypeName.Empty,
                Access = Cell.AccessCode.CCCC,
                Location = new MapPosition(1, 1),
                Description = ""
            };
            _mapSet[1, 2] = new Cell
            {
                Name = "Corridor",
                Type = Cell.TypeName.Corridor,
                Access = Cell.AccessCode.OCOC,
                Location = new MapPosition(1, 2),
                Description = "You are in the Goat Room."
            };
            _mapSet[1, 3] = new Cell
            {
                Name = "Corridor",
                Type = Cell.TypeName.Corridor,
                Access = Cell.AccessCode.OCOC,
                Location = new MapPosition(1, 3),
                Description = "You are in the Tool Room."
            };

            _mapSet[2, 0] = new Cell
            {
                Name = "The Storage Room",
                Type = Cell.TypeName.Room,
                Access = Cell.AccessCode.CCOC,
                Location = new MapPosition(2, 0),
                Description = "You are in the Storage Room."
            };
            _mapSet[2, 1] = new Cell
            {
                Name = "Corridor",
                Type = Cell.TypeName.Corridor,
                Access = Cell.AccessCode.COOC,
                Location = new MapPosition(2, 1),
                Description = "You are in a corridor."
            };
            _mapSet[2, 2] = new Cell
            {
                Name = "Corridor",
                Type = Cell.TypeName.Corridor,
                Access = Cell.AccessCode.OOOO,
                Location = new MapPosition(2, 2),
                Description = "You are in a corridor."
            };
            _mapSet[2, 3] = new Cell
            {
                Name = "The Rose Room",
                Type = Cell.TypeName.Room,
                Access = Cell.AccessCode.OCCO,
                Location = new MapPosition(2, 3),
                Description = "You are in the Rose Room."
            };

            _mapSet[3, 0] = new Cell
            {
                Name = "Corridorm",
                Type = Cell.TypeName.Corridor,
                Access = Cell.AccessCode.OOCC,
                Location = new MapPosition(3, 0),
                Description = "You are in the Storage Room."
            };
            _mapSet[3, 1] = new Cell
            {
                Name = "Corridor",
                Type = Cell.TypeName.Room,
                Access = Cell.AccessCode.OOCO,
                Location = new MapPosition(3, 1),
                Description = "You are in a corridor."
            };
            _mapSet[3, 2] = new Cell
            {
                Name = "Corridor",
                Type = Cell.TypeName.Corridor,
                Access = Cell.AccessCode.OOCO,
                Location = new MapPosition(3, 2),
                Description = "You are in a corridor."
            };
            _mapSet[3, 3] = new Cell
            {
                Name = "The Rose Room",
                Type = Cell.TypeName.Room,
                Access = Cell.AccessCode.CCCO,
                Location = new MapPosition(3, 3),
                Description = "You are in the Rose Room."
            };

            InitializeAccessFlags();
        }