ScheduleScene.cs 9.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313
  1. using System;
  2. using MaidStatus;
  3. using TextureBank;
  4. using UnityEngine;
  5. namespace Schedule
  6. {
  7. public class ScheduleScene
  8. {
  9. public ScheduleScene()
  10. {
  11. this.textureBank = new TextureBank();
  12. this.slot = new Slot[40];
  13. for (int i = 0; i < this.slot.Length; i++)
  14. {
  15. this.slot[i] = new Slot(this, i);
  16. }
  17. }
  18. public void SetSlot_Safe(int slotId, Maid maid, bool slotUpdate = true, bool updateAll = true)
  19. {
  20. if (slotId < 0)
  21. {
  22. Debug.LogWarning("ScheduleScene.SetSlot_Safe:スロットIDに0未満を指定することはできません。");
  23. return;
  24. }
  25. if (slotId >= 40)
  26. {
  27. Debug.LogWarning("ScheduleScene.SetSlot_Safe:スロットIDにkScheduleSlotMax以上の値を指定することはできません。");
  28. return;
  29. }
  30. if (maid != null && slotUpdate)
  31. {
  32. if (this.slot[slotId].maid == maid)
  33. {
  34. Debug.LogWarning("ScheduleScene.SetSlot_Safe:そのスロットIDには既に指定したメイドがセットされています。");
  35. return;
  36. }
  37. for (int i = 0; i < 40; i++)
  38. {
  39. if (i != slotId)
  40. {
  41. if (this.slot[i].maid == maid)
  42. {
  43. this.SetSlot_Safe(i, this.slot[slotId].maid, false, true);
  44. break;
  45. }
  46. }
  47. }
  48. }
  49. this.slot[slotId].maid = maid;
  50. if (slotUpdate)
  51. {
  52. ScheduleAPI.MaidWorkIdErrorCheck(true);
  53. if (updateAll)
  54. {
  55. this.Update();
  56. }
  57. else
  58. {
  59. this.Update(slotId);
  60. }
  61. }
  62. if (!DailyMgr.IsLegacy)
  63. {
  64. GameMain.Instance.FacilityMgr.UpdateFacilityAssignedMaidData();
  65. }
  66. }
  67. public void SetNoonWorkSlot_Safe(ScheduleMgr.ScheduleTime workTime, int slotId, int workId)
  68. {
  69. if (slotId < 0)
  70. {
  71. Debug.LogWarning("ScheduleScene.SetNoonWorkSlot_Safe:スロットIDに0未満を指定することはできません。");
  72. return;
  73. }
  74. if (slotId >= 40)
  75. {
  76. Debug.LogWarning("ScheduleScene.SetNoonWorkSlot_Safe:スロットIDにkScheduleSlotMax以上の値を指定することはできません。");
  77. return;
  78. }
  79. if (this.slot[slotId].maid == null)
  80. {
  81. Debug.LogWarning("ScheduleScene.SetNoonWorkSlot_Safe:そのスロットIDにメイドは設定されていません。");
  82. return;
  83. }
  84. if (workId == 0)
  85. {
  86. Debug.LogWarning("ScheduleScene.SetNoonWorkSlot_Safe:noonWorkIdに0が指定されましたが、空にはできないので傾向選択します。");
  87. ScheduleAPI.NoonWorkRandom(this.slot[slotId].maid);
  88. }
  89. if (ScheduleCSVData.TrainingData.ContainsKey(workId))
  90. {
  91. ScheduleCSVData.TrainingType trainingType = ScheduleCSVData.TrainingData[workId].trainingType;
  92. if (trainingType != ScheduleCSVData.TrainingType.Trainee)
  93. {
  94. if (trainingType != ScheduleCSVData.TrainingType.Travel)
  95. {
  96. if (workTime == ScheduleMgr.ScheduleTime.DayTime)
  97. {
  98. this.slot[slotId].maid.status.noonWorkId = workId;
  99. }
  100. else if (workTime == ScheduleMgr.ScheduleTime.Night)
  101. {
  102. this.slot[slotId].maid.status.nightWorkId = workId;
  103. }
  104. }
  105. else
  106. {
  107. this.slot[slotId].maid.status.noonWorkId = workId;
  108. this.RepeatedNoonWorkDel(this.slot[slotId].maid);
  109. int nightEntertainWorkId = ScheduleAPI.GetNightEntertainWorkId();
  110. int nightRestWorkId = ScheduleAPI.GetNightRestWorkId();
  111. for (int i = 0; i < 40; i++)
  112. {
  113. if (this.slot[i].maid != null && ScheduleCSVData.AllData.ContainsKey(this.slot[i].nightWorkId) && !ScheduleAPI.CheckNoProblemTravel(this.slot[i].nightWorkId))
  114. {
  115. if (this.slot[i].maid.status.contract == Contract.Trainee)
  116. {
  117. this.slot[i].maid.status.nightWorkId = nightRestWorkId;
  118. }
  119. else
  120. {
  121. this.slot[i].maid.status.nightWorkId = nightEntertainWorkId;
  122. }
  123. }
  124. }
  125. Debug.Log("ScheduleScene.SetNoonWorkSlot_Safe:旅行がセットされたので夜のスロットも変更します。");
  126. this.slot[slotId].maid.status.nightWorkId = ScheduleAPI.GetNightTravelWorkId();
  127. this.RepeatedNightWorkDel(this.slot[slotId].maid);
  128. }
  129. }
  130. else
  131. {
  132. this.slot[slotId].maid.status.noonWorkId = workId;
  133. this.RepeatedNoonWorkDel(this.slot[slotId].maid);
  134. Debug.Log("ScheduleScene.SetNoonWorkSlot_Safe:メイド研修(研修生)がセットされたので夜のスロットも変更します。");
  135. this.slot[slotId].maid.status.nightWorkId = ScheduleAPI.GetNightTraineeWorkId();
  136. this.RepeatedNightWorkDel(this.slot[slotId].maid);
  137. Debug.Log("ScheduleScene.SetNoonWorkSlot_Safe:メイド研修(研修生)がセットされたのでメイド長のスロットを変更します。");
  138. for (int j = 0; j < 40; j++)
  139. {
  140. if (this.slot[j].maid != null && this.slot[j].maid.status.leader)
  141. {
  142. this.slot[j].maid.status.noonWorkId = ScheduleAPI.GetNoonTrainerWorkId();
  143. this.RepeatedNoonWorkDel(this.slot[j].maid);
  144. this.slot[j].maid.status.nightWorkId = ScheduleAPI.GetNightTrainerWorkId();
  145. this.RepeatedNightWorkDel(this.slot[j].maid);
  146. break;
  147. }
  148. }
  149. }
  150. }
  151. else if (workTime == ScheduleMgr.ScheduleTime.DayTime)
  152. {
  153. this.slot[slotId].maid.status.noonWorkId = workId;
  154. }
  155. else if (workTime == ScheduleMgr.ScheduleTime.Night)
  156. {
  157. this.slot[slotId].maid.status.nightWorkId = workId;
  158. }
  159. }
  160. public void SetCommuSlot_Safe(ScheduleMgr.ScheduleTime workTime, int slotId, bool value)
  161. {
  162. if (workTime == ScheduleMgr.ScheduleTime.DayTime)
  163. {
  164. this.slot[slotId].maid.status.noonCommu = value;
  165. }
  166. else if (workTime == ScheduleMgr.ScheduleTime.Night)
  167. {
  168. this.slot[slotId].maid.status.nightCommu = value;
  169. }
  170. }
  171. public void SetNightWorkSlot_Safe(ScheduleMgr.ScheduleTime workTime, int slotId, int workId)
  172. {
  173. if (slotId < 0)
  174. {
  175. Debug.LogWarning("ScheduleScene.SetNightnWorkSlot_Safe:スロットIDに0未満を指定することはできません。");
  176. return;
  177. }
  178. if (slotId >= 40)
  179. {
  180. Debug.LogWarning("ScheduleScene.SetNightnWorkSlot_Safe:スロットIDにkScheduleSlotMax以上の値を指定することはできません。");
  181. return;
  182. }
  183. if (this.slot[slotId].maid == null)
  184. {
  185. Debug.LogWarning("ScheduleScene.SetNightnWorkSlot_Safe:そのスロットIDにメイドは設定されていません。");
  186. return;
  187. }
  188. if (workId == 0)
  189. {
  190. Debug.LogWarning("ScheduleScene.SetNightnWorkSlot_Safe:nightWorkIdに0が指定されましたが、空にはできないので傾向選択します。");
  191. ScheduleAPI.NightWorkRandom(this.slot[slotId].maid);
  192. }
  193. ScheduleCSVData.ScheduleBase scheduleBase = ScheduleCSVData.AllData[workId];
  194. ScheduleCSVData.Yotogi yotogi = (ScheduleCSVData.Yotogi)scheduleBase;
  195. if (workTime == ScheduleMgr.ScheduleTime.DayTime)
  196. {
  197. this.slot[slotId].maid.status.noonWorkId = workId;
  198. }
  199. else if (workTime == ScheduleMgr.ScheduleTime.Night)
  200. {
  201. this.slot[slotId].maid.status.nightWorkId = workId;
  202. }
  203. ScheduleCSVData.YotogiType yotogiType = yotogi.yotogiType;
  204. if (yotogiType == ScheduleCSVData.YotogiType.Vip || yotogiType == ScheduleCSVData.YotogiType.VipCall)
  205. {
  206. this.RepeatedWorkDel(workTime, this.slot[slotId].maid, workId);
  207. }
  208. }
  209. private void SetNoonWorkId(Maid maid, int setId)
  210. {
  211. maid.status.SetFlag("Schedule.ScheduleScene.NoonWorkId", setId);
  212. }
  213. private void SetNightWorkId(Maid maid, int setId)
  214. {
  215. maid.status.SetFlag("Schedule.ScheduleScene.NightWorkId", setId);
  216. }
  217. private void RepeatedWorkDel(ScheduleMgr.ScheduleTime workTime, Maid baseMaid, int workId)
  218. {
  219. int stockMaidCount = GameMain.Instance.CharacterMgr.GetStockMaidCount();
  220. for (int i = 0; i < stockMaidCount; i++)
  221. {
  222. Maid stockMaid = GameMain.Instance.CharacterMgr.GetStockMaid(i);
  223. if (stockMaid == baseMaid)
  224. {
  225. if (workTime == ScheduleMgr.ScheduleTime.DayTime)
  226. {
  227. if (stockMaid.status.nightWorkId == workId)
  228. {
  229. stockMaid.status.nightWorkId = 0;
  230. }
  231. }
  232. else if (workTime == ScheduleMgr.ScheduleTime.Night && stockMaid.status.noonWorkId == workId)
  233. {
  234. stockMaid.status.noonWorkId = 0;
  235. }
  236. }
  237. else if (stockMaid.status.noonWorkId == workId)
  238. {
  239. stockMaid.status.noonWorkId = 0;
  240. }
  241. else if (stockMaid.status.nightWorkId == workId)
  242. {
  243. stockMaid.status.nightWorkId = 0;
  244. }
  245. }
  246. }
  247. private void RepeatedNoonWorkDel(Maid baseMaid)
  248. {
  249. int stockMaidCount = GameMain.Instance.CharacterMgr.GetStockMaidCount();
  250. for (int i = 0; i < stockMaidCount; i++)
  251. {
  252. Maid stockMaid = GameMain.Instance.CharacterMgr.GetStockMaid(i);
  253. if (!(stockMaid == baseMaid))
  254. {
  255. if (stockMaid.status.noonWorkId == baseMaid.status.noonWorkId)
  256. {
  257. stockMaid.status.noonWorkId = 0;
  258. }
  259. }
  260. }
  261. }
  262. private void RepeatedNightWorkDel(Maid baseMaid)
  263. {
  264. int stockMaidCount = GameMain.Instance.CharacterMgr.GetStockMaidCount();
  265. for (int i = 0; i < stockMaidCount; i++)
  266. {
  267. Maid stockMaid = GameMain.Instance.CharacterMgr.GetStockMaid(i);
  268. if (!(stockMaid == baseMaid))
  269. {
  270. if (stockMaid.status.nightWorkId == baseMaid.status.nightWorkId)
  271. {
  272. stockMaid.status.nightWorkId = 0;
  273. }
  274. }
  275. }
  276. }
  277. public void Update()
  278. {
  279. for (int i = 0; i < this.slot.Length; i++)
  280. {
  281. this.slot[i].Update();
  282. }
  283. }
  284. public void Update(int index)
  285. {
  286. this.slot[index].Update();
  287. }
  288. public void Dispace()
  289. {
  290. if (this.textureBank != null)
  291. {
  292. this.textureBank.Dispace();
  293. }
  294. }
  295. public Slot[] slot;
  296. public TextureBank textureBank;
  297. }
  298. }