RandomPresetCtrl.cs 25 KB

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