Beispiel #1
0
    private void UpdateColorField()
    {
        string hexColor = "";
        Color  col      = PlayerManager.GetInstance().GetPlayerSlotColor(SlotIndex);

        hexColor = ColorUtility.ColorToHex(col);
        this.transform.GetChild(0).GetComponent <Text>().text = "<color=" + hexColor + ">" + "---" + "</color>";
    }
Beispiel #2
0
        private void SetupPage()
        {
            RoundLabel.Text = $"Round {PlayerInfo.CurrentRound}";
            colorToGuess    = colorGenerator.NextColor(0.2, 0.7);
            ScoreLabel.Text = PlayerInfo.CurrentScore.ToString();
            HexLabel.Text   = ColorUtility.ColorToHex(colorToGuess);
            guessingColor   = new Color(0.6, 0, 0);
            ColorDisplayBoxView.BackgroundColor = guessingColor;

            hueSelected = false;

            SelectHueButton.IsEnabled       = true;
            SelectHueButton.TextColor       = guessingColor;
            SelectHueButton.BackgroundColor = Color.FromHex("#eeeeeeee");

            SubmitButton.IsEnabled       = false;
            SubmitButton.TextColor       = Color.FromHex("#66eeeeee");
            SubmitButton.BackgroundColor = Color.FromHex("#66eeeeee");
        }
        private void colorSelector1_ColorChanged(object sender, EventArgs e)
        {
            colorPB.BackColor = ColorRGB;
            alphaPB.BackColor = colorSelector1.AlphaColor;

            loaded = false;

            redUD.Value   = ColorRGB.R;
            greenUD.Value = ColorRGB.G;
            blueUD.Value  = ColorRGB.B;
            alphaUD.Value = Alpha;
            hexTB.Text    = ColorUtility.ColorToHex(NewColor);

            loaded = true;

            if (ColorChanged != null)
            {
                ColorChanged.Invoke(sender, e);
            }
        }
Beispiel #4
0
    private static bool DrawColorField(XmlNode node)
    {
        if (node.Attributes["name"] == null)
        {
            GUILayout.Label("Error: There is no name associated with Text");
            return(false);
        }

        string name  = node.Attributes["name"].InnerText;
        Color  value = Color.black;

        if (node.Attributes["value"] == null)
        {
            GUILayout.Label("Error: There is no value associated with Text (" + name + ")");
            return(false);
        }

        try
        {
            value = ColorUtility.HexToColor(node.Attributes["value"].InnerText);
        }
        catch (FormatException)
        {
            GUILayout.Label("Error: Cannot convert hex value (" + node.Attributes["value"].InnerText + ") to a color.");
            return(false);
        }

        EditorGUILayout.PrefixLabel(name);
        Color newValue = EditorGUILayout.ColorField(value);

        if (newValue.r != value.r ||
            newValue.g != value.g ||
            newValue.b != value.b ||
            newValue.a != value.a)
        {
            node.Attributes["value"].InnerText = ColorUtility.ColorToHex(newValue);
            return(true);
        }

        return(false);
    }
Beispiel #5
0
        public void ColorToHexVerification()
        {
            Color testColor  = new Color(0.1f, 0.0f, 1.0f, 1.0f);
            Color testColor2 = new Color(1.0f, 0.5f, 0.33333f, 1.0f);
            Color testColor3 = Color.white;

            Color resultColor  = ColorUtility.HexToColor(ColorUtility.ColorToHex(testColor));
            Color resultColor2 = ColorUtility.HexToColor(ColorUtility.ColorToHex(testColor2));
            Color resultColor3 = ColorUtility.HexToColor(ColorUtility.ColorToHex(testColor3));

            // The epsilon on these is because the color object internally converts to 0-255 integer and back to float.
            Assert.IsWithin(testColor.r, resultColor.r, 0.01f, "HexToColor and ColorToHex are not symmetrical");
            Assert.IsWithin(testColor.g, resultColor.g, 0.01f, "HexToColor and ColorToHex are not symmetrical");
            Assert.IsWithin(testColor.b, resultColor.b, 0.01f, "HexToColor and ColorToHex are not symmetrical");

            Assert.IsWithin(testColor2.r, resultColor2.r, 0.01f, "HexToColor and ColorToHex are not symmetrical");
            Assert.IsWithin(testColor2.g, resultColor2.g, 0.01f, "HexToColor and ColorToHex are not symmetrical");
            Assert.IsWithin(testColor2.b, resultColor2.b, 0.01f, "HexToColor and ColorToHex are not symmetrical");

            Assert.IsWithin(testColor3.r, resultColor3.r, 0.01f, "HexToColor and ColorToHex are not symmetrical");
            Assert.IsWithin(testColor3.g, resultColor3.g, 0.01f, "HexToColor and ColorToHex are not symmetrical");
            Assert.IsWithin(testColor3.b, resultColor3.b, 0.01f, "HexToColor and ColorToHex are not symmetrical");
        }
Beispiel #6
0
        public RoundScorePage(Color actualColor, Color guessedColor)
        {
            InitializeComponent();

            ActualBackground.BackgroundColor = actualColor;
            GuessBackground.BackgroundColor  = guessedColor;

            _actualColor = actualColor;
            rand         = new Random();

            double hAccuracy = 1 - Math.Abs(actualColor.Hue - guessedColor.Hue);
            double sAccuracy = 1 - Math.Abs(actualColor.Saturation - guessedColor.Saturation);
            double lAccuracy = 1 - Math.Abs(actualColor.Luminosity - guessedColor.Luminosity);

            int points = (int)(Math.Ceiling(12 * Math.Pow(hAccuracy, 8))) + (int)(Math.Ceiling(9 * Math.Pow(sAccuracy, 8))) + (int)(Math.Ceiling(9 * Math.Pow(lAccuracy, 8)));

            Debug.WriteLine($"You have scored {points} points.");
            PlayerInfo.CurrentScore += points;
            TotalScoreLabel.Text     = PlayerInfo.CurrentScore.ToString();

            string[] comments = new string[8] {
                "Oops!", "Better luck next time!", "Not bad!", "Nice!", "Nifty!", "Superb!", "Rad!", "That's some fine craftsmanship my man!"
            };
            ScoreLabel.Text = $"{points} Moons";
            if (points <= 5)
            {
                CommentLabel.Text = comments[0];
            }
            else if (points <= 12)
            {
                CommentLabel.Text = comments[1];
            }
            else if (points <= 18)
            {
                CommentLabel.Text = comments[2];
            }
            else if (points <= 22)
            {
                CommentLabel.Text = comments[3];
            }
            else if (points <= 25)
            {
                CommentLabel.Text = comments[4];
            }
            else if (points <= 27)
            {
                CommentLabel.Text = comments[5];
            }
            else if (points <= 29)
            {
                CommentLabel.Text = comments[6];
            }
            else
            {
                CommentLabel.Text = comments[7];
            }

            ActualLabel.Text = ColorUtility.ColorToHex(actualColor);
            GuessLabel.Text  = ColorUtility.ColorToHex(guessedColor);

            ScoreLabel.TranslationX   = -(Application.Current.MainPage.Width + ScoreLabel.Width) / 8;
            ScoreLabel.Opacity        = 0;
            CommentLabel.TranslationX = Application.Current.MainPage.Width / 8;
            CommentLabel.Opacity      = 0;
        }
Beispiel #7
0
 public override string ToString()
 {
     return("StyleState(Background: " + (mBackground == null ? "null" : mBackground.name) + ", TextColor: " + ColorUtility.ColorToHex(mTextColor) + ")");
 }