ResultWorkMgr.cs 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446
  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. };
  166. dictionary.Add(string.Format("slot_{0}", maidStatusAndTaskUnit.slotNo), maidStatusAndTaskUnit);
  167. }
  168. }
  169. return dictionary;
  170. }
  171. private WorkResultScene GetWorkResultSceneApi(ResultWorkMgr.ResultType currentResultType)
  172. {
  173. if (this.m_workResultSceneApi == null)
  174. {
  175. this.m_workResultSceneApi = new WorkResultScene();
  176. }
  177. if (currentResultType != ResultWorkMgr.ResultType.Daytime)
  178. {
  179. if (currentResultType == ResultWorkMgr.ResultType.Night)
  180. {
  181. this.InitDayTimeAPI();
  182. this.InitNightAPI();
  183. }
  184. }
  185. else
  186. {
  187. this.InitDayTimeAPI();
  188. }
  189. return this.m_workResultSceneApi;
  190. }
  191. private void InitDayTimeAPI()
  192. {
  193. if (!this.m_initResultDaytime)
  194. {
  195. this.m_workResultSceneApi.Calc(WorkResultSceneMode.Noon, true);
  196. this.m_initResultDaytime = true;
  197. }
  198. }
  199. private void InitNightAPI()
  200. {
  201. if (!this.m_initResultNight)
  202. {
  203. this.m_workResultSceneApi.Calc(WorkResultSceneMode.Night, true);
  204. this.m_initResultNight = true;
  205. }
  206. }
  207. private Dictionary<string, ResultWorkCtrl.ResultWork> LoadResultData(ResultWorkMgr.ResultType resultType)
  208. {
  209. Dictionary<string, ResultWorkCtrl.ResultWork> dictionary = new Dictionary<string, ResultWorkCtrl.ResultWork>();
  210. this.m_SlotNoToAcquiredCommuBonus = string.Empty;
  211. if (this.m_workResultSceneApi.slot == null || this.m_workResultSceneApi.slot.Length <= 0)
  212. {
  213. return dictionary;
  214. }
  215. foreach (WorkResultSlot workResultSlot in this.m_workResultSceneApi.slot)
  216. {
  217. if (!(workResultSlot.maid == null))
  218. {
  219. ResultWorkCtrl.ResultWork resultWork = new ResultWorkCtrl.ResultWork();
  220. resultWork.slotNo = workResultSlot.slotId;
  221. ResultBaseTask resultBaseTask;
  222. if (resultType == ResultWorkMgr.ResultType.Daytime)
  223. {
  224. resultWork.resultTaskIcon = workResultSlot.noonWorksData.successLv_icon;
  225. resultBaseTask = workResultSlot.noonWorksData;
  226. resultWork.workId = workResultSlot.noonWorkId;
  227. }
  228. else
  229. {
  230. resultWork.resultTaskIcon = workResultSlot.nightWorksData.successLv_icon;
  231. resultBaseTask = workResultSlot.nightWorksData;
  232. resultWork.workId = workResultSlot.nightWorkId;
  233. }
  234. if (resultBaseTask == null)
  235. {
  236. Debug.Log(string.Format("スロットNo={0}に仕事の結果が設定されておりません。", workResultSlot.slotId));
  237. resultWork.hasResult = false;
  238. dictionary.Add(resultWork.slotNo.ToString(), resultWork);
  239. }
  240. else
  241. {
  242. ScheduleTaskCtrl.TaskType type = ScheduleCSVData.AllData[resultBaseTask.id].type;
  243. resultWork.taskType = type;
  244. resultWork.successLv = resultBaseTask.commonSuccessLv;
  245. if (type != ScheduleTaskCtrl.TaskType.Training)
  246. {
  247. if (type != ScheduleTaskCtrl.TaskType.Yotogi)
  248. {
  249. if (type == ScheduleTaskCtrl.TaskType.Work)
  250. {
  251. this.TrainingResultData(resultType, ref resultWork, resultBaseTask, workResultSlot);
  252. }
  253. }
  254. else
  255. {
  256. this.YotogiResultData(ref resultWork, resultBaseTask, workResultSlot);
  257. }
  258. }
  259. else
  260. {
  261. this.TrainingResultData(resultType, ref resultWork, resultBaseTask, workResultSlot);
  262. }
  263. dictionary.Add(resultWork.slotNo.ToString(), resultWork);
  264. }
  265. }
  266. }
  267. return dictionary;
  268. }
  269. private ResultWorkCtrl.ResultWork TrainingResultData(ResultWorkMgr.ResultType type, ref ResultWorkCtrl.ResultWork rw, ResultBaseTask workData, WorkResultSlot slotInfo)
  270. {
  271. rw.hasResult = true;
  272. ResultTrainingTask resultTrainingTask = (ResultTrainingTask)workData;
  273. rw.audioClipName = this.GetAudioClipName(resultTrainingTask.successLv);
  274. ResultWorkCtrl.UpperMaidStatus upperMaidStatus = new ResultWorkCtrl.UpperMaidStatus();
  275. upperMaidStatus.maidId = slotInfo.maid.status.guid;
  276. upperMaidStatus.maidLvCompletion = resultTrainingTask.maidLvCompletion;
  277. if (resultTrainingTask.successLv == ScheduleData.WorkSuccessLv.Perfect)
  278. {
  279. upperMaidStatus.perfectSuccessIcon = resultTrainingTask.bonus_icon;
  280. upperMaidStatus.givenPerfectSucces = true;
  281. }
  282. upperMaidStatus.givenCommuBonus = resultTrainingTask.communicationBonus;
  283. if (upperMaidStatus.givenCommuBonus)
  284. {
  285. this.SetUpperMaidStatus(ref upperMaidStatus, resultTrainingTask.uppedParams);
  286. upperMaidStatus.bonusIcon = resultTrainingTask.bonus_icon;
  287. this.m_SlotNoToAcquiredCommuBonus = rw.slotNo.ToString();
  288. }
  289. else
  290. {
  291. this.SetUpperMaidStatus(ref upperMaidStatus, resultTrainingTask.uppedParamsWithoutCommunicationBonus);
  292. }
  293. rw.commuFlag = upperMaidStatus.givenCommuBonus;
  294. rw.upperMaidStatus = upperMaidStatus;
  295. return rw;
  296. }
  297. private ResultWorkCtrl.ResultWork YotogiResultData(ref ResultWorkCtrl.ResultWork rw, ResultBaseTask workData, WorkResultSlot slotInfo)
  298. {
  299. rw.hasResult = true;
  300. ResultYotogiTask resultYotogiTask = (ResultYotogiTask)workData;
  301. rw.audioClipName = this.GetAudioClipName(resultYotogiTask.successLv);
  302. ResultWorkCtrl.UpperMaidStatus upperMaidStatus = new ResultWorkCtrl.UpperMaidStatus();
  303. this.SetUpperMaidStatus(ref upperMaidStatus, resultYotogiTask.uppedParams);
  304. upperMaidStatus.yotogiLvCompletion = resultYotogiTask.yotogiLvCompletion;
  305. rw.upperMaidStatus = upperMaidStatus;
  306. return rw;
  307. }
  308. private void SetUpperMaidStatus(ref ResultWorkCtrl.UpperMaidStatus upperMaidStatus, Params param)
  309. {
  310. upperMaidStatus.studyRate = StatusCtrl.ToPercent(param.study_rate, 10);
  311. upperMaidStatus.likability = param.likability;
  312. upperMaidStatus.reception = param.reception;
  313. upperMaidStatus.care = param.care;
  314. upperMaidStatus.lovely = param.lovely;
  315. upperMaidStatus.elegance = param.elegance;
  316. upperMaidStatus.charm = param.charm;
  317. upperMaidStatus.cooking = param.cooking;
  318. upperMaidStatus.vocal = param.vocal;
  319. upperMaidStatus.dance = param.dance;
  320. upperMaidStatus.appealPoint = param.appealPoint;
  321. upperMaidStatus.teach = StatusCtrl.ToPercent(param.teach_rate, 10);
  322. upperMaidStatus.maidClassLevel = param.maidClassLv;
  323. upperMaidStatus.maidClassExp = param.maidClassExp;
  324. upperMaidStatus.inyoku = param.inyoku;
  325. upperMaidStatus.hentai = param.hentai;
  326. upperMaidStatus.housi = param.housi;
  327. upperMaidStatus.m_value = param.m_value;
  328. upperMaidStatus.evaluation = param.evaluation;
  329. upperMaidStatus.income = param.sales;
  330. upperMaidStatus.yotogiClassExp = param.yotogiClassExp;
  331. upperMaidStatus.yotogiClassLevel = param.yotogiClassLv;
  332. upperMaidStatus.yotogiPlayCount = param.yotogi_play_count;
  333. upperMaidStatus.othersPlayCount = param.others_play_count;
  334. upperMaidStatus.workingFunds = param.sales;
  335. }
  336. public string GetAudioClipName(ScheduleData.WorkSuccessLv workSuccessLv)
  337. {
  338. string result = string.Empty;
  339. switch (workSuccessLv)
  340. {
  341. case ScheduleData.WorkSuccessLv.Miss:
  342. case ScheduleData.WorkSuccessLv.Unexecuted:
  343. result = "SE021.ogg";
  344. break;
  345. case ScheduleData.WorkSuccessLv.Success:
  346. result = "SE002.ogg";
  347. break;
  348. case ScheduleData.WorkSuccessLv.Perfect:
  349. result = "SE008.ogg";
  350. break;
  351. }
  352. return result;
  353. }
  354. protected override void AfterClose()
  355. {
  356. if (this.sceneMgr != null)
  357. {
  358. this.m_api.EndNextScene(new ResultWorkAPI.dgOnSceneFinalCallBack(this.sceneMgr.CloseScene));
  359. }
  360. }
  361. public void OnDestroy()
  362. {
  363. if (this.m_workResultSceneApi != null)
  364. {
  365. this.m_workResultSceneApi.Dispace();
  366. }
  367. }
  368. protected override void SetFadeTargetPanel()
  369. {
  370. this.fadeTargetPanel = this.m_goPanel;
  371. }
  372. private WorkResultScene m_workResultSceneApi;
  373. private ResultWorkMgr.ResultType currentResultType;
  374. private ResultWorkCtrl m_ctrl;
  375. private ResultWorkAPI m_api;
  376. private DescResultTraining m_descTraining;
  377. private DescResultYotogi m_descYotogi;
  378. private DescResultWork m_descWork;
  379. private string m_SlotNoToAcquiredCommuBonus;
  380. private string currentActiveButton;
  381. private bool m_initResultDaytime;
  382. private bool m_initResultNight;
  383. private const string SE_PERFECT = "SE008.ogg";
  384. private const string SE_SUCCESS = "SE002.ogg";
  385. private const string SE_MISS = "SE021.ogg";
  386. private const string uiRootPath = "/UI Root";
  387. private const string BUTTON_NAME_TEMPLATE = "slot_{0}";
  388. private const int DENOMINATOR_10 = 10;
  389. public enum ResultType
  390. {
  391. None,
  392. Daytime,
  393. Night
  394. }
  395. }