using System; using System.Collections.Generic; using UnityEngine; using UnityEngine.Events; using UnityEngine.UI; public class PhotoMotionDataShortcut : MonoBehaviour { public List itemDataList { get { return this.m_ItemDataList; } } private void Start() { CircleCommandUI circleCommandUI = this.m_CircleList.circleCommandUI; circleCommandUI.onSelect.AddListener(new UnityAction(this.OnSelectItem)); circleCommandUI.onDeselect.AddListener(new UnityAction(this.OnDeselectItem)); circleCommandUI.onDecide.AddListener(new UnityAction(this.OnDecide)); this.m_CircleList.SetActiveUI(false); } public void CreateItemList(int count) { CircleCommandUI circleCommandUI = this.m_CircleList.circleCommandUI; GameObject tempItem = circleCommandUI.listViewer.tempItem; Transform transform = tempItem.transform; transform.localScale = Vector3.one * 0.5f; circleCommandUI.Show(count, delegate(int index, Transform trans) { Text componentInChildren = trans.GetComponentInChildren(); PhotoMotionDataShortcut.ItemData itemData = trans.gameObject.AddComponent(); itemData.text = componentInChildren; itemData.data = null; this.m_ItemDataList.Add(itemData); }); } private void OnSelectItem(GameObject item) { if (item == null) { return; } Graphic component = item.GetComponent(); if (component != null) { component.color = Color.red; } item.transform.localScale = Vector3.one; item.transform.SetAsFirstSibling(); } private void OnDeselectItem(GameObject item) { if (item == null) { return; } Graphic component = item.GetComponent(); if (component != null) { Color white = Color.white; white.a = 0.5f; component.color = white; } item.transform.localScale = Vector3.one * 0.5f; } private void OnDecide(GameObject selectItem) { if (selectItem == null) { Debug.LogWarning("選択項目にnullが入った"); return; } this.OnDeselectItem(selectItem); this.m_CircleList.SetActiveUI(false); PhotoMotionDataShortcut.ItemData component = selectItem.GetComponent(); if (component != null) { this.ApplyMaidFace(this.GetMaid(), component); } } private void ApplyMaidFace(Maid maid, PhotoMotionDataShortcut.ItemData faceData) { if (faceData == null) { Debug.Log("モーションデータにnullが指定されました。"); return; } if (maid == null) { Debug.Log("メイドにnullが指定されました。"); return; } Debug.Log("メイドのモーションを変更します...\u3000モーション:" + faceData.name); faceData.data.Apply(maid); } public void Emulate(PhotoMotionDataShortcut.ItemData itemData) { if (!this.itemDataList.Contains(itemData)) { Debug.Log("コントローラ上に存在しないデータを選んだ"); return; } this.ApplyMaidFace(this.GetMaid(), itemData); } private Maid GetMaid() { CharacterMgr characterMgr = GameMain.Instance.CharacterMgr; return characterMgr.GetMaid(0); } [SerializeField] private CircleListSelectUI m_CircleList; private List m_ItemDataList = new List(); public class ItemData : MonoBehaviour { public PhotoMotionData data { get { return this.m_Data; } set { this.m_Data = value; this.UpdateText(); } } public Text text { get { return this.m_Text; } set { this.m_Text = value; } } private void UpdateText() { if (this.text == null) { return; } this.text.text = this.GetDataName(); } public string GetDataName() { if (this.data == null) { return "無し"; } return this.data.name; } private PhotoMotionData m_Data; private Text m_Text; } }