Beispiel #1
0
        public int AllowedDistance(Type typeA, Type typeB)
        {
            if (typeB == null)
            {
                return(0);
            }

            if (!IndexByType.ContainsKey(typeA) || !IndexByType.ContainsKey(typeB))
            {
                return(-1); //-1 = нельзя располагать
            }
            int indexA = IndexByType[typeA];
            int indexB = IndexByType[typeB];

            return(_matrix[indexA, indexB]);
        }
Beispiel #2
0
        public int GetMaxMatrixDistanceForTile(Type type) //максимальная дистанция у заданного типа в матрице смежности на данный момент
        {
            if (!IndexByType.ContainsKey(type))
            {
                return(-1); //-1 = не найден тип в матрице
            }
            int maxDistance = 0;
            int column      = IndexByType[type];

            for (int row = 0; row < _matrix.GetLength(0); row++)
            {
                int distance = _matrix[row, column];

                if (distance > maxDistance)
                {
                    maxDistance = distance;
                }
            }

            return(maxDistance);
        }