RandomPresetCtrl.cs 24 KB

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