ResultWorkCtrl.cs 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. using com.workman.cm3d2.task;
  6. using PlayerStatus;
  7. using Schedule;
  8. using UnityEngine;
  9. public class ResultWorkCtrl : BaseCreateViewerCtrl
  10. {
  11. public Action<string> ActionToDisplayCommuBonus { get; set; }
  12. public void Init(ResultWorkMgr resultWorkMgr, GameObject goPanel)
  13. {
  14. this.m_mgr = resultWorkMgr;
  15. this.m_goPanel = goPanel;
  16. foreach (GameObject gameObject in this.disableObjectList)
  17. {
  18. gameObject.SetActive(false);
  19. }
  20. }
  21. private void InitViewer()
  22. {
  23. this.m_scrollBar = UTY.GetChildObject(this.m_goPanel, "MaidStatusViewer/BG/Scroll Bar", false).GetComponent<UIScrollBar>();
  24. UIButton component = UTY.GetChildObject(this.m_goPanel, "Ok", false).GetComponent<UIButton>();
  25. EventDelegate.Add(component.onClick, new EventDelegate.Callback(this.m_mgr.CloseResultWorkPanel));
  26. this.m_unitPrefabPath = "SceneDaily/ResultWork/Prefab/MaidStatusUnit";
  27. this.m_goUnitParent = UTY.GetChildObject(this.m_goPanel, "MaidStatusViewer/BG/Contents/SelectedMaidUnitParent", false);
  28. this.m_resultWorkIconPrefab = Resources.Load<GameObject>("SceneDaily/ResultWork/Prefab/ResultWorkIcon");
  29. this.m_hasActiveColor = false;
  30. this.PlaySe(this.m_mgr.GetAudioClipName(ScheduleData.WorkSuccessLv.Success));
  31. UILabel component2 = UTY.GetChildObject(this.m_goPanel, "MaidStatusViewer/Header/Frame_Time/Label", false).GetComponent<UILabel>();
  32. if (this.m_mgr.GetCurrentResultType() == ResultWorkMgr.ResultType.Daytime)
  33. {
  34. component2.text = "昼";
  35. }
  36. else if (this.m_mgr.GetCurrentResultType() == ResultWorkMgr.ResultType.Night)
  37. {
  38. component2.text = "夜";
  39. }
  40. }
  41. public void CreateMaidStatusViewer(Dictionary<string, ScheduleCtrl.MaidStatusAndTaskUnit> dicMaidStatusAndTaskInfo, Dictionary<string, ResultWorkCtrl.ResultWork> dicResultWork)
  42. {
  43. if (!this.m_bInit)
  44. {
  45. this.InitViewer();
  46. this.m_bInit = true;
  47. }
  48. this.m_dicMaidStatusAndTask = dicMaidStatusAndTaskInfo;
  49. this.m_dicResultWork = dicResultWork;
  50. base.CreateViewerWhenDataNotExist<string, ScheduleCtrl.MaidStatusAndTaskUnit>(dicMaidStatusAndTaskInfo);
  51. }
  52. protected override void SetDataForViewer()
  53. {
  54. for (int i = 0; i < 40; i++)
  55. {
  56. ScheduleCtrl.MaidStatusAndTaskUnit maidStatusAndTaskUnit = null;
  57. GameObject gameObject = UnityEngine.Object.Instantiate<GameObject>(this.m_goUnitPrefab);
  58. if (this.m_dicMaidStatusAndTask.TryGetValue(string.Format("slot_{0}", i), out maidStatusAndTaskUnit))
  59. {
  60. ScheduleCtrl.SetMaidStatus(UTY.GetChildObject(gameObject, "MaidStatus", false), maidStatusAndTaskUnit);
  61. }
  62. else
  63. {
  64. ScheduleCtrl.SetEmptyMaidStatusResult(gameObject);
  65. }
  66. gameObject.name = string.Format("slot_{0}", i);
  67. base.SetTransformInfo(gameObject);
  68. GameObject childObject = UTY.GetChildObject(gameObject, "MaidStatus", false);
  69. GameObject childObject2 = UTY.GetChildObject(childObject, "SelectCursor", false);
  70. childObject2.SetActive(false);
  71. childObject.GetComponent<UIDragDropMaidStatus>().enabled = false;
  72. UIButton component = childObject.GetComponent<UIButton>();
  73. BoxCollider component2 = childObject.GetComponent<BoxCollider>();
  74. component.enabled = false;
  75. component2.enabled = false;
  76. childObject.name = string.Format("slot_{0}_" + ScheduleCtrl.SlotColumn.MaidStatus, i);
  77. GameObject childObject3 = UTY.GetChildObject(gameObject, "Task", false);
  78. if (maidStatusAndTaskUnit != null)
  79. {
  80. UIButton component3 = childObject3.GetComponent<UIButton>();
  81. maidStatusAndTaskUnit.uiBtnDaytimeTask = component3;
  82. UITexture component4 = childObject3.GetComponent<UITexture>();
  83. component4.mainTexture = maidStatusAndTaskUnit.taskIcon;
  84. component3.enabled = false;
  85. childObject3.GetComponent<BoxCollider>().enabled = false;
  86. }
  87. GameObject childObject4 = UTY.GetChildObject(childObject3, "SelectCursor", false);
  88. childObject4.SetActive(false);
  89. GameObject childObject5 = UTY.GetChildObject(childObject3, "NamePlate", false);
  90. childObject5.SetActive(false);
  91. childObject3.name = string.Format("slot_{0}_" + ScheduleCtrl.SlotColumn.DaytimeTask, i);
  92. GameObject childObject6 = UTY.GetChildObject(gameObject, "Icon_MaidClassMax", false);
  93. childObject6.SetActive(false);
  94. GameObject childObject7 = UTY.GetChildObject(gameObject, "Icon_YotogiClassMax", false);
  95. childObject7.SetActive(false);
  96. if (maidStatusAndTaskUnit != null)
  97. {
  98. ResultWorkCtrl.ResultWork resultWork = null;
  99. if (this.m_dicResultWork.TryGetValue(maidStatusAndTaskUnit.slotNo.ToString(), out resultWork))
  100. {
  101. resultWork.goTask = childObject3;
  102. resultWork.goIconMaidClassMax = childObject6;
  103. resultWork.goIconYotogiClassMax = childObject7;
  104. bool flag = true;
  105. if (resultWork.taskType == ScheduleTaskCtrl.TaskType.Yotogi || resultWork.workId == ScheduleCSVData.faclilityPowerUpWorkId)
  106. {
  107. flag = false;
  108. }
  109. GameObject childObject8 = UTY.GetChildObject(gameObject, "CommuNoon", false);
  110. if (flag)
  111. {
  112. UIToggle component5 = childObject8.GetComponent<UIToggle>();
  113. component5.value = resultWork.commuFlag;
  114. }
  115. else
  116. {
  117. childObject8.SetActive(false);
  118. }
  119. GameObject childObject9 = UTY.GetChildObject(gameObject, "UpParam", false);
  120. ScheduleMaidStatusUnit component6 = childObject9.GetComponent<ScheduleMaidStatusUnit>();
  121. component6.Init(this.m_mgr, i);
  122. this.ViewUpParam(component6, resultWork);
  123. this.ResultIcon(resultWork);
  124. }
  125. if (!DailyMgr.IsLegacy && maidStatusAndTaskUnit.maidStatus != null && maidStatusAndTaskUnit.maidStatus.maid != null)
  126. {
  127. GameMain.Instance.CharacterMgr.status.CheckTrophyMaidStatus(maidStatusAndTaskUnit.maidStatus.maid);
  128. }
  129. }
  130. }
  131. }
  132. private void ViewUpParam(ScheduleMaidStatusUnit upParamUnit, ResultWorkCtrl.ResultWork resultWork)
  133. {
  134. if (resultWork.taskType == ScheduleTaskCtrl.TaskType.Training)
  135. {
  136. ScheduleCSVData.Training training = ScheduleCSVData.TrainingData[resultWork.workId];
  137. if (training.trainingType == ScheduleCSVData.TrainingType.Trainee)
  138. {
  139. upParamUnit.SetViewer(ScheduleMaidStatusUnit.DataType.Trainee);
  140. }
  141. else if (training.trainingType == ScheduleCSVData.TrainingType.Trainer)
  142. {
  143. upParamUnit.SetViewer(ScheduleMaidStatusUnit.DataType.Trainer);
  144. }
  145. else
  146. {
  147. upParamUnit.SetViewer(ScheduleMaidStatusUnit.DataType.Training);
  148. }
  149. }
  150. else if (resultWork.taskType == ScheduleTaskCtrl.TaskType.Yotogi)
  151. {
  152. upParamUnit.SetViewer(ScheduleMaidStatusUnit.DataType.Yotogi);
  153. }
  154. else if (resultWork.taskType == ScheduleTaskCtrl.TaskType.Work)
  155. {
  156. if (resultWork.workId == ScheduleCSVData.faclilityPowerUpWorkId)
  157. {
  158. upParamUnit.SetViewer(ScheduleMaidStatusUnit.DataType.Facility);
  159. }
  160. else
  161. {
  162. upParamUnit.SetViewer(ScheduleMaidStatusUnit.DataType.Work);
  163. }
  164. }
  165. }
  166. private void DisplayResultWorkIconBySlotNo(string slotNo)
  167. {
  168. ResultWorkCtrl.ResultWork resultWork = null;
  169. if (this.m_dicResultWork.TryGetValue(slotNo, out resultWork))
  170. {
  171. int num = 34;
  172. float value = Mathf.Clamp(float.Parse(slotNo) - 5f, 0f, (float)num) / (float)num;
  173. this.m_scrollBar.value = value;
  174. this.ResultIcon(resultWork);
  175. this.PlaySe(resultWork.audioClipName);
  176. }
  177. }
  178. private void ResultIcon(ResultWorkCtrl.ResultWork resultWork)
  179. {
  180. GameObject gameObject = UnityEngine.Object.Instantiate<GameObject>(this.m_resultWorkIconPrefab);
  181. gameObject.GetComponent<UITexture>().mainTexture = resultWork.resultTaskIcon;
  182. GameObject goTask = resultWork.goTask;
  183. base.SetTransformInfo(goTask, gameObject);
  184. }
  185. private void PlaySe(string audioClipName)
  186. {
  187. GameMain.Instance.SoundMgr.PlaySe(audioClipName, false);
  188. }
  189. public void SetActiveViewer(ResultWorkMgr.ResultType result)
  190. {
  191. foreach (KeyValuePair<ResultWorkMgr.ResultType, GameObject> keyValuePair in this.m_dicCanNotDispSimultaneouslyViewer)
  192. {
  193. if (result == keyValuePair.Key)
  194. {
  195. keyValuePair.Value.SetActive(true);
  196. }
  197. else
  198. {
  199. keyValuePair.Value.SetActive(false);
  200. }
  201. }
  202. }
  203. public string GetMaidIdByButtonName(string buttonName)
  204. {
  205. ScheduleCtrl.Slot slotByButtonName = ScheduleCtrl.GetSlotByButtonName(buttonName);
  206. ScheduleCtrl.MaidStatusAndTaskUnit maidStatusAndTaskUnit = null;
  207. if (this.m_dicMaidStatusAndTask.TryGetValue(slotByButtonName.slotNo, out maidStatusAndTaskUnit))
  208. {
  209. return maidStatusAndTaskUnit.maidStatus.id;
  210. }
  211. return string.Empty;
  212. }
  213. public void SetSelectedRowActive(string buttonName)
  214. {
  215. ScheduleCtrl.Slot slotByButtonName = ScheduleCtrl.GetSlotByButtonName(buttonName);
  216. this.SetSelectedRowActiveBySlotNo(slotByButtonName.slotNo);
  217. }
  218. public void SetSelectedRowActiveByMaidId(string maidId)
  219. {
  220. string slotNoByMaidId = this.GetSlotNoByMaidId(maidId);
  221. this.SetSelectedRowActiveBySlotNo(slotNoByMaidId);
  222. }
  223. public string GetSlotNoByMaidId(string maidId)
  224. {
  225. foreach (KeyValuePair<string, ScheduleCtrl.MaidStatusAndTaskUnit> keyValuePair in this.m_dicMaidStatusAndTask)
  226. {
  227. if (keyValuePair.Value.maidStatus.id == maidId)
  228. {
  229. return keyValuePair.Key;
  230. }
  231. }
  232. return null;
  233. }
  234. public void SetSelectedRowActiveBySlotNo(string slotNo)
  235. {
  236. foreach (KeyValuePair<string, ScheduleCtrl.MaidStatusAndTaskUnit> keyValuePair in this.m_dicMaidStatusAndTask)
  237. {
  238. string key = keyValuePair.Key;
  239. ScheduleCtrl.MaidStatusAndTaskUnit value = keyValuePair.Value;
  240. Color defaultColor;
  241. if (slotNo == key)
  242. {
  243. value.goSelectCursorMaidStatus.SetActive(true);
  244. defaultColor = this.activeColor;
  245. }
  246. else
  247. {
  248. value.goSelectCursorMaidStatus.SetActive(false);
  249. defaultColor = this.inActiveColor;
  250. }
  251. value.uiBtnMaidStatus.defaultColor = defaultColor;
  252. if (value.uiBtnDaytimeTask != null)
  253. {
  254. value.uiBtnDaytimeTask.defaultColor = defaultColor;
  255. }
  256. if (value.uiBtnNightTask != null)
  257. {
  258. value.uiBtnNightTask.defaultColor = defaultColor;
  259. }
  260. }
  261. }
  262. public void AdjustParameterViewer(GameObject itemParent, int displayItemCount, int heightOfTitle, UISprite targetBG)
  263. {
  264. float num = 15f;
  265. float num2 = 25f;
  266. float num3 = 0f;
  267. if (displayItemCount > 0)
  268. {
  269. num3 += (float)heightOfTitle + num;
  270. float y = itemParent.GetComponent<UITable>().padding.y;
  271. IEnumerator enumerator = itemParent.transform.GetEnumerator();
  272. try
  273. {
  274. while (enumerator.MoveNext())
  275. {
  276. object obj = enumerator.Current;
  277. Transform transform = (Transform)obj;
  278. if (transform.gameObject.activeSelf)
  279. {
  280. UILabel component = transform.GetComponent<UILabel>();
  281. num3 += (float)component.height + y * 2f;
  282. }
  283. }
  284. }
  285. finally
  286. {
  287. IDisposable disposable;
  288. if ((disposable = (enumerator as IDisposable)) != null)
  289. {
  290. disposable.Dispose();
  291. }
  292. }
  293. num3 += num2;
  294. targetBG.height = (int)num3;
  295. }
  296. }
  297. public void StartAnimation(Action onFinished = null)
  298. {
  299. List<Task> list = new List<Task>();
  300. Action<string> action = new Action<string>(this.m_mgr.ClickMaidStatusByButtonName);
  301. Action<string> action2 = new Action<string>(this.DisplayResultWorkIconBySlotNo);
  302. IOrderedEnumerable<KeyValuePair<string, ScheduleCtrl.MaidStatusAndTaskUnit>> orderedEnumerable = from pair in this.m_dicMaidStatusAndTask
  303. orderby pair.Value.slotNo
  304. select pair;
  305. foreach (KeyValuePair<string, ScheduleCtrl.MaidStatusAndTaskUnit> keyValuePair in orderedEnumerable)
  306. {
  307. Task<string> item = new Task<string>(action, string.Format(keyValuePair.Key + "_" + ScheduleCtrl.SlotColumn.MaidStatus, new object[0]));
  308. Task<string> item2 = new Task<string>(action2, keyValuePair.Value.slotNo.ToString());
  309. SyncTask<string> item3 = new SyncTask<string>(new List<Task<string>>
  310. {
  311. item,
  312. item2
  313. });
  314. list.Add(item3);
  315. }
  316. Task<string> item4;
  317. if (!string.IsNullOrEmpty(this.m_mgr.SlotNoToAcquiredCommuBonus))
  318. {
  319. item4 = new Task<string>(new Action<string>(this.m_mgr.ClickMaidStatusByButtonName), "slot_" + this.m_mgr.SlotNoToAcquiredCommuBonus + "_MaidStatus");
  320. }
  321. else
  322. {
  323. string param = string.Format(this.m_dicMaidStatusAndTask.First<KeyValuePair<string, ScheduleCtrl.MaidStatusAndTaskUnit>>().Key + "_" + ScheduleCtrl.SlotColumn.MaidStatus, new object[0]);
  324. item4 = new Task<string>(action, param);
  325. }
  326. list.Add(item4);
  327. this.GetTaskManager().listTask = list;
  328. this.m_taskMgr.StartTask(onFinished);
  329. }
  330. public void SetAllMaidStatusButtonEnable(bool enabled)
  331. {
  332. foreach (KeyValuePair<string, ScheduleCtrl.MaidStatusAndTaskUnit> keyValuePair in this.m_dicMaidStatusAndTask)
  333. {
  334. keyValuePair.Value.colliderMaidStatus.enabled = enabled;
  335. keyValuePair.Value.uiBtnMaidStatus.enabled = enabled;
  336. }
  337. }
  338. public ResultWorkCtrl.ResultWork GetResultWorkBySlotNo(int slotNo)
  339. {
  340. ResultWorkCtrl.ResultWork result = null;
  341. if (!this.m_dicResultWork.TryGetValue(slotNo.ToString(), out result))
  342. {
  343. Debug.LogError(string.Format("不適切なスロットNoが選択されました。選択されたスロットNo={0}", slotNo));
  344. return null;
  345. }
  346. return result;
  347. }
  348. private TaskMgr GetTaskManager()
  349. {
  350. if (this.m_taskMgr == null)
  351. {
  352. GameObject f_goParent = GameObject.Find("/UI Root");
  353. GameObject childObject = UTY.GetChildObject(f_goParent, "Manager/TaskMgr", false);
  354. this.m_taskMgr = childObject.GetComponent<TaskMgr>();
  355. return this.m_taskMgr;
  356. }
  357. return this.m_taskMgr;
  358. }
  359. public void StopCoroutineIfRunning()
  360. {
  361. if (this.m_taskMgr != null)
  362. {
  363. this.m_taskMgr.Stop();
  364. }
  365. }
  366. public void OnFinished()
  367. {
  368. }
  369. public const string NOTHING = "0";
  370. private const int CONTENS_DISPLAYMAX = 6;
  371. private ResultWorkMgr m_mgr;
  372. private TaskMgr m_taskMgr;
  373. private GameObject m_goPanel;
  374. private GameObject m_resultWorkIconPrefab;
  375. private UIScrollBar m_scrollBar;
  376. private Dictionary<ResultWorkMgr.ResultType, GameObject> m_dicCanNotDispSimultaneouslyViewer;
  377. private Dictionary<string, ScheduleCtrl.MaidStatusAndTaskUnit> m_dicMaidStatusAndTask;
  378. private Dictionary<string, ResultWorkCtrl.ResultWork> m_dicResultWork;
  379. private Color activeColor;
  380. private Color inActiveColor;
  381. private bool m_hasActiveColor;
  382. private bool m_bInit;
  383. private const string UNIT_PARENT_PATH = "MaidStatusViewer/BG/Contents/SelectedMaidUnitParent";
  384. private const string UNIT_PREFAB_PATH = "SceneDaily/ResultWork/Prefab/MaidStatusUnit";
  385. private const string RESULT_WORK_ICON_PREFAB = "SceneDaily/ResultWork/Prefab/ResultWorkIcon";
  386. [SerializeField]
  387. private List<GameObject> disableObjectList = new List<GameObject>();
  388. public class ResultWork
  389. {
  390. public ScheduleTaskCtrl.TaskType taskType;
  391. public ScheduleData.WorkSuccessLv successLv = ScheduleData.WorkSuccessLv.Success;
  392. public int workId;
  393. public int slotNo;
  394. public bool hasResult;
  395. public string audioClipName;
  396. public bool commuFlag;
  397. public ResultWorkCtrl.UpperMaidStatus upperMaidStatus;
  398. public Texture2D resultTaskIcon;
  399. public GameObject goTask;
  400. public GameObject goIconMaidClassMax;
  401. public GameObject goIconYotogiClassMax;
  402. public ScheduleMaidStatusUnit upParamUnit;
  403. }
  404. public class UpperMaidStatus
  405. {
  406. public string maidId;
  407. public int studyRate;
  408. public int likability;
  409. public int reception;
  410. public int care;
  411. public int lovely;
  412. public int elegance;
  413. public int charm;
  414. public int teach;
  415. public int maidClassLevel;
  416. public int maidClassExp;
  417. public int cooking;
  418. public int vocal;
  419. public int dance;
  420. public int appealPoint;
  421. public bool maidLvCompletion;
  422. public bool givenCommuBonus;
  423. public bool givenPerfectSucces;
  424. public Texture2D bonusIcon;
  425. public Texture2D perfectSuccessIcon;
  426. public int inyoku;
  427. public int m_value;
  428. public int hentai;
  429. public int housi;
  430. public int evaluation;
  431. public long income;
  432. public int yotogiClassLevel;
  433. public int yotogiClassExp;
  434. public int yotogiPlayCount;
  435. public int othersPlayCount;
  436. public bool yotogiLvCompletion;
  437. public long workingFunds;
  438. }
  439. public class ResultStatus
  440. {
  441. public int slotNo;
  442. public ResultWorkCtrl.UpperMaidStatus maidStatus;
  443. }
  444. }