Exemplo n.º 1
0
        /// <summary>
        /// find the first avalible destination index on a line in an indicated direction.
        /// the start of the search is the last index in opposite direction.
        /// </summary>
        public int FindAvalibleDestinationInDirection(MoveDirection direction, uint lineIdx)
        {
            var destination = -1;

            var startIndex = GetLastIndexInDirection(direction.Opposite);
            var square     = direction.IsHorzOrient() ? this[startIndex, lineIdx] : this[lineIdx, startIndex];

            while (square != null && !square.Value.State.IsActive)
            {
                destination = (int)(direction.IsHorzOrient() ? square.Value.X : square.Value.Y);
                square      = square.Next(direction.Value);
            }

            return(square != null ? destination : -1);
        }