123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329 |
- using System;
- using System.Collections.Generic;
- 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);
- }
- }
- }
- }
- }
- }
- public void SetCallBackEvent(UndressingManager.OnClickEventDelegate func)
- {
- this.onclick_event_ = func;
- }
- public void SetMaid(Maid maid, Maid[] linked_maid_array)
- {
- this.maid_ = maid;
- 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.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);
- }
- }
- private 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>();
- 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);
- private 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;
- }
- 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;
- }
- 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) ? 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;
- for (int i = 0; i < this.target_sloat_id_list.Count; i++)
- {
- maid.body0.SetMask(this.target_sloat_id_list[i], !flag);
- }
- }
- public UndressingManager.UnitType unit_type;
- public List<TBody.SlotID> target_sloat_id_list = new List<TBody.SlotID>();
- public string call_scenario = string.Empty;
- public Color button_default_color;
- public UIButton button_object;
- private UndressingManager.MaskStatus button_mask_status_ = UndressingManager.MaskStatus.Off;
- }
- }
|