public virtual GameProfileCustomItem loadColorPresetCustomItem(AppColorPreset preset)
    {
        GameProfileCustomItem customItem = new GameProfileCustomItem();

        customItem = loadColorPresetCustomItem(customItem, preset);
        return(customItem);
    }
Beispiel #2
0
    public virtual GameProfileCustomItem fillDefaultCustomColors(GameProfileCustomItem customItemTo, string type)
    {
        if (customItemTo == null)
        {
            return(customItemTo);
        }

        if (customItemTo.HasData())
        {
            return(customItemTo);
        }

        // get a random

        List <AppColorPreset> colors = AppColorPresets.Instance.GetListByType(type);

        int            randomIndex  = UnityEngine.Random.Range(0, colors.Count - 1);
        AppColorPreset randomPreset = colors[randomIndex];

        customItemTo = loadColorPresetCustomItem(customItemTo, randomPreset);

        //GameCustomController.SaveColors(customItemTo);

        return(customItemTo);
    }
    public void HandleCustomPlayerColor()
    {
        CheckData();

        if (customCharacterData.isCustomType ||
            customCharacterData.isDefaultType)
        {
            //return;
        }
        else if (customCharacterDataCurrent.lastCustomColorCode
                 != customCharacterData.presetColorCode)
        {
            if (AppColorPresets.Instance.CheckByCode(customCharacterData.presetColorCode))
            {
                //LogUtil.Log("HandleCustomPlayerColor:changing:" +
                //          " lastCustomColorCode:" + lastCustomColorCode +
                //         " characterData.presetColorCode:" + characterData.presetColorCode);

                // load from current code
                AppColorPreset preset = AppColorPresets.Instance.GetByCode(
                    customCharacterData.presetColorCode);

                GameCustomController.UpdateColorPresetObject(
                    gameObject, preset);

                customCharacterDataCurrent.lastCustomColorCode =
                    customCharacterData.presetColorCode;
            }
        }
    }
Beispiel #4
0
    public void ChangePreset(int index)
    {
        int countPresets =
            AppColorPresets.Instance.GetListByType(type).Count;

        if (index < -1)
        {
            index = countPresets - 1;
        }

        if (index > countPresets - 1)
        {
            index = -1;
        }

        currentIndex = index;

        if (index > -2 && index < countPresets)
        {
            if (initialProfileCustomItem == null)
            {
                initialProfileCustomItem = GameProfileCharacters.currentCustom;
            }

            currentProfileCustomItem = GameProfileCharacters.currentCustom;

            if (index == -1)
            {
                UIUtil.SetLabelValue(labelCurrentDisplayName, "My Previous Colors");

                GameCustomController.UpdateColorPresetObject(
                    initialProfileCustomItem, currentObject, type);
            }
            else
            {
                AppColorPreset preset =
                    AppColorPresets.Instance.GetListByType(type)[currentIndex];

                // change character to currently selected texture preset

                currentProfileCustomItem =
                    GameCustomController.UpdateColorPresetObject(
                        currentProfileCustomItem, currentObject, preset);

                GameCustomController.SaveCustomItem(currentProfileCustomItem);

                UIUtil.SetLabelValue(labelCurrentDisplayName, preset.display_name);
            }
        }
    }
    public virtual GameProfileCustomItem updateColorPresetObject(
        GameProfileCustomItem profileCustomItem, GameObject go, AppColorPreset preset)
    {
        if (preset == null)
        {
            return(profileCustomItem);
        }

        Dictionary <string, Color> colors = new Dictionary <string, Color>();

        foreach (KeyValuePair <string, string> pair in preset.data)
        {
            colors.Add(pair.Key, AppColors.GetColor(pair.Value));
        }

        if (colors.Count > 0)
        {
            return(updateColorPresetObject(profileCustomItem, go, preset.type, colors));
        }

        return(profileCustomItem);
    }
 public virtual GameProfileCustomItem loadColorPresetCustomItem(GameProfileCustomItem customItem, AppColorPreset preset)
 {
     foreach (KeyValuePair <string, string> pair in preset.data)
     {
         customItem.SetCustomColor(pair.Key, AppColors.GetColor(pair.Value));
     }
     return(customItem);
 }