Example #1
0
        /// <summary>
        ///     Generates a random theme.
        /// </summary>
        private void GenerateRandomTheme()
        {
            var userTheme      = EUIResourceManager.Instance.UserTheme;
            var baseTheme      = Random.Range(0, EUIResourceManager.Instance.BlockoutThemes.Length);
            var mats           = EUIResourceManager.Instance.BlockoutThemes[baseTheme].GetSortedUniqueMaterials;
            var randomMat      = Random.Range(0, mats.Length);
            var baseThemeColor = mats[randomMat].GetColor("_Color");

            if (!m_lockColors[2])
            {
                userTheme.DynamicMaterial.SetColor("_Color", baseThemeColor);
            }

            float h, s, v;

            Color.RGBToHSV(baseThemeColor, out h, out s, out v);
            var pallet       = BlockoutStaticFunctions.GenerateColors_SaturationLuminance(mats.Length, h);
            var sortedPallet = pallet.OrderBy(x => BlockoutStaticFunctions.Luminance(x)).ToList();

            for (var i = 0; i < sortedPallet.Count; ++i)
            {
                Color.RGBToHSV(sortedPallet[i], out h, out s, out v);
                s *= 0.5f;
                sortedPallet[i] = Color.HSVToRGB(h, s, v);
            }

            if (!m_lockColors[0])
            {
                userTheme.FloorMaterial.SetColor("_Color", sortedPallet[0]);
                userTheme.TriFloor.SetColor("_Color", sortedPallet[0]);
            }
            if (!m_lockColors[1])
            {
                userTheme.WallMaterial.SetColor("_Color", sortedPallet[1]);
                userTheme.TriWalls.SetColor("_Color", sortedPallet[1]);
            }
            if (!m_lockColors[4])
            {
                userTheme.TrimMaterial.SetColor("_Color", sortedPallet[2]);
                userTheme.TriTrim.SetColor("_Color", sortedPallet[2]);
            }
            if (!m_lockColors[5])
            {
                userTheme.FoliageMaterial.SetColor("_Color", sortedPallet[3]);
            }

            if (!m_lockColors[7])
            {
                userTheme.TriggerMaterial.SetColor("_Color", sortedPallet[0]);
                userTheme.TriggerMaterial.SetColor("_Color_1", sortedPallet[0]);
            }

            if (!m_lockColors[5])
            {
                Color.RGBToHSV(sortedPallet[1], out h, out s, out v);
                var leafMatOptions = BlockoutStaticFunctions.GenerateColors_Saturation(1, h, v);
                userTheme.LeavesMaterial.SetColor("_Color", leafMatOptions[0] * 0.5f);
                userTheme.LeavesMaterial.SetColor("_Color_1", leafMatOptions[0] * 0.5f);
            }


            m_userThemeColors[0] = userTheme.FloorMaterial.GetColor("_Color");
            m_userThemeColors[1] = userTheme.WallMaterial.GetColor("_Color");
            m_userThemeColors[2] = userTheme.DynamicMaterial.GetColor("_Color");
            m_userThemeColors[3] = userTheme.TrimMaterial.GetColor("_Color");
            m_userThemeColors[4] = userTheme.FoliageMaterial.GetColor("_Color");
            m_userThemeColors[5] = userTheme.LeavesMaterial.GetColor("_Color_1");
            m_userThemeColors[6] = userTheme.WaterMateral.GetColor("_Color_1");
            m_userThemeColors[7] = userTheme.TriggerMaterial.GetColor("_Color_1");
        }