RandomPresetCtrl.cs 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. using UnityEngine;
  6. public class RandomPresetCtrl : MonoBehaviour
  7. {
  8. public void Init(GameObject goRandomPresetPanel)
  9. {
  10. string text = "random_preset_category_name.nei";
  11. using (AFileBase afileBase = GameUty.FileSystem.FileOpen(text))
  12. {
  13. using (CsvParser csvParser = new CsvParser())
  14. {
  15. bool condition = csvParser.Open(afileBase);
  16. NDebug.Assert(condition, text + "\nopen failed.");
  17. NDebug.Assert(csvParser.max_cell_y - 1 == this.categoryTitleLabels.Length, text + "に書かれているカテゴリー数とオブジェクト数が一致していません");
  18. for (int i = 1; i < csvParser.max_cell_y; i++)
  19. {
  20. this.categoryTitleLabels[i - 1].text = csvParser.GetCellAsString(0, i);
  21. }
  22. }
  23. }
  24. this.LoadRandomLogicParamter();
  25. this.CreateRandomItem(goRandomPresetPanel);
  26. this.m_listCheckRandomActive = new List<MPN>
  27. {
  28. MPN.wear,
  29. MPN.mizugi,
  30. MPN.onepiece
  31. };
  32. this.m_notSettingIcon = (Resources.Load("SceneEdit/RandomPreset/Texture/_I_del") as Texture2D);
  33. this.m_defaultColorIcon = (Resources.Load("SceneEdit/RandomPreset/Texture/_I_del") as Texture2D);
  34. this.m_dicRandomPresetBtnOrderByExecutionOrder = from pair in this.m_dicRandomPresetBtn
  35. orderby pair.Value.m_executionOrder
  36. select pair;
  37. this.LoadMaidPropData();
  38. }
  39. private void CreateRandomItem(GameObject goRandomPresetPanel)
  40. {
  41. this.m_sceneEdit = GameObject.Find("__SceneEdit__").GetComponent<SceneEdit>();
  42. this.m_dicPartsTypePair = SceneEditInfo.m_dicPartsTypePair;
  43. this.m_dicRandomPresetBtn = new Dictionary<string, RandomPresetButton>();
  44. bool flag = false;
  45. foreach (KeyValuePair<MPN, SceneEditInfo.CCateNameType> keyValuePair in this.m_dicPartsTypePair)
  46. {
  47. RandomPresetContent.MPNMapping mpnmapping;
  48. if (RandomPresetContent.m_dicMPNMapping.TryGetValue(keyValuePair.Key, out mpnmapping))
  49. {
  50. string str;
  51. if (RandomPresetContent.m_dicCategoryMapping.TryGetValue(keyValuePair.Value.m_eMenuCate, out str))
  52. {
  53. GameObject childObject = UTY.GetChildObject(goRandomPresetPanel, "Contents/" + str + "/Buttons/" + mpnmapping.m_buttonName, true);
  54. NDebug.Assert(childObject != null, string.Concat(new string[]
  55. {
  56. "ランダムプリセットのボタン[",
  57. mpnmapping.m_buttonTitle,
  58. "]のオブジェクト、[",
  59. mpnmapping.m_buttonName,
  60. "]が見つかりませんでした"
  61. }));
  62. UTY.GetChildObject(childObject, "Title", false).GetComponent<UILabel>().text = mpnmapping.m_buttonTitle;
  63. UIButton component = childObject.GetComponent<UIButton>();
  64. if (!flag)
  65. {
  66. this.activeColor = new Color(component.defaultColor.r, component.defaultColor.g, component.defaultColor.b, 1f);
  67. this.inActiveColor = component.defaultColor;
  68. flag = true;
  69. }
  70. SceneEditInfo.CCateNameType.EType eType = keyValuePair.Value.m_eType;
  71. RandomPresetButton buttonByType = this.GetButtonByType(eType);
  72. buttonByType.m_menuCategory = keyValuePair.Value.m_eMenuCate;
  73. buttonByType.m_eButtonType = eType;
  74. buttonByType.m_name = mpnmapping.m_buttonName;
  75. buttonByType.m_mpn = keyValuePair.Key;
  76. buttonByType.m_btnButton = component;
  77. buttonByType.m_bBtnActive = false;
  78. buttonByType.m_executionOrder = mpnmapping.m_executionOrder;
  79. if (eType != SceneEditInfo.CCateNameType.EType.Item)
  80. {
  81. if (eType != SceneEditInfo.CCateNameType.EType.Slider)
  82. {
  83. if (eType == SceneEditInfo.CCateNameType.EType.Color)
  84. {
  85. buttonByType.m_txtColor = UTY.GetChildObject(childObject, "Color", false).GetComponent<UITexture>();
  86. }
  87. }
  88. else
  89. {
  90. buttonByType.m_lValue = UTY.GetChildObject(childObject, "Value", false).GetComponent<UILabel>();
  91. }
  92. }
  93. else
  94. {
  95. buttonByType.m_txtItem = UTY.GetChildObject(childObject, "Item", false).GetComponent<UITexture>();
  96. }
  97. this.m_dicRandomPresetBtn.Add(buttonByType.m_name, buttonByType);
  98. }
  99. }
  100. }
  101. }
  102. public void LoadMaidPropData()
  103. {
  104. Maid maid = GameMain.Instance.CharacterMgr.GetMaid(0);
  105. MaidProp prop = maid.GetProp(MPN.MuneL);
  106. foreach (KeyValuePair<string, RandomPresetButton> keyValuePair in this.m_dicRandomPresetBtn)
  107. {
  108. RandomPresetButton value = keyValuePair.Value;
  109. if (value.m_eButtonType == SceneEditInfo.CCateNameType.EType.Item)
  110. {
  111. int num = maid.GetProp(value.m_mpn).nFileNameRID;
  112. foreach (SceneEdit.SubPropMpnData subPropMpnData in this.m_sceneEdit.subPropDatas)
  113. {
  114. if (value.m_mpn == subPropMpnData.mpn)
  115. {
  116. if (subPropMpnData.manager.sloatItems != null && subPropMpnData.manager.sloatItems[0].menuItem != null)
  117. {
  118. num = subPropMpnData.manager.sloatItems[0].menuItem.m_nMenuFileRID;
  119. }
  120. break;
  121. }
  122. }
  123. Texture2D texture2D;
  124. if (num == 0)
  125. {
  126. texture2D = this.m_notSettingIcon;
  127. }
  128. else
  129. {
  130. texture2D = this.GetTextureByRid(value.m_menuCategory, value.m_mpn, num);
  131. }
  132. value.m_txtItem.mainTexture = texture2D;
  133. }
  134. else if (value.m_eButtonType == SceneEditInfo.CCateNameType.EType.Slider)
  135. {
  136. value.m_lValue.text = maid.GetProp(value.m_mpn).value.ToString();
  137. }
  138. else if (value.m_eButtonType == SceneEditInfo.CCateNameType.EType.Color)
  139. {
  140. int nFileNameRID = maid.GetProp(value.m_mpn).nFileNameRID;
  141. Texture2D texture2D;
  142. if (nFileNameRID == 0)
  143. {
  144. texture2D = this.m_defaultColorIcon;
  145. }
  146. else
  147. {
  148. texture2D = this.GetColorTextureByRid(value.m_menuCategory, value.m_mpn, nFileNameRID);
  149. if (texture2D == null)
  150. {
  151. texture2D = this.m_defaultColorIcon;
  152. }
  153. }
  154. value.m_txtColor.mainTexture = texture2D;
  155. }
  156. }
  157. Debug.Log("データのロード処理が完了しました。");
  158. }
  159. private Texture2D GetTextureByRid(SceneEditInfo.EMenuCategory eMenuCategory, MPN btnMpn, int rid)
  160. {
  161. List<SceneEdit.SCategory> categoryList = this.m_sceneEdit.CategoryList;
  162. foreach (SceneEdit.SCategory scategory in categoryList)
  163. {
  164. if (scategory.m_eCategory == eMenuCategory)
  165. {
  166. foreach (SceneEdit.SPartsType spartsType in scategory.m_listPartsType)
  167. {
  168. if (spartsType.m_mpn == btnMpn)
  169. {
  170. foreach (SceneEdit.SMenuItem smenuItem in spartsType.m_listMenu)
  171. {
  172. if (smenuItem.m_nMenuFileRID == rid)
  173. {
  174. if (smenuItem.m_boDelOnly)
  175. {
  176. return smenuItem.m_texIcon;
  177. }
  178. return smenuItem.m_texIcon;
  179. }
  180. }
  181. return this.m_notSettingIcon;
  182. }
  183. }
  184. }
  185. }
  186. return null;
  187. }
  188. private Texture2D GetColorTextureByRid(SceneEditInfo.EMenuCategory eMenuCategory, MPN btnMpn, int rid)
  189. {
  190. MPN mpn = RandomPresetContent.m_dicColorFolderMapping[btnMpn];
  191. List<SceneEdit.SCategory> categoryList = this.m_sceneEdit.CategoryList;
  192. foreach (SceneEdit.SCategory scategory in categoryList)
  193. {
  194. if (scategory.m_eCategory == eMenuCategory)
  195. {
  196. foreach (SceneEdit.SPartsType spartsType in scategory.m_listPartsType)
  197. {
  198. if (spartsType.m_mpn == mpn)
  199. {
  200. foreach (SceneEdit.SMenuItem smenuItem in spartsType.m_listMenu)
  201. {
  202. foreach (SceneEdit.SMenuItem smenuItem2 in smenuItem.m_listColorSet)
  203. {
  204. if (smenuItem2.m_nMenuFileRID == rid)
  205. {
  206. if (smenuItem2.m_bColor)
  207. {
  208. if (smenuItem2.m_boDelOnly)
  209. {
  210. return this.m_notSettingIcon;
  211. }
  212. return smenuItem2.m_texIconRandomColor;
  213. }
  214. else
  215. {
  216. Debug.LogError(string.Format("SMenuItemクラスのm_bColorフラグの設定が誤っています。設定されているm_bColor={0}", smenuItem.m_bColor));
  217. }
  218. }
  219. }
  220. }
  221. }
  222. }
  223. }
  224. }
  225. return null;
  226. }
  227. private List<SceneEdit.SMenuItem> GetMenuItemList(SceneEditInfo.EMenuCategory eMenuCategory, MPN mpn)
  228. {
  229. List<SceneEdit.SCategory> categoryList = this.m_sceneEdit.CategoryList;
  230. foreach (SceneEdit.SCategory scategory in categoryList)
  231. {
  232. if (scategory.m_eCategory == eMenuCategory)
  233. {
  234. foreach (SceneEdit.SPartsType spartsType in scategory.m_listPartsType)
  235. {
  236. if (spartsType.m_mpn == mpn)
  237. {
  238. return spartsType.m_listMenu;
  239. }
  240. }
  241. }
  242. }
  243. Debug.LogError(string.Format("不適切なメニューカテゴリとMPNが指定されました。 MenuCategory={0}, MPN={1}", eMenuCategory, mpn));
  244. return null;
  245. }
  246. private void LoadRandomLogicParamter()
  247. {
  248. RandomPresetContent randomPresetContent = new RandomPresetContent();
  249. randomPresetContent.InitRandomPresetParamter();
  250. }
  251. private RandomPresetButton GetButtonByType(SceneEditInfo.CCateNameType.EType btnType)
  252. {
  253. if (btnType == SceneEditInfo.CCateNameType.EType.Item)
  254. {
  255. return new ItemTypeRandomPresetButton();
  256. }
  257. if (btnType == SceneEditInfo.CCateNameType.EType.Slider)
  258. {
  259. return new SliderTypeRandomPresetButton();
  260. }
  261. if (btnType != SceneEditInfo.CCateNameType.EType.Color)
  262. {
  263. return new ItemTypeRandomPresetButton();
  264. }
  265. return new ColorTypeRandomPresetButton();
  266. }
  267. public void OnButtonClick(string clickBtnName)
  268. {
  269. RandomPresetButton randomPresetButton = this.m_dicRandomPresetBtn[clickBtnName];
  270. randomPresetButton.m_bBtnActive = !randomPresetButton.m_bBtnActive;
  271. if (randomPresetButton.m_bBtnActive)
  272. {
  273. randomPresetButton.m_btnButton.defaultColor = this.activeColor;
  274. }
  275. else
  276. {
  277. randomPresetButton.m_btnButton.defaultColor = this.inActiveColor;
  278. }
  279. }
  280. public void Execute()
  281. {
  282. Maid maid = GameMain.Instance.CharacterMgr.GetMaid(0);
  283. if (maid.IsBusy)
  284. {
  285. return;
  286. }
  287. MaidProp prop = maid.GetProp(MPN.MuneL);
  288. int num = 0;
  289. if (this.m_dicRandomPresetBtn["b_BreastSize"].m_bBtnActive)
  290. {
  291. num = UnityEngine.Random.Range(prop.min, prop.max + 1);
  292. }
  293. else
  294. {
  295. num = prop.value;
  296. }
  297. int randomBaseGrpId = RandomPresetContent.GetRandomBaseGrpId(num);
  298. Dictionary<MPN, RandomPresetContent.RandomMapping> dictionary = new Dictionary<MPN, RandomPresetContent.RandomMapping>();
  299. foreach (KeyValuePair<int, RandomPresetContent.RandomMapping> keyValuePair in RandomPresetContent.m_dicRandomMapping)
  300. {
  301. if (keyValuePair.Value.randomBaseGroupId == randomBaseGrpId)
  302. {
  303. dictionary.Add(keyValuePair.Value.bodyBase.bodyBaseCategory, keyValuePair.Value);
  304. }
  305. }
  306. List<MPN> randomActiveListByMPN = this.GetRandomActiveListByMPN(this.m_listCheckRandomActive);
  307. MPN mpn = MPN.null_mpn;
  308. if (randomActiveListByMPN.Count > 0)
  309. {
  310. mpn = randomActiveListByMPN[UnityEngine.Random.Range(0, randomActiveListByMPN.Count)];
  311. foreach (MPN mpn2 in randomActiveListByMPN)
  312. {
  313. if (mpn != mpn2)
  314. {
  315. this.GetButtonByMPN(mpn2).m_bCanNotExecuteConcurrency = true;
  316. }
  317. }
  318. if (mpn == MPN.onepiece)
  319. {
  320. RandomPresetButton buttonByMPN = this.GetButtonByMPN(MPN.skirt);
  321. if (buttonByMPN.m_bBtnActive)
  322. {
  323. buttonByMPN.m_bCanNotExecuteConcurrency = true;
  324. }
  325. }
  326. }
  327. foreach (KeyValuePair<string, RandomPresetButton> keyValuePair2 in this.m_dicRandomPresetBtnOrderByExecutionOrder)
  328. {
  329. RandomPresetButton value = keyValuePair2.Value;
  330. if (value.m_name == "b_BreastSize")
  331. {
  332. maid.SetProp(value.m_mpn, num, false);
  333. value.m_lValue.text = num.ToString();
  334. if (value.m_bBtnActive)
  335. {
  336. maid.SetProp(MPN.MuneTare, 0, false);
  337. }
  338. }
  339. else if (value.m_bCanNotExecuteConcurrency)
  340. {
  341. value.m_bCanNotExecuteConcurrency = false;
  342. }
  343. else if (value.m_bBtnActive)
  344. {
  345. SceneEditInfo.CCateNameType.EType eButtonType = value.m_eButtonType;
  346. if (eButtonType != SceneEditInfo.CCateNameType.EType.Slider)
  347. {
  348. if (eButtonType != SceneEditInfo.CCateNameType.EType.Item)
  349. {
  350. if (eButtonType == SceneEditInfo.CCateNameType.EType.Color)
  351. {
  352. if (this.PutOnItemOrColor(value, maid))
  353. {
  354. this.ExecuteColorButtonByUnit(value, maid);
  355. }
  356. }
  357. }
  358. else if (this.PutOnItemOrColor(value, maid))
  359. {
  360. this.ExecuteRandomItemButtonByUnit(value, maid);
  361. if (value.m_menuCategory == SceneEditInfo.EMenuCategory.服装)
  362. {
  363. this.SetClothesFilterFlg(value);
  364. }
  365. }
  366. }
  367. else
  368. {
  369. this.ExecuteRandomNumberButtonByUnit(value, maid, dictionary);
  370. }
  371. }
  372. }
  373. maid.AllProcPropSeqStart();
  374. base.StartCoroutine(this.ExecuteAfterSetModel(maid));
  375. }
  376. public IEnumerator ExecuteAfterSetModel(Maid maid)
  377. {
  378. while (maid.IsBusy)
  379. {
  380. yield return null;
  381. }
  382. this.LoadMaidPropData();
  383. this.UpdateClothesFilter();
  384. Debug.Log("データロード及びフィルター処理を完了しました。");
  385. yield break;
  386. yield break;
  387. }
  388. private bool IsDelOnly(SceneEditInfo.EMenuCategory targetCategory, MPN targetMpn, int targetRid)
  389. {
  390. List<SceneEdit.SCategory> categoryList = this.m_sceneEdit.CategoryList;
  391. foreach (SceneEdit.SCategory scategory in categoryList)
  392. {
  393. if (scategory.m_eCategory == targetCategory)
  394. {
  395. foreach (SceneEdit.SPartsType spartsType in scategory.m_listPartsType)
  396. {
  397. if (spartsType.m_mpn == targetMpn)
  398. {
  399. foreach (SceneEdit.SMenuItem smenuItem in spartsType.m_listMenu)
  400. {
  401. if (smenuItem.m_nMenuFileRID == targetRid && smenuItem.m_boDelOnly)
  402. {
  403. return true;
  404. }
  405. }
  406. }
  407. }
  408. }
  409. }
  410. return false;
  411. }
  412. private void SetClothesFilterFlg(RandomPresetButton btn)
  413. {
  414. if (RandomPresetContent.m_listClothesItemGroupn.Contains(btn.m_mpn))
  415. {
  416. this.m_bDoFilterClothes = true;
  417. }
  418. else if (RandomPresetContent.m_listUnderwearsItemGroup.Contains(btn.m_mpn))
  419. {
  420. this.m_bDoFilterUnderwears = true;
  421. }
  422. }
  423. private void UpdateClothesFilter()
  424. {
  425. if (this.m_bDoFilterClothes)
  426. {
  427. BaseMgr<PresetButtonMgr>.Instance.UpdateClothesByName("Clothes_Dress");
  428. }
  429. else if (this.m_bDoFilterUnderwears)
  430. {
  431. BaseMgr<PresetButtonMgr>.Instance.UpdateClothesByName("Clothes_Lingerie");
  432. }
  433. this.m_bDoFilterClothes = false;
  434. this.m_bDoFilterUnderwears = false;
  435. }
  436. private bool PutOnItemOrColor(RandomPresetButton btn, Maid maid)
  437. {
  438. RandomPresetContent.MPNMapping mpnmapping;
  439. if (!RandomPresetContent.m_dicMPNMapping.TryGetValue(btn.m_mpn, out mpnmapping) || mpnmapping.m_ratioToPutOn <= 0)
  440. {
  441. return true;
  442. }
  443. int num = UnityEngine.Random.Range(0, 100);
  444. if (mpnmapping.m_ratioToPutOn >= num)
  445. {
  446. return true;
  447. }
  448. SceneEdit.SMenuItem smenuItem = null;
  449. SceneEditInfo.CCateNameType.EType eButtonType = btn.m_eButtonType;
  450. if (eButtonType != SceneEditInfo.CCateNameType.EType.Item)
  451. {
  452. if (eButtonType == SceneEditInfo.CCateNameType.EType.Color)
  453. {
  454. MPN btnMpn = RandomPresetContent.m_dicColorFolderMapping[btn.m_mpn];
  455. smenuItem = this.GetMenuItemByDelOnly(btn.m_menuCategory, btnMpn);
  456. if (smenuItem != null)
  457. {
  458. }
  459. }
  460. }
  461. else
  462. {
  463. smenuItem = this.GetMenuItemByDelOnly(btn.m_menuCategory, btn.m_mpn);
  464. if (smenuItem != null)
  465. {
  466. }
  467. }
  468. maid.SetProp(smenuItem.m_strCateName, smenuItem.m_strMenuFileName, smenuItem.m_nMenuFileRID, false, false);
  469. foreach (SceneEdit.SubPropMpnData subPropMpnData in this.m_sceneEdit.subPropDatas)
  470. {
  471. if (btn.m_mpn == subPropMpnData.mpn)
  472. {
  473. subPropMpnData.manager.UpdateAllItem();
  474. break;
  475. }
  476. }
  477. return false;
  478. }
  479. private Texture2D GetDelOnlyTexture(SceneEditInfo.EMenuCategory eMenuCategory, MPN btnMpn)
  480. {
  481. SceneEdit.SMenuItem menuItemByDelOnly = this.GetMenuItemByDelOnly(eMenuCategory, btnMpn);
  482. if (menuItemByDelOnly != null)
  483. {
  484. return menuItemByDelOnly.m_texIcon;
  485. }
  486. return this.m_notSettingIcon;
  487. }
  488. private SceneEdit.SMenuItem GetMenuItemByDelOnly(SceneEditInfo.EMenuCategory eMenuCategory, MPN btnMpn)
  489. {
  490. List<SceneEdit.SCategory> categoryList = this.m_sceneEdit.CategoryList;
  491. foreach (SceneEdit.SCategory scategory in categoryList)
  492. {
  493. if (scategory.m_eCategory == eMenuCategory)
  494. {
  495. foreach (SceneEdit.SPartsType spartsType in scategory.m_listPartsType)
  496. {
  497. if (spartsType.m_mpn == btnMpn)
  498. {
  499. foreach (SceneEdit.SMenuItem smenuItem in spartsType.m_listMenu)
  500. {
  501. if (smenuItem.m_boDelOnly)
  502. {
  503. return smenuItem;
  504. }
  505. }
  506. }
  507. }
  508. }
  509. }
  510. Debug.LogWarning(string.Format("除外用のアイコンが存在しませんでした。対象MPN={0}", btnMpn));
  511. return null;
  512. }
  513. private List<MPN> GetRandomActiveListByMPN(List<MPN> m_listCheckRandomActive)
  514. {
  515. List<MPN> list = new List<MPN>();
  516. foreach (MPN mpn in m_listCheckRandomActive)
  517. {
  518. RandomPresetButton buttonByMPN = this.GetButtonByMPN(mpn);
  519. if (buttonByMPN.m_bBtnActive)
  520. {
  521. list.Add(mpn);
  522. }
  523. }
  524. return list;
  525. }
  526. private void ExecuteRandomNumberButtonByUnit(RandomPresetButton btn, Maid maid, Dictionary<MPN, RandomPresetContent.RandomMapping> dicTargerRandomMapping)
  527. {
  528. RandomPresetContent.RandomMapping randomMapping;
  529. int min;
  530. int num;
  531. if (dicTargerRandomMapping.TryGetValue(btn.m_mpn, out randomMapping))
  532. {
  533. min = randomMapping.bodyBase.lowerLimit;
  534. num = randomMapping.bodyBase.upperLimit;
  535. }
  536. else
  537. {
  538. min = maid.GetProp(btn.m_mpn).min;
  539. num = maid.GetProp(btn.m_mpn).max;
  540. }
  541. int val = UnityEngine.Random.Range(min, num + 1);
  542. maid.SetProp(btn.m_mpn, val, false);
  543. btn.m_lValue.text = val.ToString();
  544. }
  545. private void ExecuteRandomItemButtonByUnit(RandomPresetButton btn, Maid maid)
  546. {
  547. List<SceneEdit.SCategory> categoryList = this.m_sceneEdit.CategoryList;
  548. List<SceneEdit.SMenuItem> menuItemList = this.GetMenuItemList(btn.m_menuCategory, btn.m_mpn);
  549. Dictionary<int, RandomPresetContent.PartMapping> dicMapping = RandomPresetContent.m_dicPriorityPartMapping;
  550. List<string> list = this.GetIconNameListIfPushButtonIsMappingTarget(dicMapping, btn.m_mpn, maid);
  551. if (list == null)
  552. {
  553. dicMapping = RandomPresetContent.m_dicExceptionPartMapping;
  554. List<string> iconNameListIfPushButtonIsMappingTarget = this.GetIconNameListIfPushButtonIsMappingTarget(dicMapping, btn.m_mpn, maid);
  555. if (iconNameListIfPushButtonIsMappingTarget != null)
  556. {
  557. list = this.GetRandomIconList(menuItemList, iconNameListIfPushButtonIsMappingTarget);
  558. }
  559. }
  560. string text = null;
  561. SceneEdit.SMenuItem smenuItem;
  562. if (list == null)
  563. {
  564. int index = UnityEngine.Random.Range(0, menuItemList.Count);
  565. smenuItem = menuItemList[index];
  566. }
  567. else
  568. {
  569. text = list[UnityEngine.Random.Range(0, list.Count)];
  570. smenuItem = this.GetMenuItemByFileName(menuItemList, text);
  571. }
  572. if (smenuItem == null)
  573. {
  574. Debug.LogWarning(string.Format("組み合わせとして存在しないパーツIDが選択されました。カテゴリ名={0}, MPN={1}, パーツ名={2}", btn.m_menuCategory, btn.m_mpn, text));
  575. return;
  576. }
  577. this.m_sceneEdit.customPartsWindow.ResetPoint(smenuItem.m_mpn);
  578. bool flag = false;
  579. foreach (SceneEdit.SubPropMpnData subPropMpnData in this.m_sceneEdit.subPropDatas)
  580. {
  581. if (btn.m_mpn == subPropMpnData.mpn)
  582. {
  583. flag = true;
  584. MaidProp prop = maid.GetProp(subPropMpnData.mpn);
  585. maid.SetProp(subPropMpnData.mpn.ToString(), prop.strFileName, prop.nFileNameRID, false, false);
  586. subPropMpnData.manager.UpdateAllItem();
  587. if (smenuItem.m_nMenuFileRID != prop.nFileNameRID)
  588. {
  589. subPropMpnData.manager.SetItem(smenuItem);
  590. subPropMpnData.manager.UpdateAllItem();
  591. }
  592. break;
  593. }
  594. }
  595. if (!flag)
  596. {
  597. maid.SetProp(smenuItem.m_strCateName, smenuItem.m_strMenuFileName, smenuItem.m_nMenuFileRID, false, false);
  598. }
  599. }
  600. private void ExecuteColorButtonByUnit(RandomPresetButton btn, Maid maid)
  601. {
  602. List<SceneEdit.SCategory> categoryList = this.m_sceneEdit.CategoryList;
  603. MPN mpn = RandomPresetContent.m_dicColorFolderMapping[btn.m_mpn];
  604. List<SceneEdit.SMenuItem> menuItemList = this.GetMenuItemList(btn.m_menuCategory, mpn);
  605. int index = UnityEngine.Random.Range(0, menuItemList.Count);
  606. SceneEdit.SMenuItem smenuItem = menuItemList[index];
  607. if (smenuItem.m_boDelOnly)
  608. {
  609. maid.SetProp(smenuItem.m_strCateName, smenuItem.m_strMenuFileName, smenuItem.m_nMenuFileRID, false, false);
  610. return;
  611. }
  612. if (smenuItem.m_listColorSet == null || smenuItem.m_listColorSet.Count == 0)
  613. {
  614. Debug.LogWarning(string.Format("カラーセットが存在しません。対象カテゴリ={0}, ファイル名={1}, FileRID={2}", smenuItem.m_strCateName, smenuItem.m_strMenuFileName, smenuItem.m_nMenuFileRID));
  615. return;
  616. }
  617. int index2 = UnityEngine.Random.Range(0, smenuItem.m_listColorSet.Count);
  618. SceneEdit.SMenuItem smenuItem2 = smenuItem.m_listColorSet[index2];
  619. if (btn.m_mpn != MPN.haircolor)
  620. {
  621. maid.SetProp(smenuItem.m_strCateName, smenuItem.m_strMenuFileName, smenuItem.m_nMenuFileRID, false, false);
  622. }
  623. maid.SetProp(smenuItem2.m_strCateName, smenuItem2.m_strMenuFileName, smenuItem2.m_nMenuFileRID, false, false);
  624. }
  625. private List<string> GetIconNameListIfPushButtonIsMappingTarget(Dictionary<int, RandomPresetContent.PartMapping> dicMapping, MPN btnMPN, Maid maid)
  626. {
  627. if (dicMapping == null)
  628. {
  629. return null;
  630. }
  631. List<string> result = null;
  632. foreach (KeyValuePair<int, RandomPresetContent.PartMapping> keyValuePair in dicMapping)
  633. {
  634. RandomPresetContent.PartMapping value = keyValuePair.Value;
  635. if (value.targetCategory == btnMPN)
  636. {
  637. MPN category = value.category;
  638. string strB = this.DelSuffix(maid.GetProp(category).strFileName);
  639. if (!string.IsNullOrEmpty(value.partId) && string.Compare(value.partId, strB, true) == 0)
  640. {
  641. result = this.GetMappingIconNameList(value.partId, dicMapping);
  642. return result;
  643. }
  644. }
  645. }
  646. return result;
  647. }
  648. private string DelSuffix(string str)
  649. {
  650. int num = str.IndexOf(".menu");
  651. if (num > 0)
  652. {
  653. return str.Substring(0, num);
  654. }
  655. return str;
  656. }
  657. private SceneEdit.SMenuItem GetMenuItemByFileName(List<SceneEdit.SMenuItem> list, string iconName)
  658. {
  659. foreach (SceneEdit.SMenuItem smenuItem in list)
  660. {
  661. if (string.Compare(this.DelSuffix(smenuItem.m_strMenuFileName), iconName, true) == 0)
  662. {
  663. return smenuItem;
  664. }
  665. }
  666. return null;
  667. }
  668. private List<string> GetRandomIconList(List<SceneEdit.SMenuItem> listMenuItem, List<string> listExceptionIconName)
  669. {
  670. List<string> list = new List<string>();
  671. foreach (SceneEdit.SMenuItem smenuItem in listMenuItem)
  672. {
  673. if (!listExceptionIconName.Contains(this.DelSuffix(smenuItem.m_strMenuFileName)))
  674. {
  675. list.Add(this.DelSuffix(smenuItem.m_strMenuFileName));
  676. }
  677. }
  678. return list;
  679. }
  680. private List<string> GetMappingIconNameList(string partId, Dictionary<int, RandomPresetContent.PartMapping> dicMapping)
  681. {
  682. List<string> list = new List<string>();
  683. foreach (KeyValuePair<int, RandomPresetContent.PartMapping> keyValuePair in dicMapping)
  684. {
  685. if (keyValuePair.Value.partId == partId)
  686. {
  687. list.Add(keyValuePair.Value.targetPartId);
  688. }
  689. }
  690. return list;
  691. }
  692. public RandomPresetButton GetButtonByMPN(MPN mpn)
  693. {
  694. RandomPresetContent.MPNMapping mpnmapping;
  695. if (RandomPresetContent.m_dicMPNMapping.TryGetValue(mpn, out mpnmapping))
  696. {
  697. return this.m_dicRandomPresetBtn[mpnmapping.m_buttonName];
  698. }
  699. return null;
  700. }
  701. public void OnAllButtonClick()
  702. {
  703. Color defaultColor = this.inActiveColor;
  704. bool bBtnActive = false;
  705. string name = UIButton.current.name;
  706. if (name == "SelectAll")
  707. {
  708. bBtnActive = true;
  709. defaultColor = this.activeColor;
  710. }
  711. else if (name == "DeselectAll")
  712. {
  713. bBtnActive = false;
  714. defaultColor = this.inActiveColor;
  715. }
  716. foreach (KeyValuePair<string, RandomPresetButton> keyValuePair in this.m_dicRandomPresetBtn)
  717. {
  718. keyValuePair.Value.m_bBtnActive = bBtnActive;
  719. keyValuePair.Value.m_btnButton.defaultColor = defaultColor;
  720. }
  721. }
  722. public void OnDisable()
  723. {
  724. base.StopCoroutine(this.ExecuteAfterSetModel(null));
  725. Debug.Log("データロード等がコルーチンで実行中の場合、PanelのCloseに伴い処理を停止します。");
  726. }
  727. [SerializeField]
  728. private UILabel[] categoryTitleLabels;
  729. private SceneEdit m_sceneEdit;
  730. private Dictionary<string, RandomPresetButton> m_dicRandomPresetBtn;
  731. private Dictionary<MPN, SceneEditInfo.CCateNameType> m_dicPartsTypePair;
  732. private IOrderedEnumerable<KeyValuePair<string, RandomPresetButton>> m_dicRandomPresetBtnOrderByExecutionOrder;
  733. private List<MPN> m_listCheckRandomActive;
  734. private Texture2D m_notSettingIcon;
  735. private Texture2D m_defaultColorIcon;
  736. private bool m_bDoFilterUnderwears;
  737. private bool m_bDoFilterClothes;
  738. private Color activeColor;
  739. private Color inActiveColor;
  740. private const string RANDOM_BASE_PART_NAME = "b_BreastSize";
  741. private const int NOT_SETTING = 0;
  742. private const string NOT_SETTING_ICON_PATH = "SceneEdit/RandomPreset/Texture/_I_del";
  743. private const string DEFAULT_COLOR_ICON_PATH = "SceneEdit/RandomPreset/Texture/cm3d2_edit_random_partcolor";
  744. private const string STR_FILENAME_SUFFIX = ".menu";
  745. private const int NOT_SET_RATIO_TO_PUT_ON = 0;
  746. private enum MappingType
  747. {
  748. Priority,
  749. Exception
  750. }
  751. public enum ButtonType
  752. {
  753. Slider,
  754. Item,
  755. ItemAndColor
  756. }
  757. }