123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313 |
- using System;
- using MaidStatus;
- using TextureBank;
- using UnityEngine;
- namespace Schedule
- {
- public class ScheduleScene
- {
- public ScheduleScene()
- {
- this.textureBank = new TextureBank();
- this.slot = new Slot[40];
- for (int i = 0; i < this.slot.Length; i++)
- {
- this.slot[i] = new Slot(this, i);
- }
- }
- public void SetSlot_Safe(int slotId, Maid maid, bool slotUpdate = true, bool updateAll = true)
- {
- if (slotId < 0)
- {
- Debug.LogWarning("ScheduleScene.SetSlot_Safe:スロットIDに0未満を指定することはできません。");
- return;
- }
- if (slotId >= 40)
- {
- Debug.LogWarning("ScheduleScene.SetSlot_Safe:スロットIDにkScheduleSlotMax以上の値を指定することはできません。");
- return;
- }
- if (maid != null && slotUpdate)
- {
- if (this.slot[slotId].maid == maid)
- {
- Debug.LogWarning("ScheduleScene.SetSlot_Safe:そのスロットIDには既に指定したメイドがセットされています。");
- return;
- }
- for (int i = 0; i < 40; i++)
- {
- if (i != slotId)
- {
- if (this.slot[i].maid == maid)
- {
- this.SetSlot_Safe(i, this.slot[slotId].maid, false, true);
- break;
- }
- }
- }
- }
- this.slot[slotId].maid = maid;
- if (slotUpdate)
- {
- ScheduleAPI.MaidWorkIdErrorCheck(true);
- if (updateAll)
- {
- this.Update();
- }
- else
- {
- this.Update(slotId);
- }
- }
- if (!DailyMgr.IsLegacy)
- {
- GameMain.Instance.FacilityMgr.UpdateFacilityAssignedMaidData();
- }
- }
- public void SetNoonWorkSlot_Safe(ScheduleMgr.ScheduleTime workTime, int slotId, int workId)
- {
- if (slotId < 0)
- {
- Debug.LogWarning("ScheduleScene.SetNoonWorkSlot_Safe:スロットIDに0未満を指定することはできません。");
- return;
- }
- if (slotId >= 40)
- {
- Debug.LogWarning("ScheduleScene.SetNoonWorkSlot_Safe:スロットIDにkScheduleSlotMax以上の値を指定することはできません。");
- return;
- }
- if (this.slot[slotId].maid == null)
- {
- Debug.LogWarning("ScheduleScene.SetNoonWorkSlot_Safe:そのスロットIDにメイドは設定されていません。");
- return;
- }
- if (workId == 0)
- {
- Debug.LogWarning("ScheduleScene.SetNoonWorkSlot_Safe:noonWorkIdに0が指定されましたが、空にはできないので傾向選択します。");
- ScheduleAPI.NoonWorkRandom(this.slot[slotId].maid);
- }
- if (ScheduleCSVData.TrainingData.ContainsKey(workId))
- {
- ScheduleCSVData.TrainingType trainingType = ScheduleCSVData.TrainingData[workId].trainingType;
- if (trainingType != ScheduleCSVData.TrainingType.Trainee)
- {
- if (trainingType != ScheduleCSVData.TrainingType.Travel)
- {
- if (workTime == ScheduleMgr.ScheduleTime.DayTime)
- {
- this.slot[slotId].maid.status.noonWorkId = workId;
- }
- else if (workTime == ScheduleMgr.ScheduleTime.Night)
- {
- this.slot[slotId].maid.status.nightWorkId = workId;
- }
- }
- else
- {
- this.slot[slotId].maid.status.noonWorkId = workId;
- this.RepeatedNoonWorkDel(this.slot[slotId].maid);
- int nightEntertainWorkId = ScheduleAPI.GetNightEntertainWorkId();
- int nightRestWorkId = ScheduleAPI.GetNightRestWorkId();
- for (int i = 0; i < 40; i++)
- {
- if (this.slot[i].maid != null && ScheduleCSVData.AllData.ContainsKey(this.slot[i].nightWorkId) && !ScheduleAPI.CheckNoProblemTravel(this.slot[i].nightWorkId))
- {
- if (this.slot[i].maid.status.contract == Contract.Trainee)
- {
- this.slot[i].maid.status.nightWorkId = nightRestWorkId;
- }
- else
- {
- this.slot[i].maid.status.nightWorkId = nightEntertainWorkId;
- }
- }
- }
- Debug.Log("ScheduleScene.SetNoonWorkSlot_Safe:旅行がセットされたので夜のスロットも変更します。");
- this.slot[slotId].maid.status.nightWorkId = ScheduleAPI.GetNightTravelWorkId();
- this.RepeatedNightWorkDel(this.slot[slotId].maid);
- }
- }
- else
- {
- this.slot[slotId].maid.status.noonWorkId = workId;
- this.RepeatedNoonWorkDel(this.slot[slotId].maid);
- Debug.Log("ScheduleScene.SetNoonWorkSlot_Safe:メイド研修(研修生)がセットされたので夜のスロットも変更します。");
- this.slot[slotId].maid.status.nightWorkId = ScheduleAPI.GetNightTraineeWorkId();
- this.RepeatedNightWorkDel(this.slot[slotId].maid);
- Debug.Log("ScheduleScene.SetNoonWorkSlot_Safe:メイド研修(研修生)がセットされたのでメイド長のスロットを変更します。");
- for (int j = 0; j < 40; j++)
- {
- if (this.slot[j].maid != null && this.slot[j].maid.status.leader)
- {
- this.slot[j].maid.status.noonWorkId = ScheduleAPI.GetNoonTrainerWorkId();
- this.RepeatedNoonWorkDel(this.slot[j].maid);
- this.slot[j].maid.status.nightWorkId = ScheduleAPI.GetNightTrainerWorkId();
- this.RepeatedNightWorkDel(this.slot[j].maid);
- break;
- }
- }
- }
- }
- else if (workTime == ScheduleMgr.ScheduleTime.DayTime)
- {
- this.slot[slotId].maid.status.noonWorkId = workId;
- }
- else if (workTime == ScheduleMgr.ScheduleTime.Night)
- {
- this.slot[slotId].maid.status.nightWorkId = workId;
- }
- }
- public void SetCommuSlot_Safe(ScheduleMgr.ScheduleTime workTime, int slotId, bool value)
- {
- if (workTime == ScheduleMgr.ScheduleTime.DayTime)
- {
- this.slot[slotId].maid.status.noonCommu = value;
- }
- else if (workTime == ScheduleMgr.ScheduleTime.Night)
- {
- this.slot[slotId].maid.status.nightCommu = value;
- }
- }
- public void SetNightWorkSlot_Safe(ScheduleMgr.ScheduleTime workTime, int slotId, int workId)
- {
- if (slotId < 0)
- {
- Debug.LogWarning("ScheduleScene.SetNightnWorkSlot_Safe:スロットIDに0未満を指定することはできません。");
- return;
- }
- if (slotId >= 40)
- {
- Debug.LogWarning("ScheduleScene.SetNightnWorkSlot_Safe:スロットIDにkScheduleSlotMax以上の値を指定することはできません。");
- return;
- }
- if (this.slot[slotId].maid == null)
- {
- Debug.LogWarning("ScheduleScene.SetNightnWorkSlot_Safe:そのスロットIDにメイドは設定されていません。");
- return;
- }
- if (workId == 0)
- {
- Debug.LogWarning("ScheduleScene.SetNightnWorkSlot_Safe:nightWorkIdに0が指定されましたが、空にはできないので傾向選択します。");
- ScheduleAPI.NightWorkRandom(this.slot[slotId].maid);
- }
- ScheduleCSVData.ScheduleBase scheduleBase = ScheduleCSVData.AllData[workId];
- ScheduleCSVData.Yotogi yotogi = (ScheduleCSVData.Yotogi)scheduleBase;
- if (workTime == ScheduleMgr.ScheduleTime.DayTime)
- {
- this.slot[slotId].maid.status.noonWorkId = workId;
- }
- else if (workTime == ScheduleMgr.ScheduleTime.Night)
- {
- this.slot[slotId].maid.status.nightWorkId = workId;
- }
- ScheduleCSVData.YotogiType yotogiType = yotogi.yotogiType;
- if (yotogiType == ScheduleCSVData.YotogiType.Vip || yotogiType == ScheduleCSVData.YotogiType.VipCall)
- {
- this.RepeatedWorkDel(workTime, this.slot[slotId].maid, workId);
- }
- }
- private void SetNoonWorkId(Maid maid, int setId)
- {
- maid.status.SetFlag("Schedule.ScheduleScene.NoonWorkId", setId);
- }
- private void SetNightWorkId(Maid maid, int setId)
- {
- maid.status.SetFlag("Schedule.ScheduleScene.NightWorkId", setId);
- }
- private void RepeatedWorkDel(ScheduleMgr.ScheduleTime workTime, Maid baseMaid, int workId)
- {
- int stockMaidCount = GameMain.Instance.CharacterMgr.GetStockMaidCount();
- for (int i = 0; i < stockMaidCount; i++)
- {
- Maid stockMaid = GameMain.Instance.CharacterMgr.GetStockMaid(i);
- if (stockMaid == baseMaid)
- {
- if (workTime == ScheduleMgr.ScheduleTime.DayTime)
- {
- if (stockMaid.status.nightWorkId == workId)
- {
- stockMaid.status.nightWorkId = 0;
- }
- }
- else if (workTime == ScheduleMgr.ScheduleTime.Night && stockMaid.status.noonWorkId == workId)
- {
- stockMaid.status.noonWorkId = 0;
- }
- }
- else if (stockMaid.status.noonWorkId == workId)
- {
- stockMaid.status.noonWorkId = 0;
- }
- else if (stockMaid.status.nightWorkId == workId)
- {
- stockMaid.status.nightWorkId = 0;
- }
- }
- }
- private void RepeatedNoonWorkDel(Maid baseMaid)
- {
- int stockMaidCount = GameMain.Instance.CharacterMgr.GetStockMaidCount();
- for (int i = 0; i < stockMaidCount; i++)
- {
- Maid stockMaid = GameMain.Instance.CharacterMgr.GetStockMaid(i);
- if (!(stockMaid == baseMaid))
- {
- if (stockMaid.status.noonWorkId == baseMaid.status.noonWorkId)
- {
- stockMaid.status.noonWorkId = 0;
- }
- }
- }
- }
- private void RepeatedNightWorkDel(Maid baseMaid)
- {
- int stockMaidCount = GameMain.Instance.CharacterMgr.GetStockMaidCount();
- for (int i = 0; i < stockMaidCount; i++)
- {
- Maid stockMaid = GameMain.Instance.CharacterMgr.GetStockMaid(i);
- if (!(stockMaid == baseMaid))
- {
- if (stockMaid.status.nightWorkId == baseMaid.status.nightWorkId)
- {
- stockMaid.status.nightWorkId = 0;
- }
- }
- }
- }
- public void Update()
- {
- for (int i = 0; i < this.slot.Length; i++)
- {
- this.slot[i].Update();
- }
- }
- public void Update(int index)
- {
- this.slot[index].Update();
- }
- public void Dispace()
- {
- if (this.textureBank != null)
- {
- this.textureBank.Dispace();
- }
- }
- public Slot[] slot;
- public TextureBank textureBank;
- }
- }
|