using System; using System.Collections.Generic; using UnityEngine; public class PhotUndressingManager : MonoBehaviour { public void Awake() { if (0 < this.unit_slot_dic_.Count) { return; } using (AFileBase afileBase = GameUty.FileSystem.FileOpen("phot_undressing_list.nei")) { using (CsvParser csvParser = new CsvParser()) { bool condition = csvParser.Open(afileBase); NDebug.Assert(condition, "file open error[phot_undressing_list.nei]"); for (int i = 1; i < csvParser.max_cell_y; i++) { if (csvParser.IsCellToExistData(0, i)) { int num = 0; string cellAsString = csvParser.GetCellAsString(num++, i); string cellAsString2 = csvParser.GetCellAsString(num++, i); if (!string.IsNullOrEmpty(cellAsString2)) { string[] array = cellAsString2.Split(new char[] { ',' }); for (int j = 0; j < array.Length; j++) { TBody.SlotID item = TBody.SlotID.wear; try { item = (TBody.SlotID)Enum.Parse(typeof(TBody.SlotID), array[j]); } catch { NDebug.Assert("TBody.SlotID enum parse error.\n" + array[j], false); } if (!this.unit_slot_dic_.ContainsKey(cellAsString)) { this.unit_slot_dic_.Add(cellAsString, new List()); } this.unit_slot_dic_[cellAsString].Add(item); } } } } } } } public void SetUnitButtonList(Dictionary unit_dic) { this.Awake(); foreach (KeyValuePair keyValuePair in unit_dic) { PhotUndressingManager.UndressingData undressingData = new PhotUndressingManager.UndressingData(); undressingData.unit_type = keyValuePair.Key; undressingData.button_object = keyValuePair.Value; undressingData.button_default_color = undressingData.button_object.defaultColor; if (this.unit_slot_dic_.ContainsKey(undressingData.unit_type)) { undressingData.target_sloat_id_list = this.unit_slot_dic_[undressingData.unit_type]; } EventDelegate eventDelegate = new EventDelegate(this, "OnClickButton"); eventDelegate.parameters[0].value = undressingData; undressingData.button_object.onClick.Add(eventDelegate); this.unit_dic_.Add(undressingData.unit_type, undressingData); } } public void SetMaid(Maid maid) { this.maid_ = maid; foreach (KeyValuePair keyValuePair in this.unit_dic_) { PhotUndressingManager.UndressingData value = keyValuePair.Value; value.UpdateMaskStatus(maid); } int num = 1; if (this.maid_linked_array_ != null) { num += this.maid_linked_array_.Length; } this.all_maid_data_ = new Maid[num]; this.all_maid_data_[0] = this.maid_; if (this.maid_linked_array_ != null) { for (int i = 0; i < this.maid_linked_array_.Length; i++) { this.all_maid_data_[i + 1] = this.maid_linked_array_[i]; } } } public void SetMaskMode(string unit_type, PhotUndressingManager.MaskStatus status) { if (!this.unit_dic_.ContainsKey(unit_type)) { return; } PhotUndressingManager.UndressingData undressingData = this.unit_dic_[unit_type]; if (undressingData.unit_type != "全脱衣") { this.unit_dic_["全脱衣"].mask_mode = PhotUndressingManager.MaskStatus.Off; } if (undressingData.unit_type != "全着衣") { this.unit_dic_["全着衣"].mask_mode = PhotUndressingManager.MaskStatus.Off; } undressingData.mask_mode = status; this.ApplyAllMaid(); } private void OnClickButton(PhotUndressingManager.UndressingData unit_data) { PhotUndressingManager.MaskStatus status = (unit_data.mask_mode != PhotUndressingManager.MaskStatus.On) ? PhotUndressingManager.MaskStatus.On : PhotUndressingManager.MaskStatus.Off; this.SetMaskMode(unit_data.unit_type, status); if (this.onClickEvent != null) { this.onClickEvent(); } } private void ApplyAllMaid() { if (this.unit_dic_["全脱衣"].mask_mode == PhotUndressingManager.MaskStatus.On) { for (int i = 0; i < this.all_maid_data_.Length; i++) { foreach (KeyValuePair keyValuePair in this.unit_dic_) { if (!(keyValuePair.Key == "全脱衣") && !(keyValuePair.Key == "全着衣") && keyValuePair.Value.button_object.isEnabled) { this.SetMaskMode(keyValuePair.Key, PhotUndressingManager.MaskStatus.On); } } } return; } if (this.unit_dic_["全着衣"].mask_mode == PhotUndressingManager.MaskStatus.On) { for (int j = 0; j < this.all_maid_data_.Length; j++) { foreach (KeyValuePair keyValuePair2 in this.unit_dic_) { if (!(keyValuePair2.Key == "全脱衣") && !(keyValuePair2.Key == "全着衣") && keyValuePair2.Value.button_object.isEnabled) { this.SetMaskMode(keyValuePair2.Key, PhotUndressingManager.MaskStatus.Off); } } } return; } foreach (KeyValuePair keyValuePair3 in this.unit_dic_) { PhotUndressingManager.UndressingData value = keyValuePair3.Value; for (int k = 0; k < this.all_maid_data_.Length; k++) { value.ApplyMask(this.all_maid_data_[k]); } value.UpdateMaskStatus(this.maid_); } } public HashSet GetTargetSlotID() { HashSet hashSet = new HashSet(); foreach (KeyValuePair> keyValuePair in this.unit_slot_dic_) { List value = keyValuePair.Value; for (int i = 0; i < value.Count; i++) { if (!hashSet.Contains(value[i])) { hashSet.Add(value[i]); } } } return hashSet; } public Action onClickEvent; private Dictionary unit_dic_ = new Dictionary(); private Dictionary> unit_slot_dic_ = new Dictionary>(); private Maid maid_; private Maid[] maid_linked_array_; private Maid[] all_maid_data_; public enum MaskStatus { On, Off } private class UndressingData { public PhotUndressingManager.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 == "全着衣" || this.unit_type == "全脱衣") { return; } if (this.button_mask_status_ == PhotUndressingManager.MaskStatus.Off) { this.button_object.defaultColor = this.button_default_color; this.button_object.hover = this.button_object.defaultColor; } else { Color defaultColor = this.button_default_color; defaultColor.a = 0.5f; this.button_object.defaultColor = defaultColor; this.button_object.hover = this.button_object.defaultColor; } } } public void UpdateMaskStatus(Maid maid) { if (maid == null || maid.body0 == null) { this.button_object.isEnabled = false; return; } if (this.unit_type == "全着衣" || this.unit_type == "全脱衣") { this.button_object.isEnabled = true; return; } bool flag = false; for (int i = 0; i < this.target_sloat_id_list.Count; i++) { if (maid.body0.GetSlotLoaded(this.target_sloat_id_list[i])) { flag = true; break; } } if (!flag) { this.button_object.isEnabled = false; return; } this.button_object.isEnabled = true; bool flag2 = true; for (int j = 0; j < this.target_sloat_id_list.Count; j++) { if (maid.body0.GetMask(this.target_sloat_id_list[j])) { flag2 = false; break; } } this.mask_mode = ((!flag2) ? PhotUndressingManager.MaskStatus.Off : PhotUndressingManager.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 == "全着衣" || this.unit_type == "全脱衣") { return; } bool flag = this.mask_mode == PhotUndressingManager.MaskStatus.On; for (int i = 0; i < this.target_sloat_id_list.Count; i++) { maid.body0.SetMask(this.target_sloat_id_list[i], !flag); } } public string unit_type; public List target_sloat_id_list = new List(); public string call_scenario = string.Empty; public Color button_default_color; public UIButton button_object; private PhotUndressingManager.MaskStatus button_mask_status_ = PhotUndressingManager.MaskStatus.Off; } }