PhotoMotionDataShortcut.cs 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175
  1. using System;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using UnityEngine.Events;
  5. using UnityEngine.UI;
  6. public class PhotoMotionDataShortcut : MonoBehaviour
  7. {
  8. public List<PhotoMotionDataShortcut.ItemData> itemDataList
  9. {
  10. get
  11. {
  12. return this.m_ItemDataList;
  13. }
  14. }
  15. private void Start()
  16. {
  17. CircleCommandUI circleCommandUI = this.m_CircleList.circleCommandUI;
  18. circleCommandUI.onSelect.AddListener(new UnityAction<GameObject>(this.OnSelectItem));
  19. circleCommandUI.onDeselect.AddListener(new UnityAction<GameObject>(this.OnDeselectItem));
  20. circleCommandUI.onDecide.AddListener(new UnityAction<GameObject>(this.OnDecide));
  21. this.m_CircleList.SetActiveUI(false);
  22. }
  23. public void CreateItemList(int count)
  24. {
  25. CircleCommandUI circleCommandUI = this.m_CircleList.circleCommandUI;
  26. GameObject tempItem = circleCommandUI.listViewer.tempItem;
  27. Transform transform = tempItem.transform;
  28. transform.localScale = Vector3.one * 0.5f;
  29. circleCommandUI.Show<Transform>(count, delegate(int index, Transform trans)
  30. {
  31. Text componentInChildren = trans.GetComponentInChildren<Text>();
  32. PhotoMotionDataShortcut.ItemData itemData = trans.gameObject.AddComponent<PhotoMotionDataShortcut.ItemData>();
  33. itemData.text = componentInChildren;
  34. itemData.data = null;
  35. this.m_ItemDataList.Add(itemData);
  36. });
  37. }
  38. private void OnSelectItem(GameObject item)
  39. {
  40. if (item == null)
  41. {
  42. return;
  43. }
  44. Graphic component = item.GetComponent<Graphic>();
  45. if (component != null)
  46. {
  47. component.color = Color.red;
  48. }
  49. item.transform.localScale = Vector3.one;
  50. item.transform.SetAsFirstSibling();
  51. }
  52. private void OnDeselectItem(GameObject item)
  53. {
  54. if (item == null)
  55. {
  56. return;
  57. }
  58. Graphic component = item.GetComponent<Graphic>();
  59. if (component != null)
  60. {
  61. Color white = Color.white;
  62. white.a = 0.5f;
  63. component.color = white;
  64. }
  65. item.transform.localScale = Vector3.one * 0.5f;
  66. }
  67. private void OnDecide(GameObject selectItem)
  68. {
  69. if (selectItem == null)
  70. {
  71. Debug.LogWarning("選択項目にnullが入った");
  72. return;
  73. }
  74. this.OnDeselectItem(selectItem);
  75. this.m_CircleList.SetActiveUI(false);
  76. PhotoMotionDataShortcut.ItemData component = selectItem.GetComponent<PhotoMotionDataShortcut.ItemData>();
  77. if (component != null)
  78. {
  79. this.ApplyMaidFace(this.GetMaid(), component);
  80. }
  81. }
  82. private void ApplyMaidFace(Maid maid, PhotoMotionDataShortcut.ItemData faceData)
  83. {
  84. if (faceData == null)
  85. {
  86. Debug.Log("モーションデータにnullが指定されました。");
  87. return;
  88. }
  89. if (maid == null)
  90. {
  91. Debug.Log("メイドにnullが指定されました。");
  92. return;
  93. }
  94. Debug.Log("メイドのモーションを変更します...\u3000モーション:" + faceData.name);
  95. faceData.data.Apply(maid);
  96. }
  97. public void Emulate(PhotoMotionDataShortcut.ItemData itemData)
  98. {
  99. if (!this.itemDataList.Contains(itemData))
  100. {
  101. Debug.Log("コントローラ上に存在しないデータを選んだ");
  102. return;
  103. }
  104. this.ApplyMaidFace(this.GetMaid(), itemData);
  105. }
  106. private Maid GetMaid()
  107. {
  108. CharacterMgr characterMgr = GameMain.Instance.CharacterMgr;
  109. return characterMgr.GetMaid(0);
  110. }
  111. [SerializeField]
  112. private CircleListSelectUI m_CircleList;
  113. private List<PhotoMotionDataShortcut.ItemData> m_ItemDataList = new List<PhotoMotionDataShortcut.ItemData>();
  114. public class ItemData : MonoBehaviour
  115. {
  116. public PhotoMotionData data
  117. {
  118. get
  119. {
  120. return this.m_Data;
  121. }
  122. set
  123. {
  124. this.m_Data = value;
  125. this.UpdateText();
  126. }
  127. }
  128. public Text text
  129. {
  130. get
  131. {
  132. return this.m_Text;
  133. }
  134. set
  135. {
  136. this.m_Text = value;
  137. }
  138. }
  139. private void UpdateText()
  140. {
  141. if (this.text == null)
  142. {
  143. return;
  144. }
  145. this.text.text = this.GetDataName();
  146. }
  147. public string GetDataName()
  148. {
  149. if (this.data == null)
  150. {
  151. return "無し";
  152. }
  153. return this.data.name;
  154. }
  155. private PhotoMotionData m_Data;
  156. private Text m_Text;
  157. }
  158. }