示例#1
0
        /// <summary>
        /// Gets all doors that lie along the given path. Does not include the
        /// starting point.
        /// </summary>
        /// <param name="path"></param>
        /// <returns></returns>
        public HashSet <string> GetDoorsAlongPath(IList <GridPoint> path)
        {
            var result = new HashSet <string>();

            for (int i = 0; i < path.Count; i++)
            {
                var point = path[i];
                if (CellsWithDoors.ContainsKey(point))
                {
                    result.Add(CellsWithDoors[point]);
                }
            }
            return(result);
        }
示例#2
0
        public bool GetCanEnterCell(
            GridPoint point,
            SortedDictionary <string, string> keysCollected,
            bool ignoreDoors = false)
        {
            if (!MazeCells.ContainsKey(point))
            {
                return(false);
            }
            var cell = MazeCells[point];

            if (MazeCellType.Wall.Equals(cell.Type))
            {
                return(false);
            }
            if (!ignoreDoors &&
                CellsWithDoors.ContainsKey(point) &&
                !keysCollected.ContainsKey(CellsWithDoors[point].ToLower()))
            {
                return(false);
            }
            return(true);
        }