using GCGame.Table; using System; using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; public class ChildInfoPanel : MonoBehaviour, ChildRefreshInterface, SyncSingleChildInterface{ public static ChildInfoPanel Instance; private void Awake() { Instance = this; } private void OnEnable() { RefreshChildData(); } private void OnDisable() { _IsShowAdventurePop = false; } //信息 模型 public Text _ChildName; public ChildModelAndEffectCtr _ModelEffectlCtr; public UIImgText _ChildCombatVal; public RectTransform _ChildChatPopBG; public Text _ChidChatText; public ChildSwitchBtnPanel _SwitchPanel; //技能 public ChildSkillPanel _ChildSkillPanel; //属性 public List _ChildAttrItemList; //成长 public Text _TodayPreGrowthVal; //今日预测成长值 public Text _ChildFoodVal; public Text _ChildCleanVal; public Text _ChildMoodVal; public Text _ChildHealthVal; public Text _GrowthStateDescText; public Text _CloseVal; //亲密度 public Slider _ChildGrowthSlider; public Text _ChildGrowthSliderVal; public List _RemainInteracTimes; //孩子当前学习状态 public GameObject _ChildStatePanel; public Text _ChildStateDescText; public RemainTimeCoroutine _ChildStateRemainTimeText; //按钮 public GameObject _FollowBtn; public GameObject _CancelFollowBtn; //红点 public List _RedIconList; //改名面板 public GameObject _ChangeNamePanel; /// /// 召唤孩子跟随 /// public void OnChildFollowBtn() { if (ChildData.GetChildByIndex(_CurSelectChildIndex) == null) return; var childParamTab = TableManager.GetChildrenParaByID(1, 0); if (ChildData.GetChildByIndex(_CurSelectChildIndex).basic.curLevel < (childParamTab != null ? childParamTab.FollowLevel : 2)) { GUIData.AddNotifyData(StrDictionary.GetClientDictionaryString("#{86816}")); return; } ReqChildrenFollow req = new ReqChildrenFollow(); req.childrenGuid = ChildData.GetChildByIndex(_CurSelectChildIndex).guid; req.SendMsg(); } /// /// 跟孩子互动,区别Index /// /// public void OnChildInteractionBtn(int operationIndex) { if (ChildData.GetChildByIndex(_CurSelectChildIndex) == null) return; if (ChildData.GetChildByIndex(_CurSelectChildIndex).basic.embryoEndtime > GlobalData.ServerAnsiTime) { GUIData.AddNotifyData(StrDictionary.GetClientDictionaryString("#{86804}")); return; } _IsShowAdventurePop = false; //主动交互的时候屏蔽当前的奇遇 在交互完成之后重新触发. if (int.Parse(_RemainInteracTimes[operationIndex - 1].text) > 0) { InitChatPop(operationIndex); _ModelEffectlCtr.PlayChildAnimation(operationIndex); } ReqChildrenInteract req = new ReqChildrenInteract(); req.childrenGuid = ChildData.GetChildByIndex(_CurSelectChildIndex).guid; req.type = operationIndex; req.SendMsg(); } private bool isShowChatPop = false; public void InitChatPop(int operationIndex) { var index = operationIndex - 1; if (int.Parse(_RemainInteracTimes[index].text) <= 0) return; var talkVal = StrDictionary.GetClientDictionaryString("#{" + (86830 + index) + "}"); SetChildChats(talkVal); } private float _WaitSconds = 3.0f; private float _CountTime = 0.0f; private void Update() { if(isShowChatPop) { _CountTime += Time.deltaTime; if(_CountTime >= _WaitSconds) { _CountTime = 0.0f; if(!_IsShowAdventurePop) { isShowChatPop = false; _ChildChatPopBG.gameObject.SetActive(false); //正常互动结束的时候判断当前是否有奇遇 InitAdventureDesc(); } } } } /// /// 点击修改名称 /// public void OnChangeChildNameBtn() { ChangeNameInputPanel.ShowChangeNameInputPanel(OnConfirmNameBtn); _ChangeNamePanel.SetActive(true); } public void OnConfirmNameBtn(string name) { ChildrenChangeName req = new ChildrenChangeName(); req.childrenGuid =_CurChildGuid; req.name = name; req.SendMsg(); } // 边界值20 20 17 17 原始大小119 64 public bool _IsShowAdventurePop = false; public void SetChildChats(string info) { _CountTime = 0.0f; isShowChatPop = true; _ChildChatPopBG.gameObject.SetActive (true); _ChidChatText.text = info; } //奇遇事件,暂留 public void OnAdventureRecordBtn() { UIManager.ShowUI(UIInfo.ChildAdventureRecordPanel, (bool bSucess, object param) => { if(bSucess) { ChildAdventureRecordPanel.Instance.InitRecordPanel(_CurSelectChildIndex); } }); } public void RefreshChildData(RetChildren childData = null) { _FollowBtn.SetActive(ChildData.ChildPacket != null && ChildData.ChildPacket.list.Count >0); InitChildInfoPanel(); } void InitChildInfoPanel() { _SwitchPanel.InitSwitchPanel(ChildData.ChildPacket == null ? 0 : ChildData.ChildPacket.list.Count); ShowChildByIndex(); } private int _CurSelectChildIndex = -1; public long _CurChildGuid = -1; public void ShowChildByIndex(int index = 0) { //切换成功之后再记录 _CurSelectChildIndex = index; ChildPanel.PlayeChildSoundByIndex(_CurSelectChildIndex); if (ChildData.ChildPacket != null && index > ChildData.ChildPacket.list.Count - 1) { Debug.LogError("index out of range"); return; } _CurChildGuid = ChildData.GetChildByIndex(index).guid; //倒计时初始化 IsInitEmbyroPanel(); //告诉服务器当前选中的子女 SetCurSelectChild(); //名称 战力 模型 InitNameAndModelPanel(); //技能 _ChildSkillPanel.InitSkillItem(_CurSelectChildIndex); //属性 InitAttrPanel(); //清洁相关 交互 InitInteractionPanel(); //当前学习状态 InitStudyState(); //初始化按钮状态 InitBtnState(); //初始化奇遇 InitAdventureDesc(); //刷新界面红点 RefreshMenuItemRedState(); } public void RefreshMenuItemRedState() { var stateList = ChildData.GetChildRedStateByIndex(_CurSelectChildIndex); var _MenuItemBase = ChildPanel.Instance._MenuItemBase; for (int index = 0; index < _MenuItemBase._MenuItemList.Count; index++) { _MenuItemBase._MenuItemList[index].ShowRedIcon(stateList != null && stateList.Contains(index + 1)); } //转世 if (ChildRenicarNationPanel.Instance) ChildRenicarNationPanel.Instance.ShowRedIcon(stateList != null && stateList.Contains(3)); } //选中当前子女 void SetCurSelectChild() { SelectCurChildren req = new SelectCurChildren(); req.childrenGuid = ChildData.GetChildByIndex(_CurSelectChildIndex).guid; req.SendMsg(); } public void InitBtnState() { _FollowBtn.SetActive(ChildData.GetChildByIndex(_CurSelectChildIndex).guid != GameManager.gameManager.PlayerDataPool.ChildData.CurCarryChildData.childGuid); _CancelFollowBtn.SetActive(ChildData.GetChildByIndex(_CurSelectChildIndex).guid == GameManager.gameManager.PlayerDataPool.ChildData.CurCarryChildData.childGuid); } public void IsInitEmbyroPanel() { if(ChildData.GetChildByIndex(_CurSelectChildIndex).basic.embryoEndtime > GlobalData.ServerAnsiTime) { _FollowBtn.SetActive(false); _CancelFollowBtn.SetActive(false); } else { InitBtnState(); } } void InitNameAndModelPanel() { //名称 战力 _CurChildGuid = ChildData.GetChildByIndex(_CurSelectChildIndex) == null ? -1 : ChildData.GetChildByIndex(_CurSelectChildIndex).guid; if (ChildData.GetChildByIndex(_CurSelectChildIndex) != null) { if (ChildData.GetChildByIndex(_CurSelectChildIndex).basic.embryoEndtime > GlobalData.ServerAnsiTime) { _ChildName.text = ""; } else { _ChildName.text = ChildData.GetChildByIndex(_CurSelectChildIndex) == null ? "" : ChildData.GetChildByIndex(_CurSelectChildIndex).basic.name; } } _ChildCombatVal.text = ChildData.GetChildByIndex(_CurSelectChildIndex) == null ? "0" : ChildData.GetChildByIndex(_CurSelectChildIndex).basic.power.ToString(); if (ChildData.GetChildByIndex(_CurSelectChildIndex) == null) return; _ModelEffectlCtr.ShowChild(_CurSelectChildIndex); } void InitAttrPanel() { if(ChildData.GetChildByIndex(_CurSelectChildIndex) == null) { for (int index = 0; index < _ChildAttrItemList.Count; index++) _ChildAttrItemList[index].gameObject.SetActive(false); return; } for (int index = 0; index < ChildData.GetChildByIndex(_CurSelectChildIndex).attr.attrList.Count && index < _ChildAttrItemList.Count; index++) { _ChildAttrItemList[index].gameObject.SetActive(true); _ChildAttrItemList[index].InitAttrInfo(ChildData.GetChildByIndex(_CurSelectChildIndex).attr.attrList[index].attrId, int.Parse(ChildData.GetChildByIndex(_CurSelectChildIndex).attr.attrList[index].attrValue.ToString())); } for(int index = ChildData.GetChildByIndex(_CurSelectChildIndex).attr.attrList.Count; index < _ChildAttrItemList.Count; index++) { _ChildAttrItemList[index].gameObject.SetActive(false); } } void InitInteractionPanel() { _TodayPreGrowthVal.text = ChildData.GetChildByIndex(_CurSelectChildIndex) == null ? "0" : ChildData.GetChildByIndex(_CurSelectChildIndex).interact.expectExp.ToString(); //获取上限 var childParamTab = TableManager.GetChildrenParaByID(0, 0); if(childParamTab == null) { Debug.LogError("childParamTab is null"); return; } _ChildCleanVal.text = (ChildData.GetChildByIndex(_CurSelectChildIndex) == null ? 0 : ChildData.GetChildByIndex(_CurSelectChildIndex).interact.curClean) + "/" + childParamTab.MaxClean; _ChildFoodVal.text = (ChildData.GetChildByIndex(_CurSelectChildIndex) == null ? 0 : ChildData.GetChildByIndex(_CurSelectChildIndex).interact.curSatiety) + "/" + childParamTab.MaxSatiety; _ChildMoodVal.text = (ChildData.GetChildByIndex(_CurSelectChildIndex) == null ? 0 : ChildData.GetChildByIndex(_CurSelectChildIndex).interact.curMood) + "/" + childParamTab.MaxMood; _ChildHealthVal.text = (ChildData.GetChildByIndex(_CurSelectChildIndex) == null ? 0 : ChildData.GetChildByIndex(_CurSelectChildIndex).interact.curHealth) + "/" + childParamTab.MaxHealth; var adId = ChildData.GetChildByIndex(_CurSelectChildIndex).randomEvent.reserved; Tab_ChildrenAdventure charAdventureTab = null; if (adId != -1) { charAdventureTab = TableManager.GetChildrenAdventureByID(adId, 0); } //设置剩余互动次数 for(int index = 0; index < _RemainInteracTimes.Count; index++) { if(ChildData.GetChildByIndex(_CurSelectChildIndex) == null) { _RemainInteracTimes[index].text = "0"; } else { if (charAdventureTab != null && charAdventureTab.InteractType == (index + 1)) { _RemainInteracTimes[index].text = ChildData.GetChildByIndex(_CurSelectChildIndex) == null ? "0" : (Math.Max(ChildData.GetChildByIndex(_CurSelectChildIndex).interact.remainTimes, 0) + 1) + ""; } else { _RemainInteracTimes[index].text = ChildData.GetChildByIndex(_CurSelectChildIndex) == null ? "0" : Math.Max(ChildData.GetChildByIndex(_CurSelectChildIndex).interact.remainTimes, 0) + ""; } _RedIconList[index].SetActive(int.Parse(_RemainInteracTimes[index].text) > 0); } } //成长阶段描述 var childSkillTab = TableManager.GetChildrenLevelUpByID(ChildData.GetChildByIndex(_CurSelectChildIndex) == null ? 1 : ChildData.GetChildByIndex(_CurSelectChildIndex).basic.curLevel, 0); if(childSkillTab == null) { Debug.LogError("ChildrenLevelUp is null : " + ChildData.GetChildByIndex(_CurSelectChildIndex) == null ? 1 : ChildData.GetChildByIndex(_CurSelectChildIndex).basic.curLevel); } var childStateTypeTab = TableManager.GetChildrenStateTypeByID(childSkillTab.CurStateType, 0); if(childStateTypeTab == null) { }else { _GrowthStateDescText.EnsureVal(childStateTypeTab.StateDesc); } //亲密度 _CloseVal.text = (ChildData.GetChildByIndex(_CurSelectChildIndex) == null ? 0 : ChildData.GetChildByIndex(_CurSelectChildIndex).basic.intimacy) + ""; //Slider _ChildGrowthSlider.value = ChildData.GetChildByIndex(_CurSelectChildIndex) == null ? 0 : (float)ChildData.GetChildByIndex(_CurSelectChildIndex).basic.curExp / (float)childSkillTab.ExpNeed; _ChildGrowthSliderVal.text = ChildData.GetChildByIndex(_CurSelectChildIndex) == null ? "0" : ChildData.GetChildByIndex(_CurSelectChildIndex).basic.curExp + "/" + childSkillTab.ExpNeed; } public void InitAdventureDesc() { _IsShowAdventurePop = false; var childData = ChildData.GetChildByIndex(_CurSelectChildIndex); if (childData == null) return; if (childData.randomEvent.reserved == -1) return; var childAdventureTab = TableManager.GetChildrenAdventureByID(childData.randomEvent.reserved, 0); if (childAdventureTab == null) return; _IsShowAdventurePop = true; SetChildChats(StrDictionary.GetClientDictionaryString("#{" + childAdventureTab.PopStrId + "}")); } void InitStudyState() { if(ChildData.GetChildByIndex(_CurSelectChildIndex) == null) { _ChildStatePanel.SetActive(false); return; } if(ChildData.GetChildByIndex(_CurSelectChildIndex).study.studyingType != 0) { _ChildStatePanel.SetActive(true); var strId = 86800 + ChildData.GetChildByIndex(_CurSelectChildIndex).study.studyingType - 1; _ChildStateDescText.text = StrDictionary.GetClientDictionaryString("#{" + strId + "}"); _ChildStateRemainTimeText.StartCountTime(ChildData.GetChildByIndex(_CurSelectChildIndex).study.studyingEndtime + 60, OnStudyFinishCallBack); } else { _ChildStatePanel.SetActive(false); } } public void OnStudyFinishCallBack() { _ChildStatePanel.SetActive(false); } //使用增长经验的道具 public void OnGrowthItemBtn() { var childParaTab = TableManager.GetChildrenParaByID(0, 0); if (childParaTab == null) return; List itemList = new List(); for(int index = 0; index < childParaTab.getIncGrowthItemIdCount(); index++) { if (!itemList.Contains(childParaTab.GetIncGrowthItemIdbyIndex(index))) itemList.Add(childParaTab.GetIncGrowthItemIdbyIndex(index)); } if(itemList.Count < 1) { Debug.LogError("Growth itemidList is null, check childPara table"); return; } ChildItemCtrBase.ShowItemBase(itemList); } //取消跟随 public void OnCancelFollowBtn() { if(GameManager.gameManager.PlayerDataPool.ChildData.CurCarryChildData.childGuid == -1) { Debug.LogError("CurCarry child guid is -1, can't cancel follow!"); //这种神奇的BUG万一遇到了呢. InitBtnState(); return; } ReqChildrenCancelFollow req = new ReqChildrenCancelFollow(); req.childrenGuid = GameManager.gameManager.PlayerDataPool.ChildData.CurCarryChildData.childGuid; req.SendMsg(); } public void RefreshSingleChild(CNode info) { if (info.guid == ChildData.GetChildByIndex(_CurSelectChildIndex).guid) ShowChildByIndex(_CurSelectChildIndex); } public void OnHelpBtn() { MessageHelpLogic.ShowHelpMessage(75); } }