public Action <ColorSwapAsyncOperation> CreateColorSwapTask(INitroxPlayer nitroxPlayer)
        {
            GameObject         playerModel       = nitroxPlayer.PlayerModel;
            Color              playerColor       = nitroxPlayer.PlayerSettings.PlayerColor;
            IColorSwapStrategy colorSwapStrategy = new HueSwapper(playerColor);

            SkinnedMeshRenderer reinforcedSuitRenderer = playerModel.GetRenderer(REINFORCED_SUIT_GAME_OBJECT_NAME);

            reinforcedSuitRenderer.material.ApplyClonedTexture();
            reinforcedSuitRenderer.materials[1].ApplyClonedTexture();

            SkinnedMeshRenderer reinforcedGloveRenderer = playerModel.GetRenderer(REINFORCED_GLOVES_GAME_OBJECT_NAME);

            reinforcedGloveRenderer.material.ApplyClonedTexture();

            Color[] suitTexturePixels  = reinforcedSuitRenderer.material.GetMainTexturePixels();
            Color[] armsTexturePixels  = reinforcedSuitRenderer.materials[1].GetMainTexturePixels();
            Color[] gloveTexturePixels = reinforcedGloveRenderer.material.GetMainTexturePixels();

            return(operation =>
            {
                HsvSwapper reinforcedSuitFilter = new HsvSwapper(colorSwapStrategy);
                reinforcedSuitFilter.SetHueRange(0f, 20f);
                reinforcedSuitFilter.SetSaturationRange(45f, 100f);

                reinforcedSuitFilter.SwapColors(suitTexturePixels);
                reinforcedSuitFilter.SwapColors(armsTexturePixels);
                reinforcedSuitFilter.SwapColors(gloveTexturePixels);

                operation.UpdateIndex(REINFORCED_SUIT_INDEX_KEY, suitTexturePixels);
                operation.UpdateIndex(REINFORCED_SUIT_ARMS_INDEX_KEY, armsTexturePixels);
                operation.UpdateIndex(REINFORCED_GLOVES_INDEX_KEY, gloveTexturePixels);
            });
        }
Пример #2
0
        public Action <ColorSwapAsyncOperation> CreateColorSwapTask(INitroxPlayer nitroxPlayer)
        {
            GameObject         playerModel       = nitroxPlayer.PlayerModel;
            Color              playerColor       = nitroxPlayer.PlayerSettings.PlayerColor;
            IColorSwapStrategy colorSwapStrategy = new HueSwapper(playerColor);

            SkinnedMeshRenderer stillSuitRenderer = playerModel.GetRenderer(STILL_SUIT_GAME_OBJECT_NAME);

            stillSuitRenderer.material.ApplyClonedTexture();
            stillSuitRenderer.materials[1].ApplyClonedTexture();

            Color[] bodyTexturePixels = stillSuitRenderer.material.GetMainTexturePixels();
            Color[] armsTexturePixels = stillSuitRenderer.materials[1].GetMainTexturePixels();

            return(operation =>
            {
                HsvSwapper stillSuitFilter = new HsvSwapper(colorSwapStrategy);
                stillSuitFilter.SetHueRange(0f, 75f);

                stillSuitFilter.SwapColors(bodyTexturePixels);
                stillSuitFilter.SwapColors(armsTexturePixels);

                operation.UpdateIndex(STILL_SUIT_INDEX_KEY, bodyTexturePixels);
                operation.UpdateIndex(STILL_SUIT_ARMS_INDEX_KEY, armsTexturePixels);
            });
        }
Пример #3
0
        public Action <ColorSwapAsyncOperation> CreateColorSwapTask(INitroxPlayer nitroxPlayer)
        {
            GameObject         playerModel       = nitroxPlayer.PlayerModel;
            Color              playerColor       = nitroxPlayer.PlayerSettings.PlayerColor.ToUnity();
            IColorSwapStrategy colorSwapStrategy = new HueSwapper(playerColor);

            SkinnedMeshRenderer basicFinRenderer = playerModel.GetRenderer(FINS_GAME_OBJECT_NAME);

            basicFinRenderer.material.ApplyClonedTexture();

            SkinnedMeshRenderer chargedFinRenderer = playerModel.GetRenderer(CHARGED_FINS_GAME_OBJECT_NAME);

            chargedFinRenderer.material.ApplyClonedTexture();

            SkinnedMeshRenderer glideFinRenderer = playerModel.GetRenderer(GLIDE_FINS_GAME_OBJECT_NAME);

            glideFinRenderer.material.ApplyClonedTexture();

            //All fin models use the same texture.
            Color[] texturePixels = basicFinRenderer.material.GetMainTexturePixels();

            return(operation =>
            {
                HsvSwapper finFilter = new HsvSwapper(colorSwapStrategy);
                finFilter.SetHueRange(0f, 35f);

                finFilter.SwapColors(texturePixels);

                operation.UpdateIndex(FINS_INDEX_KEY, texturePixels);
            });
        }
        public Action <ColorSwapAsyncOperation> CreateColorSwapTask(INitroxPlayer nitroxPlayer)
        {
            GameObject playerModel = nitroxPlayer.PlayerModel;
            Color      playerColor = nitroxPlayer.PlayerSettings.PlayerColor;

            HueSaturationVibrancySwapper hueSaturationVibrancySwapper = new HueSaturationVibrancySwapper(playerColor);
            HueSwapper hueSwapper = new HueSwapper(playerColor);

            SkinnedMeshRenderer radiationSuitRenderer = playerModel.GetRenderer(RADIATION_SUIT_GAME_OBJECT_NAME);

            radiationSuitRenderer.material.ApplyClonedTexture();
            radiationSuitRenderer.materials[1].ApplyClonedTexture();

            Color[] legPixelBlock    = radiationSuitRenderer.material.GetMainTexturePixelBlock(legTextureBlock);
            Color[] feetPixelBlock   = radiationSuitRenderer.material.GetMainTexturePixelBlock(feetTextureBlock);
            Color[] beltPixelBlock   = radiationSuitRenderer.material.GetMainTexturePixelBlock(beltTextureBlock);
            Color[] armSleevesPixels = radiationSuitRenderer.materials[1].GetMainTexturePixels();

            return(operation =>
            {
                HsvSwapper radiationSuitLegFilter = new HsvSwapper(hueSaturationVibrancySwapper);
                radiationSuitLegFilter.SetSaturationRange(0f, 35f);
                radiationSuitLegFilter.SetVibrancyRange(40f, 100f);

                HsvSwapper radiationSuitArmAndFeetFilter = new HsvSwapper(hueSwapper);
                radiationSuitArmAndFeetFilter.SetHueRange(0f, 100f);
                radiationSuitArmAndFeetFilter.SetVibrancyRange(30f, 100f);

                HsvSwapper radiationSuitBeltFilter = new HsvSwapper(hueSwapper);
                radiationSuitBeltFilter.SetVibrancyRange(3f, 100f);
                radiationSuitBeltFilter.SetHueRange(0f, 90f);

                radiationSuitLegFilter.SwapColors(legPixelBlock);
                radiationSuitArmAndFeetFilter.SwapColors(feetPixelBlock);
                radiationSuitArmAndFeetFilter.SwapColors(armSleevesPixels);
                radiationSuitBeltFilter.SwapColors(beltPixelBlock);

                operation.UpdateIndex(RADIATION_SUIT_ARMS_INDEX_KEY, armSleevesPixels);
                operation.UpdateIndex(RADIATION_SUIT_LEG_INDEX_KEY, legPixelBlock);
                operation.UpdateIndex(RADIATION_SUIT_FEET_INDEX_KEY, feetPixelBlock);
                operation.UpdateIndex(RADIATION_SUIT_BELT_INDEX_KEY, beltPixelBlock);
            });
        }
Пример #5
0
        public Action <ColorSwapAsyncOperation> CreateColorSwapTask(INitroxPlayer nitroxPlayer)
        {
            GameObject         playerModel       = nitroxPlayer.PlayerModel;
            Color              playerColor       = nitroxPlayer.PlayerSettings.PlayerColor.ToUnity();
            IColorSwapStrategy colorSwapStrategy = new HueSwapper(playerColor);

            SkinnedMeshRenderer scubaTankRenderer = playerModel.GetRenderer(SCUBA_TANK_GAME_OBJECT_NAME);

            scubaTankRenderer.material.ApplyClonedTexture();

            Color[] texturePixels = scubaTankRenderer.material.GetMainTexturePixels();

            return(operation =>
            {
                HsvSwapper scubaTankFilter = new HsvSwapper(colorSwapStrategy);
                scubaTankFilter.SetHueRange(0f, 30f);

                scubaTankFilter.SwapColors(texturePixels);

                operation.UpdateIndex(SCUBA_TANK_INDEX_KEY, texturePixels);
            });
        }
        public void ApplyPlayerColor(Dictionary <string, Color[]> pixelIndex, INitroxPlayer nitroxPlayer)
        {
            Color[] suitPixelIndexes  = pixelIndex[REINFORCED_SUIT_INDEX_KEY];
            Color[] armsTexturePixels = pixelIndex[REINFORCED_SUIT_ARMS_INDEX_KEY];
            Color[] glovePixelIndexes = pixelIndex[REINFORCED_GLOVES_INDEX_KEY];

            GameObject         playerModel       = nitroxPlayer.PlayerModel;
            Color              playerColor       = nitroxPlayer.PlayerSettings.PlayerColor;
            IColorSwapStrategy colorSwapStrategy = new HueSwapper(playerColor);

            SkinnedMeshRenderer reinforcedSuitRenderer = playerModel.GetRenderer(REINFORCED_SUIT_GAME_OBJECT_NAME);

            reinforcedSuitRenderer.material.UpdateMainTextureColors(suitPixelIndexes);
            reinforcedSuitRenderer.material.SetTexture("_MainTex", reinforcedSuitRenderer.material.mainTexture);
            reinforcedSuitRenderer.material.SetTexture("_SpecTex", reinforcedSuitRenderer.material.mainTexture);

            reinforcedSuitRenderer.materials[1].UpdateMainTextureColors(armsTexturePixels);
            reinforcedSuitRenderer.materials[1].SetTexture("_MainTex", reinforcedSuitRenderer.materials[1].mainTexture);
            reinforcedSuitRenderer.materials[1].SetTexture("_SpecTex", reinforcedSuitRenderer.materials[1].mainTexture);

            SkinnedMeshRenderer reinforcedGlovesRenderer = playerModel.GetRenderer(REINFORCED_GLOVES_GAME_OBJECT_NAME);

            reinforcedGlovesRenderer.material.UpdateMainTextureColors(glovePixelIndexes);
        }
Пример #7
0
        public Action <ColorSwapAsyncOperation> CreateColorSwapTask(INitroxPlayer nitroxPlayer)
        {
            GameObject         playerModel       = nitroxPlayer.PlayerModel;
            Color              playerColor       = nitroxPlayer.PlayerSettings.PlayerColor.ToUnity();
            IColorSwapStrategy colorSwapStrategy = new HueSwapper(playerColor);

            SkinnedMeshRenderer rebreatherRenderer = playerModel.GetRenderer(REBREATHER_GAME_OBJECT_NAME);

            rebreatherRenderer.material.ApplyClonedTexture();

            FixRebreatherMaterials(playerModel, rebreatherRenderer);

            Color[] texturePixels = rebreatherRenderer.material.GetMainTexturePixels();

            return(operation =>
            {
                HsvSwapper rebreatherFilter = new HsvSwapper(colorSwapStrategy);
                rebreatherFilter.SetHueRange(0f, 25f);

                rebreatherFilter.SwapColors(texturePixels);

                operation.UpdateIndex(REBREATHER_INDEX_KEY, texturePixels);
            });
        }