using System; using System.Collections.Generic; using UnityEngine; using UnityEngine.Events; using UnityEngine.UI; public class PhotoFaceDataShortcut : MonoBehaviour { public List itemDataList { get { return this.m_ItemDataList; } } public bool IsLeftHand { get { return this.m_IsLeftHand; } set { this.m_IsLeftHand = value; } } public void Init(bool isLeftHand) { this.m_IsLeftHand = isLeftHand; 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.controller = ((!isLeftHand) ? GameMain.Instance.OvrMgr.ovr_obj.right_controller.controller : GameMain.Instance.OvrMgr.ovr_obj.left_controller.controller); this.m_CircleList.SetActiveUI(true); GameObject childObject = UTY.GetChildObject(base.gameObject, "CircleCommandUI/text right hand", false); childObject.GetComponent().text = ((!isLeftHand) ? "右" : "左"); } 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; this.itemDataList.Clear(); PhotoFaceData.Create(); circleCommandUI.Show(count, delegate(int index, Transform trans) { Text componentInChildren = trans.GetComponentInChildren(); PhotoFaceDataShortcut.ItemData itemData = trans.gameObject.AddComponent(); itemData.handController = this; itemData.index = index; itemData.text = componentInChildren; this.itemDataList.Add(itemData); }); ControllerShortcutSettingData.LoadDefault(); if (this.m_IsLeftHand) { List faceListLeft = ControllerShortcutSettingData.config.faceListLeft; for (int i = 0; i < faceListLeft.Count; i++) { if (i < this.itemDataList.Count) { this.itemDataList[i].faceData = faceListLeft[i]; } } } else { List faceListRight = ControllerShortcutSettingData.config.faceListRight; for (int j = 0; j < faceListRight.Count; j++) { if (j < this.itemDataList.Count) { this.itemDataList[j].faceData = faceListRight[j]; } } } } 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.SetAsLastSibling(); if (ControllerShortcutSettingData.config.isDirectMode) { PhotoFaceDataShortcut.ItemData component2 = item.GetComponent(); if (component2 != null) { this.ApplyMaidFace(this.GetMaid(), component2); } } } 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); if (!ControllerShortcutSettingData.config.isEveryShowMode) { this.m_CircleList.SetActiveUI(false); } if (ControllerShortcutSettingData.config.isDirectMode) { return; } PhotoFaceDataShortcut.ItemData component = selectItem.GetComponent(); if (component != null) { this.ApplyMaidFace(this.GetMaid(), component); } } private void ApplyMaidFace(Maid maid, PhotoFaceDataShortcut.ItemData itemData) { if (itemData == null || itemData.data == null) { Debug.Log("表情データにnullが指定されました。"); return; } if (maid == null) { Debug.Log("メイドにnullが指定されました。"); return; } maid.FaceAnime(itemData.data.setting_name, 0.5f, 0); maid.body0.Face.morph.SetValueOriginalBlendSet(itemData.blendType); maid.FaceBlend("オリジナル"); maid.OpenMouth(itemData.isOpenMouth); Debug.Log(string.Concat(new object[] { "基本表情:", itemData.data.name, "\n追加表情:", itemData.blendType })); } public void Emulate(PhotoFaceDataShortcut.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(); private bool m_IsLeftHand; [Serializable] public class FaceData { public string dataName { get { return this.m_strData; } } public PhotoFaceData data { get { return this.m_Data; } set { this.m_Data = value; if (value == null) { this.m_strData = PhotoFaceDataShortcut.FaceData.strDataNull; } else { this.m_strData = value.setting_name; } } } public TMorph.AddBlendType blendType { get { return this.m_BlendType; } set { this.m_BlendType = value; } } public bool isOpenMouth { get { return this.m_IsOpenMouth; } set { this.m_IsOpenMouth = value; } } public static PhotoFaceDataShortcut.FaceData defaultData { get { if (PhotoFaceDataShortcut.FaceData.m_DefaultData == null) { PhotoFaceData.Create(); PhotoFaceDataShortcut.FaceData.m_DefaultData = new PhotoFaceDataShortcut.FaceData(); PhotoFaceDataShortcut.FaceData.m_DefaultData.data = PhotoFaceData.init_data; PhotoFaceDataShortcut.FaceData.m_DefaultData.m_strData = PhotoFaceDataShortcut.FaceData.strDataNull; PhotoFaceDataShortcut.FaceData.m_DefaultData.blendType = TMorph.AddBlendType.None; PhotoFaceDataShortcut.FaceData.m_DefaultData.isOpenMouth = false; } return PhotoFaceDataShortcut.FaceData.m_DefaultData; } } private PhotoFaceData m_Data; [SerializeField] private TMorph.AddBlendType m_BlendType; [SerializeField] private bool m_IsOpenMouth; [SerializeField] private string m_strData; private static string strDataNull = "通常"; private static PhotoFaceDataShortcut.FaceData m_DefaultData; } public class ItemData : MonoBehaviour { public PhotoFaceDataShortcut handController { get; set; } public int index { get; set; } public PhotoFaceDataShortcut.FaceData faceData { get { return this.m_FaceData; } set { this.m_FaceData = value; this.UpdateData(); } } public PhotoFaceData data { get { return this.m_FaceData.data; } set { this.m_FaceData.data = value; this.UpdateText(); this.UpdateConfigData(); } } public Text text { get { return this.m_Text; } set { this.m_Text = value; } } public TMorph.AddBlendType blendType { get { return this.m_FaceData.blendType; } set { this.m_FaceData.blendType = value; } } public bool isOpenMouth { get { return this.m_FaceData.isOpenMouth; } set { this.m_FaceData.isOpenMouth = 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 void UpdateConfigData() { if (this.handController.IsLeftHand) { if (ControllerShortcutSettingData.config.faceListLeft.Count <= this.index) { return; } ControllerShortcutSettingData.config.faceListLeft[this.index] = this.faceData; } else { if (ControllerShortcutSettingData.config.faceListRight.Count <= this.index) { return; } ControllerShortcutSettingData.config.faceListRight[this.index] = this.faceData; } } private void UpdateData() { PhotoFaceDataShortcut.ItemData.CreatePhotoFaceDataNameDic(); int num; if (PhotoFaceDataShortcut.ItemData.photoFaceDataNameDic.TryGetValue(this.faceData.dataName, out num)) { this.data = PhotoFaceData.Get((long)num); } else { this.data = null; } } private static void CreatePhotoFaceDataNameDic() { if (PhotoFaceDataShortcut.ItemData.m_PhotoFaceDataNameDic != null && PhotoFaceDataShortcut.ItemData.m_PhotoFaceDataNameDic.Count > 0) { return; } PhotoFaceData.Create(); PhotoFaceDataShortcut.ItemData.m_PhotoFaceDataNameDic = new SortedDictionary(); foreach (PhotoFaceData photoFaceData in PhotoFaceData.data) { PhotoFaceDataShortcut.ItemData.m_PhotoFaceDataNameDic.Add(photoFaceData.setting_name, photoFaceData.id); } } public static SortedDictionary photoFaceDataNameDic { get { PhotoFaceDataShortcut.ItemData.CreatePhotoFaceDataNameDic(); return PhotoFaceDataShortcut.ItemData.m_PhotoFaceDataNameDic; } private set { PhotoFaceDataShortcut.ItemData.m_PhotoFaceDataNameDic = value; } } private PhotoFaceDataShortcut.FaceData m_FaceData = new PhotoFaceDataShortcut.FaceData(); private Text m_Text; private static SortedDictionary m_PhotoFaceDataNameDic; } }