123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480 |
- 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<UIGrid>();
- 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<UndressingManager.UnitType, UndressingManager.UndressingData> 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<Maid> list = new List<Maid>();
- 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<UndressingManager.UnitType, UndressingManager.UndressingData> 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<UndressingManager.UnitType, UndressingManager.UndressingData> 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<UndressingManager.UnitType, UndressingManager.UndressingData> 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<UndressingManager.UnitData> UnitDataList = new List<UndressingManager.UnitData>();
- [SerializeField]
- private UIButton hannugiButton;
- private Dictionary<UndressingManager.UnitType, UndressingManager.UndressingData> unit_dic_ = new Dictionary<UndressingManager.UnitType, UndressingManager.UndressingData>();
- 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<TBody.SlotID> target_sloat_id_list = new List<TBody.SlotID>();
- public List<MPN> target_newbody_mpn_id_list = new List<MPN>();
- public string call_scenario = string.Empty;
- public Color button_default_color;
- public UIButton button_object;
- private UndressingManager.MaskStatus button_mask_status_ = UndressingManager.MaskStatus.Off;
- }
- }
|