Beispiel #1
0
        public static FieldPosition GetRandomEmptyFieldPosition()
        {
            EmptyFieldsPosition freeFields = EmptyFieldsPosition.Instance;

            int           position = generator.Next(freeFields.NumberOfEmptyFields());
            FieldPosition pos;

            try
            {
                pos = freeFields.GetEmptyFieldFromListAt(position);
            }
            catch (NoFreeFieldException e)
            {
                throw e;
            }

            freeFields.RemoveEmptyFieldFromList(pos.z, pos.x, pos.y);
            return(pos);
        }
        /// <summary>
        /// Method removes specified field from list of empty fields
        /// </summary>
        /// <param name="z"></param>
        /// <param name="x"></param>
        /// <param name="y"></param>
        private void RemoveFieldPositionFromListOfEmptyFields(int z, int x, int y)
        {
            EmptyFieldsPosition freeFields = EmptyFieldsPosition.Instance;

            freeFields.RemoveEmptyFieldFromList(z, x, y);
        }