MaidMiniStatusCtrl.cs 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  1. using System;
  2. using System.Collections.Generic;
  3. using MaidStatus;
  4. using UnityEngine;
  5. using wf;
  6. namespace Kasizuki
  7. {
  8. public class MaidMiniStatusCtrl : NGUIWindow, IStatusCtrl<Maid>
  9. {
  10. protected override void Awake()
  11. {
  12. base.Awake();
  13. base.CacheChildObject<UILabel>("FirstName/Value", "FirstName");
  14. base.CacheChildObject<UILabel>("LastName/Value", "LastName");
  15. base.CacheChildObject<UILabel>("Column1/Character/Value", "Personal");
  16. base.CacheChildObject<UILabel>("Column1/SexExperience/Value", "SexualExp");
  17. base.CacheChildObject<UILabel>("Column1/BodySize/Parent/Height/Value", "Height");
  18. base.CacheChildObject<UILabel>("Column1/BodySize/Parent/Weight/Value", "Weight");
  19. base.CacheChildObject<UILabel>("Column1/BodySize/Parent/Bust/Value", "Bust");
  20. base.CacheChildObject<UILabel>("Column1/BodySize/Parent/Bust/Cup/Value", "Cup");
  21. base.CacheChildObject<UILabel>("Column1/BodySize/Parent/Waist/Value", "Waist");
  22. base.CacheChildObject<UILabel>("Column1/BodySize/Parent/Hip/Value", "Hip");
  23. base.CacheChildObject<UILabel>("WorkCount/Value", "WorkCount");
  24. MaidAppealComment maidAppealComment = base.CacheChildObject<MaidAppealComment>("AppealComment", "Appeal");
  25. MaidAppealComment maidAppealComment2 = maidAppealComment;
  26. maidAppealComment2.onClickRight = (Action)Delegate.Combine(maidAppealComment2.onClickRight, new Action(delegate()
  27. {
  28. this.ChangeMaidAppeal(1);
  29. }));
  30. MaidAppealComment maidAppealComment3 = maidAppealComment;
  31. maidAppealComment3.onClickLeft = (Action)Delegate.Combine(maidAppealComment3.onClickLeft, new Action(delegate()
  32. {
  33. this.ChangeMaidAppeal(-1);
  34. }));
  35. UIInput uiinput = base.CacheChildObject<UIInput>("FreeCommentWindow/FreeComment", "FreeComment");
  36. EventDelegate.Add(uiinput.onChange, new EventDelegate.Callback(this.OnChangeFreeComment));
  37. this.m_IsAwaked = true;
  38. }
  39. public void SetData(Maid maid)
  40. {
  41. if (maid == null)
  42. {
  43. NDebug.Warning("情報を表示するメイドにnullが指定されました。");
  44. return;
  45. }
  46. this.m_TargetMaid = maid;
  47. this.UpdateNGUILabel();
  48. }
  49. public void UpdateMaidInfo()
  50. {
  51. if (this.m_TargetMaid == null)
  52. {
  53. NDebug.Warning("情報を表示するメイドがnullでした。SetMaid( Maid )関数で、情報を表示するメイドを指定してください。");
  54. return;
  55. }
  56. this.UpdateNGUILabel();
  57. }
  58. private void UpdateNGUILabel()
  59. {
  60. if (!this.m_IsAwaked)
  61. {
  62. base.gameObject.SetActive(true);
  63. }
  64. Maid targetMaid = this.m_TargetMaid;
  65. Status status = targetMaid.status;
  66. base.GetCache<UILabel>("FirstName").text = status.firstName;
  67. base.GetCache<UILabel>("LastName").text = status.lastName;
  68. UILabel cache = base.GetCache<UILabel>("Personal");
  69. cache.fontSize = 25;
  70. cache.text = status.personal.drawName;
  71. Utility.ResizeUILabelFontSize(cache, 251);
  72. base.GetCache<UILabel>("SexualExp").text = EnumConvert.GetString(status.seikeiken);
  73. base.GetCache<UILabel>("Height").text = status.body.height.ToString();
  74. base.GetCache<UILabel>("Weight").text = status.body.weight.ToString();
  75. base.GetCache<UILabel>("Bust").text = status.body.bust.ToString();
  76. base.GetCache<UILabel>("Cup").text = status.body.cup;
  77. base.GetCache<UILabel>("Waist").text = status.body.waist.ToString();
  78. base.GetCache<UILabel>("Hip").text = status.body.hip.ToString();
  79. int maidData = GameMain.Instance.KasizukiMgr.GetMaidData<int>(targetMaid, MaidDataType.仕事回数, false);
  80. base.GetCache<UILabel>("WorkCount").text = maidData.ToString();
  81. string maidData2 = GameMain.Instance.KasizukiMgr.GetMaidData<string>(targetMaid, MaidDataType.フリ\u30FCコメント, false);
  82. base.GetCache<UIInput>("FreeComment").value = maidData2;
  83. this.ChangeMaidAppeal(0);
  84. }
  85. private void ChangeMaidAppeal(int relativeIndex)
  86. {
  87. MaidAppealComment cache = base.GetCache<MaidAppealComment>("Appeal");
  88. Maid targetMaid = this.m_TargetMaid;
  89. int maidData = GameMain.Instance.KasizukiMgr.GetMaidData<int>(targetMaid, MaidDataType.アピ\u30FCル欄, false);
  90. List<AppealData.Data> datas = AppealData.GetDatas(targetMaid);
  91. if (AppealData.Contains(maidData))
  92. {
  93. AppealData.Data relativeAppealData = this.GetRelativeAppealData(datas, AppealData.GetData(maidData), relativeIndex);
  94. if (relativeAppealData != null)
  95. {
  96. this.SetAppealImage(relativeAppealData);
  97. }
  98. }
  99. else if (datas.Count > 0)
  100. {
  101. this.SetAppealImage(datas[0]);
  102. }
  103. }
  104. private void SetAppealImage(AppealData.Data data)
  105. {
  106. MaidAppealComment cache = base.GetCache<MaidAppealComment>("Appeal");
  107. cache.ChangeImage(data.GetTexture());
  108. GameMain.Instance.KasizukiMgr.SetMaidData<int>(this.m_TargetMaid, MaidDataType.アピ\u30FCル欄, data.ID, false);
  109. }
  110. private AppealData.Data GetRelativeAppealData(List<AppealData.Data> list, AppealData.Data now, int index)
  111. {
  112. if (list == null || now == null)
  113. {
  114. return null;
  115. }
  116. int num = -1;
  117. if (list.Count > 0)
  118. {
  119. num = list.IndexOf(now);
  120. }
  121. if (num >= 0 && 0 <= num + index && num + index < list.Count)
  122. {
  123. return list[num + index];
  124. }
  125. return null;
  126. }
  127. private void OnChangeFreeComment()
  128. {
  129. if (this.m_TargetMaid == null)
  130. {
  131. Debug.LogWarning("フリーコメント欄に文字が入力されましたが、選択中のメイドが存在しないので何もしません。");
  132. return;
  133. }
  134. string value = UIInput.current.value;
  135. KasizukiManager kasizukiMgr = GameMain.Instance.KasizukiMgr;
  136. kasizukiMgr.SetMaidData<string>(this.m_TargetMaid, MaidDataType.フリ\u30FCコメント, value, false);
  137. }
  138. private string AdjustStrLengthIfOver(string str, int length)
  139. {
  140. if (str.Length > length)
  141. {
  142. str = str.Substring(length);
  143. Debug.LogError(string.Format("入力された文字数が最大文字数を超えています。入力文字={0}, 最大文字数={1}", str, length));
  144. }
  145. return str;
  146. }
  147. private const int MAX_FREE_COMMENT_LENGTH = 70;
  148. private Maid m_TargetMaid;
  149. private bool m_IsAwaked;
  150. }
  151. }