123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851 |
- using System;
- using System.Collections;
- using System.Collections.Generic;
- using System.Linq;
- using UnityEngine;
- public class RandomPresetCtrl : MonoBehaviour
- {
- public void Init(GameObject goRandomPresetPanel)
- {
- string text = "random_preset_category_name.nei";
- using (AFileBase afileBase = GameUty.FileSystem.FileOpen(text))
- {
- using (CsvParser csvParser = new CsvParser())
- {
- bool condition = csvParser.Open(afileBase);
- NDebug.Assert(condition, text + "\nopen failed.");
- NDebug.Assert(csvParser.max_cell_y - 1 == this.categoryTitleLabels.Length, text + "に書かれているカテゴリー数とオブジェクト数が一致していません");
- }
- }
- this.LoadRandomLogicParamter();
- this.CreateRandomItem(goRandomPresetPanel);
- this.m_listCheckRandomActive = new List<MPN>
- {
- MPN.wear,
- MPN.mizugi,
- MPN.onepiece
- };
- this.m_notSettingIcon = (Resources.Load("SceneEdit/RandomPreset/Texture/_I_del") as Texture2D);
- this.m_defaultColorIcon = (Resources.Load("SceneEdit/RandomPreset/Texture/_I_del") as Texture2D);
- this.m_dicRandomPresetBtnOrderByExecutionOrder = from pair in this.m_dicRandomPresetBtn
- orderby pair.Value.m_executionOrder
- select pair;
- this.LoadMaidPropData();
- }
- private void CreateRandomItem(GameObject goRandomPresetPanel)
- {
- this.m_sceneEdit = GameObject.Find("__SceneEdit__").GetComponent<SceneEdit>();
- this.m_dicPartsTypePair = SceneEditInfo.m_dicPartsTypePair;
- this.m_dicRandomPresetBtn = new Dictionary<string, RandomPresetButton>();
- bool flag = false;
- HashSet<int> hashSet = new HashSet<int>();
- foreach (KeyValuePair<MPN, SceneEditInfo.CCateNameType> keyValuePair in this.m_dicPartsTypePair)
- {
- if (!Product.VBA || (keyValuePair.Key != MPN.chikubicolor && keyValuePair.Key != MPN.underhair))
- {
- RandomPresetContent.MPNMapping mpnmapping;
- if (RandomPresetContent.m_dicMPNMapping.TryGetValue(keyValuePair.Key, out mpnmapping))
- {
- string str;
- if (RandomPresetContent.m_dicCategoryMapping.TryGetValue(keyValuePair.Value.m_eMenuCate, out str))
- {
- GameObject childObject = UTY.GetChildObject(goRandomPresetPanel, "Contents/" + str + "/Buttons/" + mpnmapping.m_buttonName, true);
- NDebug.Assert(childObject != null, string.Concat(new string[]
- {
- "ランダムプリセットのボタン[",
- mpnmapping.m_buttonTitle,
- "]のオブジェクト、[",
- mpnmapping.m_buttonName,
- "]が見つかりませんでした"
- }));
- UIButton component = childObject.GetComponent<UIButton>();
- if (!flag)
- {
- this.activeColor = new Color(component.defaultColor.r, component.defaultColor.g, component.defaultColor.b, 1f);
- this.inActiveColor = component.defaultColor;
- flag = true;
- }
- SceneEditInfo.CCateNameType.EType eType = keyValuePair.Value.m_eType;
- RandomPresetButton buttonByType = this.GetButtonByType(eType);
- buttonByType.m_menuCategory = keyValuePair.Value.m_eMenuCate;
- buttonByType.m_eButtonType = eType;
- buttonByType.m_name = mpnmapping.m_buttonName;
- buttonByType.m_mpn = keyValuePair.Key;
- buttonByType.m_btnButton = component;
- if (!hashSet.Contains(component.GetInstanceID()))
- {
- hashSet.Add(component.GetInstanceID());
- }
- buttonByType.m_bBtnActive = false;
- buttonByType.m_executionOrder = mpnmapping.m_executionOrder;
- if (eType != SceneEditInfo.CCateNameType.EType.Item)
- {
- if (eType != SceneEditInfo.CCateNameType.EType.Slider)
- {
- if (eType == SceneEditInfo.CCateNameType.EType.Color)
- {
- buttonByType.m_txtColor = UTY.GetChildObject(childObject, "Color", false).GetComponent<UITexture>();
- }
- }
- else
- {
- buttonByType.m_lValue = UTY.GetChildObject(childObject, "Value", false).GetComponent<UILabel>();
- }
- }
- else
- {
- buttonByType.m_txtItem = UTY.GetChildObject(childObject, "Item", false).GetComponent<UITexture>();
- }
- this.m_dicRandomPresetBtn.Add(buttonByType.m_name, buttonByType);
- }
- }
- }
- }
- if (Product.VBA)
- {
- UIButton[] componentsInChildren = UTY.GetChildObject(goRandomPresetPanel, "Contents", false).GetComponentsInChildren<UIButton>();
- foreach (UIButton uibutton in componentsInChildren)
- {
- if (!hashSet.Contains(uibutton.GetInstanceID()))
- {
- uibutton.transform.gameObject.SetActive(false);
- }
- }
- }
- }
- public void LoadMaidPropData()
- {
- Maid maid = GameMain.Instance.CharacterMgr.GetMaid(0);
- MaidProp prop = maid.GetProp(MPN.MuneL);
- foreach (KeyValuePair<string, RandomPresetButton> keyValuePair in this.m_dicRandomPresetBtn)
- {
- RandomPresetButton value = keyValuePair.Value;
- EventDelegate.Add(value.m_btnButton.onClick, new EventDelegate.Callback(this.randomRandomPresetMgr.OnButtonClick));
- if (value.m_eButtonType == SceneEditInfo.CCateNameType.EType.Item)
- {
- int num = maid.GetProp(value.m_mpn).nFileNameRID;
- foreach (SceneEdit.SubPropMpnData subPropMpnData in this.m_sceneEdit.subPropDatas)
- {
- if (value.m_mpn == subPropMpnData.mpn)
- {
- if (subPropMpnData.manager.sloatItems != null && subPropMpnData.manager.sloatItems[0].menuItem != null)
- {
- num = subPropMpnData.manager.sloatItems[0].menuItem.m_nMenuFileRID;
- }
- break;
- }
- }
- Texture2D texture2D;
- if (num == 0)
- {
- texture2D = this.m_notSettingIcon;
- }
- else
- {
- texture2D = this.GetTextureByRid(value.m_menuCategory, value.m_mpn, num);
- }
- value.m_txtItem.mainTexture = texture2D;
- }
- else if (value.m_eButtonType == SceneEditInfo.CCateNameType.EType.Slider)
- {
- value.m_lValue.text = maid.GetProp(value.m_mpn).value.ToString();
- }
- else if (value.m_eButtonType == SceneEditInfo.CCateNameType.EType.Color)
- {
- int nFileNameRID = maid.GetProp(value.m_mpn).nFileNameRID;
- Texture2D texture2D;
- if (nFileNameRID == 0)
- {
- texture2D = this.m_defaultColorIcon;
- }
- else
- {
- texture2D = this.GetColorTextureByRid(value.m_menuCategory, value.m_mpn, nFileNameRID);
- if (texture2D == null)
- {
- texture2D = this.m_defaultColorIcon;
- }
- }
- value.m_txtColor.mainTexture = texture2D;
- }
- }
- Debug.Log("データのロード処理が完了しました。");
- }
- private void OnEnable()
- {
- if (!Product.VBA)
- {
- return;
- }
- foreach (UITable uitable in base.gameObject.GetComponentsInChildren<UITable>(true))
- {
- if (uitable != null)
- {
- uitable.Reposition();
- }
- }
- }
- private Texture2D GetTextureByRid(SceneEditInfo.EMenuCategory eMenuCategory, MPN btnMpn, int rid)
- {
- List<SceneEdit.SCategory> categoryList = this.m_sceneEdit.CategoryList;
- foreach (SceneEdit.SCategory scategory in categoryList)
- {
- if (scategory.m_eCategory == eMenuCategory)
- {
- foreach (SceneEdit.SPartsType spartsType in scategory.m_listPartsType)
- {
- if (spartsType.m_mpn == btnMpn)
- {
- foreach (SceneEdit.SMenuItem smenuItem in spartsType.m_listMenu)
- {
- if (smenuItem.m_nMenuFileRID == rid)
- {
- if (smenuItem.m_boDelOnly)
- {
- return smenuItem.m_texIconRef;
- }
- return smenuItem.m_texIconRef;
- }
- }
- return this.m_notSettingIcon;
- }
- }
- }
- }
- return null;
- }
- private Texture2D GetColorTextureByRid(SceneEditInfo.EMenuCategory eMenuCategory, MPN btnMpn, int rid)
- {
- MPN mpn = RandomPresetContent.m_dicColorFolderMapping[btnMpn];
- List<SceneEdit.SCategory> categoryList = this.m_sceneEdit.CategoryList;
- foreach (SceneEdit.SCategory scategory in categoryList)
- {
- if (scategory.m_eCategory == eMenuCategory)
- {
- foreach (SceneEdit.SPartsType spartsType in scategory.m_listPartsType)
- {
- if (spartsType.m_mpn == mpn)
- {
- foreach (SceneEdit.SMenuItem smenuItem in spartsType.m_listMenu)
- {
- foreach (SceneEdit.SMenuItem smenuItem2 in smenuItem.m_listColorSet)
- {
- if (smenuItem2.m_nMenuFileRID == rid)
- {
- if (smenuItem2.m_bColor)
- {
- if (smenuItem2.m_boDelOnly)
- {
- return this.m_notSettingIcon;
- }
- return smenuItem2.m_texIconRandomColorRef;
- }
- else
- {
- Debug.LogError(string.Format("SMenuItemクラスのm_bColorフラグの設定が誤っています。設定されているm_bColor={0}", smenuItem.m_bColor));
- }
- }
- }
- }
- }
- }
- }
- }
- return null;
- }
- private List<SceneEdit.SMenuItem> GetMenuItemList(SceneEditInfo.EMenuCategory eMenuCategory, MPN mpn)
- {
- List<SceneEdit.SCategory> categoryList = this.m_sceneEdit.CategoryList;
- foreach (SceneEdit.SCategory scategory in categoryList)
- {
- if (scategory.m_eCategory == eMenuCategory)
- {
- foreach (SceneEdit.SPartsType spartsType in scategory.m_listPartsType)
- {
- if (spartsType.m_mpn == mpn)
- {
- return spartsType.m_listMenu;
- }
- }
- }
- }
- Debug.LogError(string.Format("不適切なメニューカテゴリとMPNが指定されました。 MenuCategory={0}, MPN={1}", eMenuCategory, mpn));
- return null;
- }
- private void LoadRandomLogicParamter()
- {
- RandomPresetContent randomPresetContent = new RandomPresetContent();
- randomPresetContent.InitRandomPresetParamter();
- }
- private RandomPresetButton GetButtonByType(SceneEditInfo.CCateNameType.EType btnType)
- {
- if (btnType == SceneEditInfo.CCateNameType.EType.Item)
- {
- return new ItemTypeRandomPresetButton();
- }
- if (btnType == SceneEditInfo.CCateNameType.EType.Slider)
- {
- return new SliderTypeRandomPresetButton();
- }
- if (btnType != SceneEditInfo.CCateNameType.EType.Color)
- {
- return new ItemTypeRandomPresetButton();
- }
- return new ColorTypeRandomPresetButton();
- }
- public void OnButtonClick(string clickBtnName)
- {
- RandomPresetButton randomPresetButton = this.m_dicRandomPresetBtn[clickBtnName];
- randomPresetButton.m_bBtnActive = !randomPresetButton.m_bBtnActive;
- if (randomPresetButton.m_bBtnActive)
- {
- randomPresetButton.m_btnButton.defaultColor = this.activeColor;
- }
- else
- {
- randomPresetButton.m_btnButton.defaultColor = this.inActiveColor;
- }
- }
- public void Execute()
- {
- Maid maid = GameMain.Instance.CharacterMgr.GetMaid(0);
- if (maid.IsBusy)
- {
- return;
- }
- MaidProp prop = maid.GetProp(MPN.MuneL);
- int num = 0;
- if (this.m_dicRandomPresetBtn["b_BreastSize"].m_bBtnActive)
- {
- num = UnityEngine.Random.Range(prop.min, prop.max + 1);
- }
- else
- {
- num = prop.value;
- }
- int randomBaseGrpId = RandomPresetContent.GetRandomBaseGrpId(num);
- Dictionary<MPN, RandomPresetContent.RandomMapping> dictionary = new Dictionary<MPN, RandomPresetContent.RandomMapping>();
- foreach (KeyValuePair<int, RandomPresetContent.RandomMapping> keyValuePair in RandomPresetContent.m_dicRandomMapping)
- {
- if (keyValuePair.Value.randomBaseGroupId == randomBaseGrpId)
- {
- dictionary.Add(keyValuePair.Value.bodyBase.bodyBaseCategory, keyValuePair.Value);
- }
- }
- List<MPN> randomActiveListByMPN = this.GetRandomActiveListByMPN(this.m_listCheckRandomActive);
- MPN mpn = MPN.null_mpn;
- if (randomActiveListByMPN.Count > 0)
- {
- mpn = randomActiveListByMPN[UnityEngine.Random.Range(0, randomActiveListByMPN.Count)];
- foreach (MPN mpn2 in randomActiveListByMPN)
- {
- if (mpn != mpn2)
- {
- this.GetButtonByMPN(mpn2).m_bCanNotExecuteConcurrency = true;
- }
- }
- if (mpn == MPN.onepiece)
- {
- RandomPresetButton buttonByMPN = this.GetButtonByMPN(MPN.skirt);
- if (buttonByMPN.m_bBtnActive)
- {
- buttonByMPN.m_bCanNotExecuteConcurrency = true;
- }
- }
- }
- foreach (KeyValuePair<string, RandomPresetButton> keyValuePair2 in this.m_dicRandomPresetBtnOrderByExecutionOrder)
- {
- RandomPresetButton value = keyValuePair2.Value;
- if (value.m_name == "b_BreastSize")
- {
- maid.SetProp(value.m_mpn, num, false);
- value.m_lValue.text = num.ToString();
- if (value.m_bBtnActive)
- {
- maid.SetProp(MPN.MuneTare, 0, false);
- }
- }
- else if (value.m_bCanNotExecuteConcurrency)
- {
- value.m_bCanNotExecuteConcurrency = false;
- }
- else if (value.m_bBtnActive)
- {
- SceneEditInfo.CCateNameType.EType eButtonType = value.m_eButtonType;
- if (eButtonType != SceneEditInfo.CCateNameType.EType.Slider)
- {
- if (eButtonType != SceneEditInfo.CCateNameType.EType.Item)
- {
- if (eButtonType == SceneEditInfo.CCateNameType.EType.Color)
- {
- if (this.PutOnItemOrColor(value, maid))
- {
- this.ExecuteColorButtonByUnit(value, maid);
- }
- }
- }
- else if (this.PutOnItemOrColor(value, maid))
- {
- this.ExecuteRandomItemButtonByUnit(value, maid);
- if (value.m_menuCategory == SceneEditInfo.EMenuCategory.服装)
- {
- this.SetClothesFilterFlg(value);
- }
- }
- }
- else
- {
- this.ExecuteRandomNumberButtonByUnit(value, maid, dictionary);
- }
- }
- }
- SceneEdit.AllProcPropSeqStart(maid);
- base.StartCoroutine(this.ExecuteAfterSetModel(maid));
- }
- public IEnumerator ExecuteAfterSetModel(Maid maid)
- {
- while (maid.IsBusy)
- {
- yield return null;
- }
- this.LoadMaidPropData();
- this.UpdateClothesFilter();
- Debug.Log("データロード及びフィルター処理を完了しました。");
- yield break;
- yield break;
- }
- private bool IsDelOnly(SceneEditInfo.EMenuCategory targetCategory, MPN targetMpn, int targetRid)
- {
- List<SceneEdit.SCategory> categoryList = this.m_sceneEdit.CategoryList;
- foreach (SceneEdit.SCategory scategory in categoryList)
- {
- if (scategory.m_eCategory == targetCategory)
- {
- foreach (SceneEdit.SPartsType spartsType in scategory.m_listPartsType)
- {
- if (spartsType.m_mpn == targetMpn)
- {
- foreach (SceneEdit.SMenuItem smenuItem in spartsType.m_listMenu)
- {
- if (smenuItem.m_nMenuFileRID == targetRid && smenuItem.m_boDelOnly)
- {
- return true;
- }
- }
- }
- }
- }
- }
- return false;
- }
- private void SetClothesFilterFlg(RandomPresetButton btn)
- {
- if (RandomPresetContent.m_listClothesItemGroupn.Contains(btn.m_mpn))
- {
- this.m_bDoFilterClothes = true;
- }
- else if (RandomPresetContent.m_listUnderwearsItemGroup.Contains(btn.m_mpn))
- {
- this.m_bDoFilterUnderwears = true;
- }
- }
- private void UpdateClothesFilter()
- {
- if (this.m_bDoFilterClothes)
- {
- BaseMgr<PresetButtonMgr>.Instance.UpdateClothesByName("Clothes_Dress");
- }
- else if (this.m_bDoFilterUnderwears)
- {
- BaseMgr<PresetButtonMgr>.Instance.UpdateClothesByName("Clothes_Lingerie");
- }
- this.m_bDoFilterClothes = false;
- this.m_bDoFilterUnderwears = false;
- }
- private bool PutOnItemOrColor(RandomPresetButton btn, Maid maid)
- {
- RandomPresetContent.MPNMapping mpnmapping;
- if (!RandomPresetContent.m_dicMPNMapping.TryGetValue(btn.m_mpn, out mpnmapping) || mpnmapping.m_ratioToPutOn <= 0)
- {
- return true;
- }
- int num = UnityEngine.Random.Range(0, 100);
- if (mpnmapping.m_ratioToPutOn >= num)
- {
- return true;
- }
- SceneEdit.SMenuItem smenuItem = null;
- SceneEditInfo.CCateNameType.EType eButtonType = btn.m_eButtonType;
- if (eButtonType != SceneEditInfo.CCateNameType.EType.Item)
- {
- if (eButtonType == SceneEditInfo.CCateNameType.EType.Color)
- {
- MPN btnMpn = RandomPresetContent.m_dicColorFolderMapping[btn.m_mpn];
- smenuItem = this.GetMenuItemByDelOnly(btn.m_menuCategory, btnMpn);
- if (smenuItem != null)
- {
- }
- }
- }
- else
- {
- smenuItem = this.GetMenuItemByDelOnly(btn.m_menuCategory, btn.m_mpn);
- if (smenuItem != null)
- {
- }
- }
- maid.SetProp(smenuItem.m_strCateName, smenuItem.m_strMenuFileName, smenuItem.m_nMenuFileRID, false, false);
- foreach (SceneEdit.SubPropMpnData subPropMpnData in this.m_sceneEdit.subPropDatas)
- {
- if (btn.m_mpn == subPropMpnData.mpn)
- {
- subPropMpnData.manager.UpdateAllItem();
- break;
- }
- }
- return false;
- }
- private Texture2D GetDelOnlyTexture(SceneEditInfo.EMenuCategory eMenuCategory, MPN btnMpn)
- {
- SceneEdit.SMenuItem menuItemByDelOnly = this.GetMenuItemByDelOnly(eMenuCategory, btnMpn);
- if (menuItemByDelOnly != null)
- {
- return menuItemByDelOnly.m_texIconRef;
- }
- return this.m_notSettingIcon;
- }
- private SceneEdit.SMenuItem GetMenuItemByDelOnly(SceneEditInfo.EMenuCategory eMenuCategory, MPN btnMpn)
- {
- List<SceneEdit.SCategory> categoryList = this.m_sceneEdit.CategoryList;
- foreach (SceneEdit.SCategory scategory in categoryList)
- {
- if (scategory.m_eCategory == eMenuCategory)
- {
- foreach (SceneEdit.SPartsType spartsType in scategory.m_listPartsType)
- {
- if (spartsType.m_mpn == btnMpn)
- {
- foreach (SceneEdit.SMenuItem smenuItem in spartsType.m_listMenu)
- {
- if (smenuItem.m_boDelOnly)
- {
- return smenuItem;
- }
- }
- }
- }
- }
- }
- Debug.LogWarning(string.Format("除外用のアイコンが存在しませんでした。対象MPN={0}", btnMpn));
- return null;
- }
- private List<MPN> GetRandomActiveListByMPN(List<MPN> m_listCheckRandomActive)
- {
- List<MPN> list = new List<MPN>();
- foreach (MPN mpn in m_listCheckRandomActive)
- {
- RandomPresetButton buttonByMPN = this.GetButtonByMPN(mpn);
- if (buttonByMPN != null && buttonByMPN.m_bBtnActive)
- {
- list.Add(mpn);
- }
- }
- return list;
- }
- private void ExecuteRandomNumberButtonByUnit(RandomPresetButton btn, Maid maid, Dictionary<MPN, RandomPresetContent.RandomMapping> dicTargerRandomMapping)
- {
- RandomPresetContent.RandomMapping randomMapping;
- int min;
- int num;
- if (dicTargerRandomMapping.TryGetValue(btn.m_mpn, out randomMapping))
- {
- min = randomMapping.bodyBase.lowerLimit;
- num = randomMapping.bodyBase.upperLimit;
- }
- else
- {
- min = maid.GetProp(btn.m_mpn).min;
- num = maid.GetProp(btn.m_mpn).max;
- }
- int val = UnityEngine.Random.Range(min, num + 1);
- maid.SetProp(btn.m_mpn, val, false);
- btn.m_lValue.text = val.ToString();
- }
- private void ExecuteRandomItemButtonByUnit(RandomPresetButton btn, Maid maid)
- {
- List<SceneEdit.SCategory> categoryList = this.m_sceneEdit.CategoryList;
- List<SceneEdit.SMenuItem> menuItemList = this.GetMenuItemList(btn.m_menuCategory, btn.m_mpn);
- if (menuItemList == null)
- {
- return;
- }
- Dictionary<int, RandomPresetContent.PartMapping> dicMapping = RandomPresetContent.m_dicPriorityPartMapping;
- List<string> list = this.GetIconNameListIfPushButtonIsMappingTarget(dicMapping, btn.m_mpn, maid);
- if (list == null)
- {
- dicMapping = RandomPresetContent.m_dicExceptionPartMapping;
- List<string> iconNameListIfPushButtonIsMappingTarget = this.GetIconNameListIfPushButtonIsMappingTarget(dicMapping, btn.m_mpn, maid);
- if (iconNameListIfPushButtonIsMappingTarget != null)
- {
- list = this.GetRandomIconList(menuItemList, iconNameListIfPushButtonIsMappingTarget);
- }
- }
- string text = null;
- SceneEdit.SMenuItem smenuItem;
- if (list == null)
- {
- int index = UnityEngine.Random.Range(0, menuItemList.Count);
- smenuItem = menuItemList[index];
- }
- else
- {
- text = list[UnityEngine.Random.Range(0, list.Count)];
- smenuItem = this.GetMenuItemByFileName(menuItemList, text);
- }
- if (smenuItem == null)
- {
- Debug.LogWarning(string.Format("組み合わせとして存在しないパーツIDが選択されました。カテゴリ名={0}, MPN={1}, パーツ名={2}", btn.m_menuCategory, btn.m_mpn, text));
- return;
- }
- this.m_sceneEdit.customPartsWindow.ResetPoint(smenuItem.m_mpn);
- bool flag = false;
- foreach (SceneEdit.SubPropMpnData subPropMpnData in this.m_sceneEdit.subPropDatas)
- {
- if (btn.m_mpn == subPropMpnData.mpn)
- {
- flag = true;
- MaidProp prop = maid.GetProp(subPropMpnData.mpn);
- maid.SetProp(subPropMpnData.mpn.ToString(), prop.strFileName, prop.nFileNameRID, false, false);
- subPropMpnData.manager.UpdateAllItem();
- if (smenuItem.m_nMenuFileRID != prop.nFileNameRID)
- {
- subPropMpnData.manager.SetItem(smenuItem);
- subPropMpnData.manager.UpdateAllItem();
- }
- break;
- }
- }
- if (!flag)
- {
- maid.SetProp(smenuItem.m_strCateName, smenuItem.m_strMenuFileName, smenuItem.m_nMenuFileRID, false, false);
- if (smenuItem.m_mpn == MPN.eye_hi && this.m_sceneEdit.isNewFace)
- {
- maid.SetProp(MPN.eye_hi_r, smenuItem.m_strMenuFileName, smenuItem.m_nMenuFileRID, false, false);
- }
- }
- }
- private void ExecuteColorButtonByUnit(RandomPresetButton btn, Maid maid)
- {
- List<SceneEdit.SCategory> categoryList = this.m_sceneEdit.CategoryList;
- MPN mpn = RandomPresetContent.m_dicColorFolderMapping[btn.m_mpn];
- List<SceneEdit.SMenuItem> menuItemList = this.GetMenuItemList(btn.m_menuCategory, mpn);
- if (menuItemList == null)
- {
- return;
- }
- int index = UnityEngine.Random.Range(0, menuItemList.Count);
- SceneEdit.SMenuItem smenuItem = menuItemList[index];
- if (smenuItem.m_boDelOnly)
- {
- maid.SetProp(smenuItem.m_strCateName, smenuItem.m_strMenuFileName, smenuItem.m_nMenuFileRID, false, false);
- return;
- }
- if (smenuItem.m_listColorSet == null || smenuItem.m_listColorSet.Count == 0)
- {
- Debug.LogWarning(string.Format("カラーセットが存在しません。対象カテゴリ={0}, ファイル名={1}, FileRID={2}", smenuItem.m_strCateName, smenuItem.m_strMenuFileName, smenuItem.m_nMenuFileRID));
- return;
- }
- int index2 = UnityEngine.Random.Range(0, smenuItem.m_listColorSet.Count);
- SceneEdit.SMenuItem smenuItem2 = smenuItem.m_listColorSet[index2];
- if (btn.m_mpn != MPN.haircolor)
- {
- maid.SetProp(smenuItem.m_strCateName, smenuItem.m_strMenuFileName, smenuItem.m_nMenuFileRID, false, false);
- }
- maid.SetProp(smenuItem2.m_strCateName, smenuItem2.m_strMenuFileName, smenuItem2.m_nMenuFileRID, false, false);
- }
- private List<string> GetIconNameListIfPushButtonIsMappingTarget(Dictionary<int, RandomPresetContent.PartMapping> dicMapping, MPN btnMPN, Maid maid)
- {
- if (dicMapping == null)
- {
- return null;
- }
- List<string> result = null;
- foreach (KeyValuePair<int, RandomPresetContent.PartMapping> keyValuePair in dicMapping)
- {
- RandomPresetContent.PartMapping value = keyValuePair.Value;
- if (value.targetCategory == btnMPN)
- {
- MPN category = value.category;
- string strB = this.DelSuffix(maid.GetProp(category).strFileName);
- if (!string.IsNullOrEmpty(value.partId) && string.Compare(value.partId, strB, true) == 0)
- {
- result = this.GetMappingIconNameList(value.partId, dicMapping);
- return result;
- }
- }
- }
- return result;
- }
- private string DelSuffix(string str)
- {
- int num = str.IndexOf(".menu");
- if (num > 0)
- {
- return str.Substring(0, num);
- }
- return str;
- }
- private SceneEdit.SMenuItem GetMenuItemByFileName(List<SceneEdit.SMenuItem> list, string iconName)
- {
- foreach (SceneEdit.SMenuItem smenuItem in list)
- {
- if (string.Compare(this.DelSuffix(smenuItem.m_strMenuFileName), iconName, true) == 0)
- {
- return smenuItem;
- }
- }
- return null;
- }
- private List<string> GetRandomIconList(List<SceneEdit.SMenuItem> listMenuItem, List<string> listExceptionIconName)
- {
- List<string> list = new List<string>();
- foreach (SceneEdit.SMenuItem smenuItem in listMenuItem)
- {
- if (!listExceptionIconName.Contains(this.DelSuffix(smenuItem.m_strMenuFileName)))
- {
- list.Add(this.DelSuffix(smenuItem.m_strMenuFileName));
- }
- }
- return list;
- }
- private List<string> GetMappingIconNameList(string partId, Dictionary<int, RandomPresetContent.PartMapping> dicMapping)
- {
- List<string> list = new List<string>();
- foreach (KeyValuePair<int, RandomPresetContent.PartMapping> keyValuePair in dicMapping)
- {
- if (keyValuePair.Value.partId == partId)
- {
- list.Add(keyValuePair.Value.targetPartId);
- }
- }
- return list;
- }
- public RandomPresetButton GetButtonByMPN(MPN mpn)
- {
- RandomPresetContent.MPNMapping mpnmapping;
- if (RandomPresetContent.m_dicMPNMapping.TryGetValue(mpn, out mpnmapping))
- {
- return this.m_dicRandomPresetBtn[mpnmapping.m_buttonName];
- }
- return null;
- }
- public void OnAllButtonClick()
- {
- Color defaultColor = this.inActiveColor;
- bool bBtnActive = false;
- string name = UIButton.current.name;
- if (name == "SelectAll")
- {
- bBtnActive = true;
- defaultColor = this.activeColor;
- }
- else if (name == "DeselectAll")
- {
- bBtnActive = false;
- defaultColor = this.inActiveColor;
- }
- foreach (KeyValuePair<string, RandomPresetButton> keyValuePair in this.m_dicRandomPresetBtn)
- {
- keyValuePair.Value.m_bBtnActive = bBtnActive;
- keyValuePair.Value.m_btnButton.defaultColor = defaultColor;
- }
- }
- public void OnDisable()
- {
- base.StopCoroutine(this.ExecuteAfterSetModel(null));
- Debug.Log("データロード等がコルーチンで実行中の場合、PanelのCloseに伴い処理を停止します。");
- }
- [SerializeField]
- private RandomPresetMgr randomRandomPresetMgr;
- [SerializeField]
- private UILabel[] categoryTitleLabels;
- private SceneEdit m_sceneEdit;
- private Dictionary<string, RandomPresetButton> m_dicRandomPresetBtn;
- private Dictionary<MPN, SceneEditInfo.CCateNameType> m_dicPartsTypePair;
- private IOrderedEnumerable<KeyValuePair<string, RandomPresetButton>> m_dicRandomPresetBtnOrderByExecutionOrder;
- private List<MPN> m_listCheckRandomActive;
- private Texture2D m_notSettingIcon;
- private Texture2D m_defaultColorIcon;
- private bool m_bDoFilterUnderwears;
- private bool m_bDoFilterClothes;
- private Color activeColor;
- private Color inActiveColor;
- private const string RANDOM_BASE_PART_NAME = "b_BreastSize";
- private const int NOT_SETTING = 0;
- private const string NOT_SETTING_ICON_PATH = "SceneEdit/RandomPreset/Texture/_I_del";
- private const string DEFAULT_COLOR_ICON_PATH = "SceneEdit/RandomPreset/Texture/cm3d2_edit_random_partcolor";
- private const string STR_FILENAME_SUFFIX = ".menu";
- private const int NOT_SET_RATIO_TO_PUT_ON = 0;
- private enum MappingType
- {
- Priority,
- Exception
- }
- public enum ButtonType
- {
- Slider,
- Item,
- ItemAndColor
- }
- }
|