public static AbstractHalfBlockColor RandomPrimaryColor()
        {
            HalfBlockColor color;
            ArrayList      primaryColors = new ArrayList();

            primaryColors.Add(ColorModel.RED);
            primaryColors.Add(ColorModel.YELLOW);
            primaryColors.Add(ColorModel.BLUE);

            float random = UnityEngine.Random.value;
            Color c      = new Color();

            foreach (KeyValuePair <Color, float> entry in StructureReader.colorsMap)
            {
                if (random <= entry.Value)
                {
                    c = entry.Key;
                    break;
                }
            }

            if (!primaryColors.Contains(c))
            {
                c     = splitSecondary(c);
                color = new HalfBlockColor(c);
                color.isSecondaryColor = true;
                return(color);
            }
            color = new HalfBlockColor(c);
            color.isSecondaryColor = false;
            return(color);
        }
예제 #2
0
        public void CombineColorTest(Color firstColor, Color secondColor, Color expectedColor)
        {
            AbstractHalfBlockColor first    = new HalfBlockColor(firstColor);
            AbstractHalfBlockColor second   = new HalfBlockColor(secondColor);
            AbstractHalfBlockColor expected = new HalfBlockColor(expectedColor);
            AbstractHalfBlockColor result   = first.CombineColor(second);

            Assert.True(expected.Equals(result));
        }
예제 #3
0
        public void EqualsTest()
        {
            AbstractHalfBlockColor _otherGreen = new HalfBlockColor(ColorModel.GREEN);

            Assert.True(_green.Equals(_otherGreen));
        }