コード例 #1
0
        public Door GetDoor(DirectionsEight dir)
        {
            var door = _doors[(int)dir];

            if (door != null)
            {
                return(door);
            }
            if (!dir.IsCardinal())
            {
                return(null);
            }
            var adjacent = dir.Adjacent();

            for (int i = 0; i < adjacent.Length; i++)
            {
                door = _doors[(int)adjacent[i]];
                if (door != null)
                {
                    return(door);
                }
            }
            return(null);
        }