using System.Collections; using System.Collections.Generic; using UnityEngine; using GCGame.Table; public class ChildPanel : MonoBehaviour { public CommonMenuItemContainerBase _MenuItemBase; public static ChildPanel Instance; private void Awake() { Instance = this; } private void OnDestroy() { Instance = null; } private void OnEnable() { ReqChildInfo(); _MenuItemContainerBase.ShowNoDataPanel(GameManager.gameManager.PlayerDataPool.ChildData.ChildCount <= 0); _MenuItemContainerBase.ShowDefaultFirst(0); } private void OnDisable() { _CurSelectChildIndex = -1; } /// /// 请求全部孩子信息 /// void ReqChildInfo() { ReqChildren req = new ReqChildren(); req.flag = 1; req.SendMsg(); } public CommonMenuItemContainerBase _MenuItemContainerBase; public void ShowPanel(int index) { _MenuItemContainerBase.ShowNoDataPanel(GameManager.gameManager.PlayerDataPool.ChildData.ChildCount <= 0); _MenuItemContainerBase.ShowDefaultFirst(index); } public ChildInfoPanel _InfoPanel; public ChildStudyPanel _StudyPanel; public ChildFashionPanel _FashionPanel; public ChildRenicarNationPanel _RenicarNationPanel; public void RefreshChildData(RetChildren info) { #if UNITY_EDITOR for (int index = 0; index < info.list.Count; index++) { Debug.LogError("ChildName : " + info.list[index].basic.name + ", randomEventId : " + info.list[index].randomEvent.reserved); } #endif if (_InfoPanel.gameObject.activeInHierarchy) _InfoPanel.RefreshChildData(info); if (_StudyPanel.gameObject.activeInHierarchy) _StudyPanel.RefreshChildData(info); if (_FashionPanel.gameObject.activeInHierarchy) _FashionPanel.RefreshChildData(info); if (_RenicarNationPanel.gameObject.activeInHierarchy) _RenicarNationPanel.RefreshChildData(info); } public void OnClose() { UIManager.CloseUI(UIInfo.ChildPanel); } public void RefreshPanelRedState() { if (ChildInfoPanel.Instance) ChildInfoPanel.Instance.RefreshMenuItemRedState(); if (ChildRenicarNationPanel.Instance) ChildRenicarNationPanel.Instance.RefreshMenuItemRedState(); } private static int _CurSelectChildIndex = -1; public static void PlayeChildSoundByIndex(int childeIndex) { if (_CurSelectChildIndex == childeIndex) return; _CurSelectChildIndex = childeIndex; var childData = ChildData.GetChildByIndex(childeIndex); var childLevelUpTab = TableManager.GetChildrenLevelUpByID(childData.basic.curLevel, 0); if(childLevelUpTab == null) { Debug.LogError("ChildLevelUpTab is null : " + childData.basic.curLevel); return; } var childStateTypeTab = TableManager.GetChildrenStateTypeByID(childLevelUpTab.CurStateType, 0); if(childStateTypeTab == null) { Debug.LogError("ChildStateType is null : " + childLevelUpTab.CurStateType); return; } var soundId = childData.basic.gender == (int)ChildHeadIcon.ChildSex.Boy ? childStateTypeTab.BoySoundId : childStateTypeTab.GirlSoundId; GameManager.gameManager.SoundManager.PlaySoundEffect(soundId); } }