示例#1
0
        ///<summary>
        /// Resurns an array of color components with subsequent colors starting with a random index
        ///</summary>
        public static ColorComponentVO[] GetArray()
        {
            ColorComponentVO[] colorComponents = new ColorComponentVO[POSITIONS.Length];

            int index = UnityEngine.Random.Range(0, BASE_COLORS.Length);

            for (int i = 0; i < colorComponents.Length; i++)
            {
                colorComponents [i] = new ColorComponentVO(BASE_COLORS [(index + i) % BASE_COLORS.Length], POSITIONS[i]);
            }

            return(colorComponents);
        }
示例#2
0
        ///<summary>
        /// Resurns color value on a specifier position, which corresponds to specified colorComponents
        ///</summary>
        public static Color GetColorAt(float[] tileRelativePos, ColorComponentVO[] colorComponents, float tint)
        {
            float r = 0;
            float g = 0;
            float b = 0;

            for (int colorIdx = 0; colorIdx < 3; colorIdx++)
            {
                ColorComponentVO colorComponent = colorComponents [colorIdx];
                float            distance       = (Mathf.Abs(tileRelativePos [0] - colorComponent.position [0]) + Mathf.Abs(tileRelativePos [1] - colorComponent.position [1])) / 2;

                r += colorComponent.color.r - (colorComponent.color.r * distance);
                g += colorComponent.color.g - (colorComponent.color.g * distance);
                b += colorComponent.color.b - (colorComponent.color.b * distance);
            }

            return(new Color(tint * r, tint * g, tint * b, 1));
        }