ResultWorkMgr.cs 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449
  1. using System;
  2. using System.Collections.Generic;
  3. using BackupParamAccessor;
  4. using PlayerStatus;
  5. using Schedule;
  6. using UnityEngine;
  7. public class ResultWorkMgr : BaseCreatePanel
  8. {
  9. public ResultWorkMgr.ResultType GetCurrentResultType()
  10. {
  11. return this.currentResultType;
  12. }
  13. public WorkResultScene GetWorkResultSceneApi()
  14. {
  15. return this.m_workResultSceneApi;
  16. }
  17. public string SlotNoToAcquiredCommuBonus
  18. {
  19. get
  20. {
  21. return this.m_SlotNoToAcquiredCommuBonus;
  22. }
  23. }
  24. public ResultWorkCtrl Ctrl
  25. {
  26. get
  27. {
  28. return this.m_ctrl;
  29. }
  30. }
  31. public void SetCurrentActiveButton(string buttonName)
  32. {
  33. this.currentActiveButton = buttonName;
  34. }
  35. public override void Init()
  36. {
  37. this.m_goPanel = base.GetPanel("ResultWorkPanel");
  38. this.m_ctrl = base.GetCtrl<ResultWorkCtrl>();
  39. this.m_ctrl.Init(this, this.m_goPanel);
  40. this.m_api = new ResultWorkAPI();
  41. this.m_descTraining = UTY.GetChildObject(this.m_goPanel, "ResultViewer/DescResultTraining", false).GetComponent<DescResultTraining>();
  42. this.m_descTraining.Init(this, this.m_ctrl, this.m_goPanel);
  43. this.m_descYotogi = UTY.GetChildObject(this.m_goPanel, "ResultViewer/DescResultYotogi", false).GetComponent<DescResultYotogi>();
  44. this.m_descYotogi.Init(this, this.m_ctrl, this.m_goPanel);
  45. this.m_descWork = UTY.GetChildObject(this.m_goPanel, "ResultViewer/DescResultWork", false).GetComponent<DescResultWork>();
  46. this.m_descWork.Init(this, this.m_ctrl, this.m_goPanel);
  47. }
  48. public void OpenResultDaytimePanel()
  49. {
  50. Debug.Log("昼仕事リザルトをオープンしました。");
  51. this.m_api.SceneStart(true, this, new ResultWorkAPI.dgOnSceneStartCallBack(this.OpenResultDaytimeCallBack));
  52. }
  53. public void OpenResultDaytimeCallBack()
  54. {
  55. base.BaseOpenPanel(ResultWorkMgr.ResultType.Daytime.ToString());
  56. }
  57. public void OpenResultNightPanel()
  58. {
  59. Debug.Log("夜仕事リザルトをオープンしました。");
  60. this.m_api.SceneStart(false, this, new ResultWorkAPI.dgOnSceneStartCallBack(this.OpenResultNightCallBack));
  61. }
  62. public void OpenResultNightCallBack()
  63. {
  64. base.BaseOpenPanel(ResultWorkMgr.ResultType.Night.ToString());
  65. }
  66. protected override void OpenPanel(string openType)
  67. {
  68. ResultWorkMgr.ResultType resultType = (ResultWorkMgr.ResultType)Enum.Parse(typeof(ResultWorkMgr.ResultType), openType);
  69. this.currentResultType = resultType;
  70. Dictionary<string, ScheduleCtrl.MaidStatusAndTaskUnit> dictionary = this.LoadMaidStatusData();
  71. if (!this.m_ctrl.HasDicData<string, ScheduleCtrl.MaidStatusAndTaskUnit>(dictionary))
  72. {
  73. Debug.LogWarning("スケジュールにメイドが設定されていないため、表示する仕事の結果がありません。");
  74. return;
  75. }
  76. this.currentActiveButton = string.Empty;
  77. Dictionary<string, ResultWorkCtrl.ResultWork> dictionary2 = this.LoadResultData(this.currentResultType);
  78. this.m_ctrl.CreateMaidStatusViewer(dictionary, dictionary2);
  79. this.SetDescResultWorkDic(dictionary2);
  80. this.ExecuteDaytimeRelatedAPI();
  81. this.ExecuteNightRelatedAPI();
  82. }
  83. private void OnFinished()
  84. {
  85. this.m_ctrl.OnFinished();
  86. this.ActiveDescAnimation(false);
  87. }
  88. private void ActiveDescAnimation(bool acitve)
  89. {
  90. this.m_descTraining.m_playedAnimation = acitve;
  91. this.m_descYotogi.m_playedAnimation = acitve;
  92. this.m_descWork.m_playedAnimation = acitve;
  93. }
  94. private void SetDescResultWorkDic(Dictionary<string, ResultWorkCtrl.ResultWork> dicResultWork)
  95. {
  96. this.m_descTraining.SetResultWorkDic(dicResultWork);
  97. this.m_descYotogi.SetResultWorkDic(dicResultWork);
  98. this.m_descWork.SetResultWorkDic(dicResultWork);
  99. }
  100. private void ExecuteDaytimeRelatedAPI()
  101. {
  102. GameMain.Instance.CharacterMgr.status.CheckTrophyDayResultAndNightResult();
  103. }
  104. private void ExecuteNightRelatedAPI()
  105. {
  106. GameMain.Instance.CharacterMgr.status.CheckTrophyDayResultAndNightResult();
  107. }
  108. public void CloseResultWorkPanel()
  109. {
  110. base.BaseClosePanel();
  111. }
  112. protected override void ClosePanel()
  113. {
  114. this.AfterTreatment();
  115. }
  116. private void AfterTreatment()
  117. {
  118. this.currentActiveButton = string.Empty;
  119. this.currentResultType = ResultWorkMgr.ResultType.None;
  120. this.m_ctrl.StopCoroutineIfRunning();
  121. }
  122. public void ClickMaidStatus()
  123. {
  124. string name = UIButton.current.name;
  125. this.ClickMaidStatusByButtonName(name);
  126. }
  127. public void ClickMaidStatusByButtonName(string buttonName)
  128. {
  129. }
  130. public Dictionary<string, ScheduleCtrl.MaidStatusAndTaskUnit> LoadMaidStatusData()
  131. {
  132. this.m_workResultSceneApi = this.GetWorkResultSceneApi(this.currentResultType);
  133. Dictionary<string, ScheduleCtrl.MaidStatusAndTaskUnit> dictionary = new Dictionary<string, ScheduleCtrl.MaidStatusAndTaskUnit>();
  134. if (this.m_workResultSceneApi.slot == null || this.m_workResultSceneApi.slot.Length <= 0)
  135. {
  136. return dictionary;
  137. }
  138. foreach (WorkResultSlot workResultSlot in this.m_workResultSceneApi.slot)
  139. {
  140. ScheduleCtrl.MaidStatusAndTaskUnit maidStatusAndTaskUnit = new ScheduleCtrl.MaidStatusAndTaskUnit();
  141. if (!(workResultSlot.maid == null))
  142. {
  143. maidStatusAndTaskUnit.slotNo = workResultSlot.slotId;
  144. if (this.currentResultType == ResultWorkMgr.ResultType.Daytime)
  145. {
  146. maidStatusAndTaskUnit.daytimeTaskId = workResultSlot.noonWorkId.ToString();
  147. maidStatusAndTaskUnit.taskIcon = workResultSlot.noon_icon;
  148. }
  149. else if (this.currentResultType == ResultWorkMgr.ResultType.Night)
  150. {
  151. maidStatusAndTaskUnit.daytimeTaskId = workResultSlot.nightWorkId.ToString();
  152. maidStatusAndTaskUnit.taskIcon = workResultSlot.night_icon;
  153. }
  154. maidStatusAndTaskUnit.maidStatus = new MaidStatusListCtrl.MaidStatusButton
  155. {
  156. maid = workResultSlot.maid,
  157. id = workResultSlot.maid.status.guid,
  158. isReader = workResultSlot.leader,
  159. maidIcon = workResultSlot.icon,
  160. firstName = workResultSlot.first_name,
  161. lastName = workResultSlot.last_name,
  162. Rranking = workResultSlot.popular_rank,
  163. crownIcon = workResultSlot.popular_rank_icon,
  164. contractTypeName = workResultSlot.contract_type_name,
  165. contractTypeNameTerm = workResultSlot.contract_type_name_term,
  166. personalName = workResultSlot.personal_name,
  167. personalNameTerm = workResultSlot.personal_name_term
  168. };
  169. dictionary.Add(string.Format("slot_{0}", maidStatusAndTaskUnit.slotNo), maidStatusAndTaskUnit);
  170. }
  171. }
  172. return dictionary;
  173. }
  174. private WorkResultScene GetWorkResultSceneApi(ResultWorkMgr.ResultType currentResultType)
  175. {
  176. if (this.m_workResultSceneApi == null)
  177. {
  178. this.m_workResultSceneApi = new WorkResultScene();
  179. }
  180. if (currentResultType != ResultWorkMgr.ResultType.Daytime)
  181. {
  182. if (currentResultType == ResultWorkMgr.ResultType.Night)
  183. {
  184. this.InitDayTimeAPI();
  185. this.InitNightAPI();
  186. }
  187. }
  188. else
  189. {
  190. this.InitDayTimeAPI();
  191. }
  192. return this.m_workResultSceneApi;
  193. }
  194. private void InitDayTimeAPI()
  195. {
  196. if (!this.m_initResultDaytime)
  197. {
  198. this.m_workResultSceneApi.Calc(WorkResultSceneMode.Noon, true);
  199. this.m_initResultDaytime = true;
  200. }
  201. }
  202. private void InitNightAPI()
  203. {
  204. if (!this.m_initResultNight)
  205. {
  206. this.m_workResultSceneApi.Calc(WorkResultSceneMode.Night, true);
  207. this.m_initResultNight = true;
  208. }
  209. }
  210. private Dictionary<string, ResultWorkCtrl.ResultWork> LoadResultData(ResultWorkMgr.ResultType resultType)
  211. {
  212. Dictionary<string, ResultWorkCtrl.ResultWork> dictionary = new Dictionary<string, ResultWorkCtrl.ResultWork>();
  213. this.m_SlotNoToAcquiredCommuBonus = string.Empty;
  214. if (this.m_workResultSceneApi.slot == null || this.m_workResultSceneApi.slot.Length <= 0)
  215. {
  216. return dictionary;
  217. }
  218. foreach (WorkResultSlot workResultSlot in this.m_workResultSceneApi.slot)
  219. {
  220. if (!(workResultSlot.maid == null))
  221. {
  222. ResultWorkCtrl.ResultWork resultWork = new ResultWorkCtrl.ResultWork();
  223. resultWork.slotNo = workResultSlot.slotId;
  224. ResultBaseTask resultBaseTask;
  225. if (resultType == ResultWorkMgr.ResultType.Daytime)
  226. {
  227. resultWork.resultTaskIcon = workResultSlot.noonWorksData.successLv_icon;
  228. resultBaseTask = workResultSlot.noonWorksData;
  229. resultWork.workId = workResultSlot.noonWorkId;
  230. }
  231. else
  232. {
  233. resultWork.resultTaskIcon = workResultSlot.nightWorksData.successLv_icon;
  234. resultBaseTask = workResultSlot.nightWorksData;
  235. resultWork.workId = workResultSlot.nightWorkId;
  236. }
  237. if (resultBaseTask == null)
  238. {
  239. Debug.Log(string.Format("スロットNo={0}に仕事の結果が設定されておりません。", workResultSlot.slotId));
  240. resultWork.hasResult = false;
  241. dictionary.Add(resultWork.slotNo.ToString(), resultWork);
  242. }
  243. else
  244. {
  245. ScheduleTaskCtrl.TaskType type = ScheduleCSVData.AllData[resultBaseTask.id].type;
  246. resultWork.taskType = type;
  247. resultWork.successLv = resultBaseTask.commonSuccessLv;
  248. if (type != ScheduleTaskCtrl.TaskType.Training)
  249. {
  250. if (type != ScheduleTaskCtrl.TaskType.Yotogi)
  251. {
  252. if (type == ScheduleTaskCtrl.TaskType.Work)
  253. {
  254. this.TrainingResultData(resultType, ref resultWork, resultBaseTask, workResultSlot);
  255. }
  256. }
  257. else
  258. {
  259. this.YotogiResultData(ref resultWork, resultBaseTask, workResultSlot);
  260. }
  261. }
  262. else
  263. {
  264. this.TrainingResultData(resultType, ref resultWork, resultBaseTask, workResultSlot);
  265. }
  266. dictionary.Add(resultWork.slotNo.ToString(), resultWork);
  267. }
  268. }
  269. }
  270. return dictionary;
  271. }
  272. private ResultWorkCtrl.ResultWork TrainingResultData(ResultWorkMgr.ResultType type, ref ResultWorkCtrl.ResultWork rw, ResultBaseTask workData, WorkResultSlot slotInfo)
  273. {
  274. rw.hasResult = true;
  275. ResultTrainingTask resultTrainingTask = (ResultTrainingTask)workData;
  276. rw.audioClipName = this.GetAudioClipName(resultTrainingTask.successLv);
  277. ResultWorkCtrl.UpperMaidStatus upperMaidStatus = new ResultWorkCtrl.UpperMaidStatus();
  278. upperMaidStatus.maidId = slotInfo.maid.status.guid;
  279. upperMaidStatus.maidLvCompletion = resultTrainingTask.maidLvCompletion;
  280. if (resultTrainingTask.successLv == ScheduleData.WorkSuccessLv.Perfect)
  281. {
  282. upperMaidStatus.perfectSuccessIcon = resultTrainingTask.bonus_icon;
  283. upperMaidStatus.givenPerfectSucces = true;
  284. }
  285. upperMaidStatus.givenCommuBonus = resultTrainingTask.communicationBonus;
  286. if (upperMaidStatus.givenCommuBonus)
  287. {
  288. this.SetUpperMaidStatus(ref upperMaidStatus, resultTrainingTask.uppedParams);
  289. upperMaidStatus.bonusIcon = resultTrainingTask.bonus_icon;
  290. this.m_SlotNoToAcquiredCommuBonus = rw.slotNo.ToString();
  291. }
  292. else
  293. {
  294. this.SetUpperMaidStatus(ref upperMaidStatus, resultTrainingTask.uppedParamsWithoutCommunicationBonus);
  295. }
  296. rw.commuFlag = upperMaidStatus.givenCommuBonus;
  297. rw.upperMaidStatus = upperMaidStatus;
  298. return rw;
  299. }
  300. private ResultWorkCtrl.ResultWork YotogiResultData(ref ResultWorkCtrl.ResultWork rw, ResultBaseTask workData, WorkResultSlot slotInfo)
  301. {
  302. rw.hasResult = true;
  303. ResultYotogiTask resultYotogiTask = (ResultYotogiTask)workData;
  304. rw.audioClipName = this.GetAudioClipName(resultYotogiTask.successLv);
  305. ResultWorkCtrl.UpperMaidStatus upperMaidStatus = new ResultWorkCtrl.UpperMaidStatus();
  306. this.SetUpperMaidStatus(ref upperMaidStatus, resultYotogiTask.uppedParams);
  307. upperMaidStatus.yotogiLvCompletion = resultYotogiTask.yotogiLvCompletion;
  308. rw.upperMaidStatus = upperMaidStatus;
  309. return rw;
  310. }
  311. private void SetUpperMaidStatus(ref ResultWorkCtrl.UpperMaidStatus upperMaidStatus, Params param)
  312. {
  313. upperMaidStatus.studyRate = StatusCtrl.ToPercent(param.study_rate, 10);
  314. upperMaidStatus.likability = param.likability;
  315. upperMaidStatus.reception = param.reception;
  316. upperMaidStatus.care = param.care;
  317. upperMaidStatus.lovely = param.lovely;
  318. upperMaidStatus.elegance = param.elegance;
  319. upperMaidStatus.charm = param.charm;
  320. upperMaidStatus.cooking = param.cooking;
  321. upperMaidStatus.vocal = param.vocal;
  322. upperMaidStatus.dance = param.dance;
  323. upperMaidStatus.appealPoint = param.appealPoint;
  324. upperMaidStatus.teach = StatusCtrl.ToPercent(param.teach_rate, 10);
  325. upperMaidStatus.maidClassLevel = param.maidClassLv;
  326. upperMaidStatus.maidClassExp = param.maidClassExp;
  327. upperMaidStatus.inyoku = param.inyoku;
  328. upperMaidStatus.hentai = param.hentai;
  329. upperMaidStatus.housi = param.housi;
  330. upperMaidStatus.m_value = param.m_value;
  331. upperMaidStatus.evaluation = param.evaluation;
  332. upperMaidStatus.income = param.sales;
  333. upperMaidStatus.yotogiClassExp = param.yotogiClassExp;
  334. upperMaidStatus.yotogiClassLevel = param.yotogiClassLv;
  335. upperMaidStatus.yotogiPlayCount = param.yotogi_play_count;
  336. upperMaidStatus.othersPlayCount = param.others_play_count;
  337. upperMaidStatus.workingFunds = param.sales;
  338. }
  339. public string GetAudioClipName(ScheduleData.WorkSuccessLv workSuccessLv)
  340. {
  341. string result = string.Empty;
  342. switch (workSuccessLv)
  343. {
  344. case ScheduleData.WorkSuccessLv.Miss:
  345. case ScheduleData.WorkSuccessLv.Unexecuted:
  346. result = "SE021.ogg";
  347. break;
  348. case ScheduleData.WorkSuccessLv.Success:
  349. result = "SE002.ogg";
  350. break;
  351. case ScheduleData.WorkSuccessLv.Perfect:
  352. result = "SE008.ogg";
  353. break;
  354. }
  355. return result;
  356. }
  357. protected override void AfterClose()
  358. {
  359. if (this.sceneMgr != null)
  360. {
  361. this.m_api.EndNextScene(new ResultWorkAPI.dgOnSceneFinalCallBack(this.sceneMgr.CloseScene));
  362. }
  363. }
  364. public void OnDestroy()
  365. {
  366. if (this.m_workResultSceneApi != null)
  367. {
  368. this.m_workResultSceneApi.Dispace();
  369. }
  370. }
  371. protected override void SetFadeTargetPanel()
  372. {
  373. this.fadeTargetPanel = this.m_goPanel;
  374. }
  375. private WorkResultScene m_workResultSceneApi;
  376. private ResultWorkMgr.ResultType currentResultType;
  377. private ResultWorkCtrl m_ctrl;
  378. private ResultWorkAPI m_api;
  379. private DescResultTraining m_descTraining;
  380. private DescResultYotogi m_descYotogi;
  381. private DescResultWork m_descWork;
  382. private string m_SlotNoToAcquiredCommuBonus;
  383. private string currentActiveButton;
  384. private bool m_initResultDaytime;
  385. private bool m_initResultNight;
  386. private const string SE_PERFECT = "SE008.ogg";
  387. private const string SE_SUCCESS = "SE002.ogg";
  388. private const string SE_MISS = "SE021.ogg";
  389. private const string uiRootPath = "/UI Root";
  390. private const string BUTTON_NAME_TEMPLATE = "slot_{0}";
  391. private const int DENOMINATOR_10 = 10;
  392. public enum ResultType
  393. {
  394. None,
  395. Daytime,
  396. Night
  397. }
  398. }