private void FinishGame() { m_bFinished = true; float colorDiff = 0.0f; var paintTexture = m_painter.PaintTexture; for (int x = 0; x < paintTexture.width; x++) { for (int y = 0; y < paintTexture.height; y++) { Color color = paintTexture.GetPixel(x, y); Color targetColor = m_targetImage.Sprite.texture.GetPixelBilinear((float)x / paintTexture.width, (float)y / paintTexture.height); float diff = Vector3.Distance(ColorConvertor.RGBToYUV(color), ColorConvertor.RGBToYUV(targetColor)); colorDiff += diff; } } float score = colorDiff / (paintTexture.width + paintTexture.height); m_scoreText.Value = $"{score:F0}"; UIController.ActivateUI(m_scoreUIName); }
private void SetRandomColor() { Vector4 cmyk = Vector4.zero; cmyk.x = Random.Range(0.0f, 1.0f); cmyk.y = Random.Range(0.0f, 1.0f); cmyk.z = Random.Range(0.0f, 1.0f); cmyk.w = Random.Range(0, 3) < 1 ? Random.Range(0.0f, 0.3f) : Random.Range(0.3f, 1.0f); Color rgb = ColorConvertor.CMYKToRGB(cmyk); foreach (var spriteRenderer in m_spriteRenderers) { spriteRenderer.color = rgb; } }