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; } } }
public virtual void OnCustomColorChanged(Color color) { GameAudio.PlayEffect(GameAudioEffects.audio_effect_ui_button_1); currentProfileCustomItem = GameProfileCharacters.currentCustom; foreach (AppContentAssetCustomItem customItem in AppContentAssetCustomItems.Instance.GetListByType(type)) { Dictionary <string, Color> colors = new Dictionary <string, Color>(); foreach (AppContentAssetCustomItemProperty prop in customItem.properties) { bool update = false; #if USE_UI_NGUI_2_7 || USE_UI_NGUI_3 foreach (KeyValuePair <string, UICheckbox> pair in checkboxes) { #else foreach (KeyValuePair <string, Toggle> pair in checkboxes) { #endif if (pair.Value == null) { LogUtil.Log("Checkbox not found:" + pair.Key); continue; } if (UIUtil.IsCheckboxChecked(pair.Value) &&//.isChecked prop.code == pair.Key) { update = true; } } Color colorTo = currentProfileCustomItem.GetCustomColor(prop.code); if (update) { color.a = 1; colorTo = color; } colors.Add(prop.code, colorTo); } currentProfileCustomItem = GameCustomController.UpdateColorPresetObject( currentProfileCustomItem, currentObject, type, colors); GameCustomController.SaveCustomItem(currentProfileCustomItem); } }
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 void SetCustomColors() { CheckData(); if (customCharacterDataCurrent.lastCustomColorCode == customCharacterData.presetColorCode) { //return; } //LogUtil.Log("SetCustomColors" // + " type:" + characterData.type // + " presetType:" + characterData.presetType // + " presetColorCode:" + characterData.presetColorCode // + " presetTextureCode:" + characterData.presetTextureCode); if (customCharacterData.isCustomType || customCharacterData.isTeamType || customCharacterData.isExplicitType) { return; } else if (customCharacterData.isDefaultType) { if (customCharacterData.actorType == GameCustomActorTypes.heroType) { GameProfileCustomItem customItem = GameProfileCharacters.currentCustom; //LogUtil.Log("SetCustomColors" // + " customItem:" + customItem.ToJson()); if (customItem != null) { if (!customItem.HasData()) { GameCustomController.UpdateColorPresetObject( gameObject, AppColorPresets.Instance.GetByCode( customCharacterData.presetColorCodeDefault)); } else { //customItem = GameCustomController.FillDefaultCustomColors(customItem, type); GameCustomController.UpdateColorPresetObject( customItem, gameObject, customCharacterData.presetType); } } else { GameCustomController.UpdateColorPresetObject( gameObject, AppColorPresets.Instance.GetByCode( customCharacterData.presetColorCodeDefault)); }//GameCustomController.BroadcastCustomColorsChanged } else { GameCustomController.UpdateColorPresetObject( gameObject, AppColorPresets.Instance.GetByCode( customCharacterData.presetColorCodeDefault)); }//GameCustomController.BroadcastCustomColorsChanged } customCharacterDataCurrent.lastCustomColorCode = customCharacterData.presetColorCode; }