UndressItem.cs 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170
  1. using System;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using wf;
  5. namespace Dance
  6. {
  7. public class UndressItem : MonoBehaviour
  8. {
  9. private UndressDance_Mgr.PartsData m_MyPartsData
  10. {
  11. get
  12. {
  13. return UndressDance_Mgr.Instance.GetPartsData(this.m_MyMpn);
  14. }
  15. }
  16. public bool IsUndress
  17. {
  18. get
  19. {
  20. return this.m_MaidPartsiconPair[UndressDance_Mgr.Instance.SelectMaid].IsUndress;
  21. }
  22. }
  23. public bool IsEnable
  24. {
  25. get
  26. {
  27. return this.m_MyButton.isEnabled;
  28. }
  29. }
  30. public void Init(MPN mpn)
  31. {
  32. this.m_MyButton = base.GetComponent<UIButton>();
  33. this.m_MyIcon = base.GetComponent<UITexture>();
  34. this.m_MyMpn = mpn;
  35. this.m_MyIcon.mainTexture = this.m_MyPartsData.DefaultIcon;
  36. EventDelegate.Add(this.m_MyButton.onClick, new EventDelegate.Callback(this.SwitchMask));
  37. }
  38. public void AddMaidData(Maid maid)
  39. {
  40. if (!maid || this.m_MaidPartsiconPair.ContainsKey(maid))
  41. {
  42. return;
  43. }
  44. if (maid.IsCrcBody)
  45. {
  46. this.m_MaidPartsiconPair[maid] = new UndressItem.MaidInfo(null, false);
  47. }
  48. else
  49. {
  50. MaidProp prop = maid.GetProp(this.m_MyMpn);
  51. SceneEdit.SMenuItem smenuItem = new SceneEdit.SMenuItem();
  52. SceneEdit.InitMenuItemScript(smenuItem, prop.strFileName, false);
  53. if (smenuItem.m_texIconRef)
  54. {
  55. this.m_MaidPartsiconPair.Add(maid, new UndressItem.MaidInfo(smenuItem.m_texIconRef, false));
  56. }
  57. }
  58. }
  59. public void UpdateState(Maid maid)
  60. {
  61. if (maid.IsCrcBody)
  62. {
  63. this.m_MyButton.isEnabled = false;
  64. foreach (MPN parentMpn in this.m_MyPartsData.Mpnlist)
  65. {
  66. if (maid.body0.GetSlotLoaded(parentMpn))
  67. {
  68. this.m_MyButton.isEnabled = true;
  69. break;
  70. }
  71. }
  72. if (this.m_MyPartsData.Mpnlist.Count <= 0 && this.m_MyButton.gameObject.activeSelf)
  73. {
  74. this.m_MyButton.gameObject.SetActive(false);
  75. Utility.ResetNGUI(this.m_MyButton.transform.parent.GetComponent<UIGrid>());
  76. }
  77. }
  78. else
  79. {
  80. string strFileName = maid.GetProp(this.m_MyMpn).strFileName;
  81. this.m_MyButton.isEnabled = (!string.IsNullOrEmpty(strFileName) && strFileName.IndexOf("_del") < 0 && this.m_MaidPartsiconPair.ContainsKey(maid));
  82. }
  83. if (!this.m_MyButton.isEnabled || maid.IsCrcBody)
  84. {
  85. this.m_MyIcon.mainTexture = this.m_MyPartsData.DefaultIcon;
  86. if (maid.IsCrcBody)
  87. {
  88. this.m_MyButton.defaultColor = (this.m_MyButton.hover = ((!this.m_MaidPartsiconPair[maid].IsUndress) ? this.m_DefaultColor : this.m_UndressColor));
  89. }
  90. }
  91. else
  92. {
  93. this.m_MyIcon.mainTexture = this.m_MaidPartsiconPair[maid].ItemIcon;
  94. this.m_MyButton.defaultColor = (this.m_MyButton.hover = ((!this.m_MaidPartsiconPair[maid].IsUndress) ? this.m_DefaultColor : this.m_UndressColor));
  95. }
  96. }
  97. public void SetMaidMask(Maid maid, bool is_mask_on)
  98. {
  99. if (!this.IsEnable)
  100. {
  101. return;
  102. }
  103. if (!this.m_MaidPartsiconPair.ContainsKey(maid))
  104. {
  105. return;
  106. }
  107. if (this.m_MaidPartsiconPair[maid].IsUndress == is_mask_on)
  108. {
  109. return;
  110. }
  111. this.m_MaidPartsiconPair[maid].IsUndress = is_mask_on;
  112. if (maid.IsCrcBody)
  113. {
  114. foreach (MPN parentMpn in this.m_MyPartsData.Mpnlist)
  115. {
  116. maid.body0.SetMask(parentMpn, !is_mask_on);
  117. }
  118. }
  119. else
  120. {
  121. foreach (TBody.SlotID f_eSlot in this.m_MyPartsData.SlotIDlist)
  122. {
  123. maid.body0.SetMask(f_eSlot, !is_mask_on);
  124. }
  125. }
  126. this.UpdateState(maid);
  127. UndressDance_Mgr.Instance.ChangeSexsualPoint(this.m_MyMpn);
  128. }
  129. public void SwitchMask()
  130. {
  131. Maid selectMaid = UndressDance_Mgr.Instance.SelectMaid;
  132. this.SetMaidMask(selectMaid, !this.m_MaidPartsiconPair[selectMaid].IsUndress);
  133. }
  134. [SerializeField]
  135. private Color m_DefaultColor = Color.white;
  136. [SerializeField]
  137. private Color m_UndressColor = Color.white;
  138. private UIButton m_MyButton;
  139. private UITexture m_MyIcon;
  140. private MPN m_MyMpn;
  141. private Dictionary<Maid, UndressItem.MaidInfo> m_MaidPartsiconPair = new Dictionary<Maid, UndressItem.MaidInfo>();
  142. private class MaidInfo
  143. {
  144. public MaidInfo(Texture icon, bool is_undress)
  145. {
  146. this.ItemIcon = icon;
  147. this.IsUndress = is_undress;
  148. }
  149. public bool IsUndress;
  150. public Texture ItemIcon;
  151. }
  152. }
  153. }