using System; using System.Collections.Generic; using MaidExtension; using UnityEngine; public class UndressingManager : MonoBehaviour { public void Awake() { for (int i = 0; i < this.UnitDataList.Count; i++) { UndressingManager.UnitData unitData = this.UnitDataList[i]; NDebug.Assert(unitData.ButtonObject != null, "button object null error."); UndressingManager.UndressingData undressingData = new UndressingManager.UndressingData(); undressingData.unit_type = unitData.UnitType; undressingData.button_object = unitData.ButtonObject; undressingData.button_default_color = unitData.ButtonObject.defaultColor; EventDelegate eventDelegate = new EventDelegate(this, "OnClickButton"); eventDelegate.parameters[0].value = undressingData; undressingData.button_object.onClick.Add(eventDelegate); this.unit_dic_.Add(unitData.UnitType, undressingData); } using (AFileBase afileBase = GameUty.FileSystem.FileOpen("yotogi_play_undressing.nei")) { using (CsvParser csvParser = new CsvParser()) { bool condition = csvParser.Open(afileBase); NDebug.Assert(condition, "file open error[yotogi_play_undressing.nei]"); for (int j = 1; j < csvParser.max_cell_y; j++) { if (csvParser.IsCellToExistData(0, j)) { int num = 0; string cellAsString = csvParser.GetCellAsString(num++, j); string cellAsString2 = csvParser.GetCellAsString(num++, j); UndressingManager.UnitType key = UndressingManager.UnitType.全着衣; try { key = (UndressingManager.UnitType)Enum.Parse(typeof(UndressingManager.UnitType), cellAsString2); } catch (ArgumentException) { NDebug.Assert("enum parse error.\n[" + cellAsString2 + "] Convert to UnitData.Type Failed.", false); } if (this.unit_dic_.ContainsKey(key)) { UndressingManager.UndressingData undressingData2 = this.unit_dic_[key]; string cellAsString3 = csvParser.GetCellAsString(num++, j); if (!string.IsNullOrEmpty(cellAsString3)) { string[] array = cellAsString3.Split(new char[] { ',' }); for (int k = 0; k < array.Length; k++) { TBody.SlotID item = TBody.SlotID.wear; try { item = (TBody.SlotID)Enum.Parse(typeof(TBody.SlotID), array[k]); } catch { NDebug.Assert("TBody.SlotID enum parse error.\n" + array[k], false); } undressingData2.target_sloat_id_list.Add(item); } } undressingData2.call_scenario = csvParser.GetCellAsString(num++, j); cellAsString3 = csvParser.GetCellAsString(num++, j); if (!string.IsNullOrEmpty(cellAsString3)) { string[] array2 = cellAsString3.Split(new char[] { ',' }); for (int l = 0; l < array2.Length; l++) { MPN mpn = MPN.null_mpn; try { mpn = (MPN)Enum.Parse(typeof(MPN), array2[l]); } catch { NDebug.Assert("mpn enum parse error.\n" + array2[l], false); } if (mpn != MPN.null_mpn) { undressingData2.target_newbody_mpn_id_list.Add(mpn); } } } } } } } } if (this.hannugiButton != null) { EventDelegate.Add(this.hannugiButton.onClick, delegate() { if (this.all_maid_data_ == null || this.all_maid_data_.Length <= 0) { return; } bool flag = false; foreach (Maid maid in this.all_maid_data_) { if (!(maid == null) && maid.IsCrcBody && maid.mekureController.IsSupportedCostumeType(MaidCostumeChangeController.CostumeType.Hadake)) { flag = maid.mekureController.IsEnabledCostumeType(MaidCostumeChangeController.CostumeType.Hadake); break; } } foreach (Maid maid2 in this.all_maid_data_) { if (!(maid2 == null)) { maid2.mekureController.SetEnabledCostumeType(MaidCostumeChangeController.CostumeType.Hadake, !flag, null); } } this.UpdateHannugiButton(); }); } } public void UpdateHannugiButton() { if (this.hannugiButton == null) { return; } foreach (Maid maid in this.all_maid_data_) { if (!(maid == null) && maid.IsCrcBody && maid.mekureController.IsSupportedCostumeType(MaidCostumeChangeController.CostumeType.Hadake)) { this.hannugiButton.isEnabled = maid.mekureController.IsSupportedCostumeType(MaidCostumeChangeController.CostumeType.Hadake); if (this.hannugiButton.isEnabled) { bool flag = maid.mekureController.IsEnabledCostumeType(MaidCostumeChangeController.CostumeType.Hadake); Color defaultColor = this.hannugiButton.defaultColor; defaultColor.a = ((!flag) ? 0.5f : 1f); this.hannugiButton.defaultColor = defaultColor; break; } } } } public void SetCallBackEvent(UndressingManager.OnClickEventDelegate func) { this.onclick_event_ = func; } public void SetMaid(Maid maid, Maid[] linked_maid_array) { this.maid_ = maid; UIGrid component = base.GetComponent(); if (this.maid_.IsCrcBody) { component.cellWidth = 92f; if (this.hannugiButton != null) { this.hannugiButton.gameObject.SetActive(true); } } else { component.cellWidth = 100f; if (this.hannugiButton != null) { this.hannugiButton.gameObject.SetActive(false); } } Behaviour behaviour = component; bool flag = true; component.repositionNow = flag; behaviour.enabled = flag; foreach (KeyValuePair keyValuePair in this.unit_dic_) { UndressingManager.UndressingData value = keyValuePair.Value; value.UpdateMaskStatus(maid); } if (linked_maid_array == null || linked_maid_array.Length == 0) { this.all_maid_data_ = new Maid[1]; this.all_maid_data_[0] = this.maid_; } else { List list = new List(); foreach (Maid maid2 in linked_maid_array) { if (!(maid2 == this.maid_)) { list.Add(maid2); } } list.Insert(0, this.maid_); this.all_maid_data_ = list.ToArray(); } this.UpdateHannugiButton(); this.ApplyAllMaid(); } public void SetMaskMode(UndressingManager.UnitType type, UndressingManager.MaskStatus status) { if (!this.unit_dic_.ContainsKey(type)) { return; } UndressingManager.UndressingData undressingData = this.unit_dic_[type]; if (undressingData.unit_type != UndressingManager.UnitType.全脱衣) { this.unit_dic_[UndressingManager.UnitType.全脱衣].mask_mode = UndressingManager.MaskStatus.Off; } if (undressingData.unit_type != UndressingManager.UnitType.全着衣) { this.unit_dic_[UndressingManager.UnitType.全着衣].mask_mode = UndressingManager.MaskStatus.Off; } undressingData.mask_mode = status; this.ApplyAllMaid(); if (this.onclick_event_ != null) { this.onclick_event_(undressingData.call_scenario); } } public UndressingManager.UndressingData GetUndressingData(UndressingManager.UnitType unitType) { return (!this.unit_dic_.ContainsKey(unitType)) ? null : this.unit_dic_[unitType]; } public void OnClickButton(UndressingManager.UndressingData unit_data) { UndressingManager.MaskStatus status = (unit_data.mask_mode != UndressingManager.MaskStatus.On) ? UndressingManager.MaskStatus.On : UndressingManager.MaskStatus.Off; this.SetMaskMode(unit_data.unit_type, status); } private void ApplyAllMaid() { if (this.unit_dic_[UndressingManager.UnitType.全脱衣].mask_mode == UndressingManager.MaskStatus.On) { for (int i = 0; i < this.all_maid_data_.Length; i++) { this.all_maid_data_[i].body0.SetMaskMode(TBody.MaskMode.Nude); } foreach (KeyValuePair keyValuePair in this.unit_dic_) { UndressingManager.UndressingData value = keyValuePair.Value; if (value.unit_type != UndressingManager.UnitType.全脱衣 && value.unit_type != UndressingManager.UnitType.全着衣) { value.mask_mode = UndressingManager.MaskStatus.On; } } return; } if (this.unit_dic_[UndressingManager.UnitType.全着衣].mask_mode == UndressingManager.MaskStatus.On) { for (int j = 0; j < this.all_maid_data_.Length; j++) { this.all_maid_data_[j].body0.SetMaskMode(TBody.MaskMode.None); } foreach (KeyValuePair keyValuePair2 in this.unit_dic_) { UndressingManager.UndressingData value2 = keyValuePair2.Value; if (value2.unit_type != UndressingManager.UnitType.全脱衣 && value2.unit_type != UndressingManager.UnitType.全着衣) { value2.mask_mode = UndressingManager.MaskStatus.Off; } } return; } foreach (KeyValuePair keyValuePair3 in this.unit_dic_) { UndressingManager.UndressingData value3 = keyValuePair3.Value; for (int k = 0; k < this.all_maid_data_.Length; k++) { value3.ApplyMask(this.all_maid_data_[k]); } value3.UpdateMaskStatus(this.maid_); } } [SerializeField] public List UnitDataList = new List(); [SerializeField] private UIButton hannugiButton; private Dictionary unit_dic_ = new Dictionary(); private Maid maid_; private Maid[] all_maid_data_; private UndressingManager.OnClickEventDelegate onclick_event_; public enum UnitType { 全脱衣, 全着衣, トップス, ボトムス, ブラジャ\u30FC, パンツ, ソックス, シュ\u30FCズ, ヘッドドレス, メガネ, 背中, 手袋, Max } public enum MaskStatus { On, Off } [Serializable] public class UnitData { public UndressingManager.UnitType UnitType; public UIButton ButtonObject; } public delegate void OnClickEventDelegate(string call_file); public class UndressingData { public UndressingManager.MaskStatus mask_mode { get { return this.button_mask_status_; } set { if (this.button_mask_status_ == value) { return; } this.button_mask_status_ = value; if (this.unit_type == UndressingManager.UnitType.全着衣 || this.unit_type == UndressingManager.UnitType.全脱衣) { return; } if (this.button_mask_status_ == UndressingManager.MaskStatus.Off) { this.button_object.defaultColor = this.button_default_color; } else { Color defaultColor = this.button_default_color; defaultColor.a = 0.5f; this.button_object.defaultColor = defaultColor; } } } public void UpdateMaskStatus(Maid maid) { if (maid == null || maid.body0 == null || this.unit_type == UndressingManager.UnitType.全着衣 || this.unit_type == UndressingManager.UnitType.全脱衣) { return; } if (this.target_newbody_mpn_id_list[0] == MPN.acchead) { bool mask = maid.body0.GetMask(MPN.acchead); bool mask2 = maid.body0.GetMask(MPN.wear); } bool flag = false; if (maid.body0.IsCrcBody) { for (int i = 0; i < this.target_newbody_mpn_id_list.Count; i++) { if (maid.body0.GetSlotLoaded(this.target_newbody_mpn_id_list[i])) { flag = true; break; } } } else { for (int j = 0; j < this.target_sloat_id_list.Count; j++) { if (maid.body0.GetSlotLoaded(this.target_sloat_id_list[j])) { flag = true; break; } } } if (!flag) { this.button_object.defaultColor = this.button_object.disabledColor; this.button_object.isEnabled = false; return; } bool flag2 = true; if (maid.body0.IsCrcBody) { for (int k = 0; k < this.target_newbody_mpn_id_list.Count; k++) { if (maid.body0.GetMask(this.target_newbody_mpn_id_list[k])) { flag2 = false; break; } } } else { for (int l = 0; l < this.target_sloat_id_list.Count; l++) { if (maid.body0.GetMask(this.target_sloat_id_list[l])) { flag2 = false; break; } } } this.mask_mode = ((!flag2) ? UndressingManager.MaskStatus.Off : UndressingManager.MaskStatus.On); } public void ApplyMask(Maid[] maid_array) { if (maid_array == null) { return; } for (int i = 0; i < maid_array.Length; i++) { this.ApplyMask(maid_array[i]); } } public void ApplyMask(Maid maid) { if (maid == null || maid.body0 == null || !this.button_object.isEnabled || this.unit_type == UndressingManager.UnitType.全着衣 || this.unit_type == UndressingManager.UnitType.全脱衣) { return; } bool flag = this.mask_mode == UndressingManager.MaskStatus.On; if (maid.body0.IsCrcBody) { for (int i = 0; i < this.target_newbody_mpn_id_list.Count; i++) { maid.body0.SetMask(this.target_newbody_mpn_id_list[i], !flag); } } else { for (int j = 0; j < this.target_sloat_id_list.Count; j++) { maid.body0.SetMask(this.target_sloat_id_list[j], !flag); } } } public UndressingManager.UnitType unit_type; public List target_sloat_id_list = new List(); public List target_newbody_mpn_id_list = new List(); public string call_scenario = string.Empty; public Color button_default_color; public UIButton button_object; private UndressingManager.MaskStatus button_mask_status_ = UndressingManager.MaskStatus.Off; } }