123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175 |
- using System;
- using System.Collections.Generic;
- using UnityEngine;
- using UnityEngine.Events;
- using UnityEngine.UI;
- public class PhotoMotionDataShortcut : MonoBehaviour
- {
- public List<PhotoMotionDataShortcut.ItemData> itemDataList
- {
- get
- {
- return this.m_ItemDataList;
- }
- }
- private void Start()
- {
- CircleCommandUI circleCommandUI = this.m_CircleList.circleCommandUI;
- circleCommandUI.onSelect.AddListener(new UnityAction<GameObject>(this.OnSelectItem));
- circleCommandUI.onDeselect.AddListener(new UnityAction<GameObject>(this.OnDeselectItem));
- circleCommandUI.onDecide.AddListener(new UnityAction<GameObject>(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<Transform>(count, delegate(int index, Transform trans)
- {
- Text componentInChildren = trans.GetComponentInChildren<Text>();
- PhotoMotionDataShortcut.ItemData itemData = trans.gameObject.AddComponent<PhotoMotionDataShortcut.ItemData>();
- itemData.text = componentInChildren;
- itemData.data = null;
- this.m_ItemDataList.Add(itemData);
- });
- }
- private void OnSelectItem(GameObject item)
- {
- if (item == null)
- {
- return;
- }
- Graphic component = item.GetComponent<Graphic>();
- 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<Graphic>();
- 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<PhotoMotionDataShortcut.ItemData>();
- 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<PhotoMotionDataShortcut.ItemData> m_ItemDataList = new List<PhotoMotionDataShortcut.ItemData>();
- 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;
- }
- }
|