ResultWorkCtrl.cs 16 KB

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