示例#1
0
        /// <summary>
        /// Matrix Constructor
        /// </summary>
        /// <param name="config"></param>
        /// <param name="value"></param>
        /// <param name="indexInPmc"></param>
        /// <param name="indexInContainer"></param>
        public Matrix(PmcConfiguration config, T value, int indexInPmc, int indexInContainer) : base(config, value)
        {
            _indexInPmc = indexInPmc;
            _indexInContainer = indexInContainer;

            Dimension = GetPointDimension();
        }
示例#2
0
        /// <summary>
        /// Helper method to get points count base on matrix index inside container and XyRule, XRule
        /// </summary>
        /// <param name="dimension"></param>
        /// <param name="indexInContainer"></param>
        /// <param name="indexInMatrix"></param>
        /// <returns></returns>
        public int GetCountPointsXyAndXRule(PointDimension dimension, int indexInContainer, int indexInMatrix)
        {
            switch (dimension)
            {
            case PointDimension.Xy:
            {
                var path = new PointPath
                {
                    IndexInContainer = indexInContainer,
                    IndexInMatrix    = indexInMatrix
                };

                var customPointsNumber = XyConfig.Rules?.FirstOrDefault(r => r.Path.Equals(path))?.CountPoints;

                return(customPointsNumber ?? XyConfig.DefaultCountPoints ?? CountPoints);
            }

            case PointDimension.X:
            {
                var path = new PointPath
                {
                    IndexInContainer = indexInContainer,
                    IndexInMatrix    = indexInMatrix
                };

                var customPointsNumber = XConfig.Rules?.FirstOrDefault(r => r.Path.Equals(path))?.CountPoints;

                return(customPointsNumber ?? XyConfig.DefaultCountPoints ?? CountPoints);
            }

            default:
                return(CountPoints);
            }
        }
示例#3
0
        /// <summary>
        /// Position Constructor
        /// </summary>
        /// <param name="config"></param>
        /// <param name="value"></param>
        /// <param name="indexInPmc"></param>
        /// <param name="indexInContainer"></param>
        /// <param name="indexInMatrix"></param>
        /// <param name="dimension"></param>
        public Position(PmcConfiguration config, T value, int indexInPmc, int indexInContainer, int indexInMatrix, PointDimension dimension) : base(config, value)
        {
            _indexInPmc       = indexInPmc;
            _indexInContainer = indexInContainer;
            _indexInMatrix    = indexInMatrix;

            Dimension = dimension;
        }
示例#4
0
        public void FirstMatrix_Returns_XY_Dimension(int index, PointDimension expectedDimension)
        {
            // Arrange

            //Act
            var actualDimension = _pmc[0][index].Dimension;

            //Assert
            Assert.AreEqual(expectedDimension, actualDimension);
        }
示例#5
0
文件: HexMath.cs 项目: tory37/HexGame
    /// <summary>
    /// Returns the distance from a flat edge to the opposite flat edge of a hexagon.
    /// </summary>
    /// <param name="dimension">The width from point to opposite point or 
    ///		the radius from center to point of the hexagon</param>
    /// <param name="dimensionType">The enum to tell the function whether
    ///		/dimension/ is the point to opposite point width or radius </param>
    /// <returns></returns>
    public static float EdgeToEdgeWidth(float dimension, PointDimension dimensionType)
    {
        float pointRadius = dimension;

        if ( dimensionType == PointDimension.PointWidth)
                pointRadius  = dimension * .5f;
        else
                pointRadius = dimension;

        return 2 * ((pointRadius * Mathf.Sqrt(3)) / 2);
    }
示例#6
0
        /// <summary>
        /// Point Constructor
        /// </summary>
        /// <param name="dimension"></param>
        /// <param name="dataValue"></param>
        public Point(PointDimension dimension, T dataValue)
        {
            Dimension = dimension;

            FormPoint(dataValue);
        }