using System; using System.Linq; using Core.Language; using Excel2Json; using Fort23.UTool; namespace Fort23.Mono { [UIBinding(prefab = "PlacesInfoWidget")] public partial class PlacesInfoWidget : UIComponent { private AccountFileInfo.SmallPlacesData currentSmallPlacesData; private AccountFileInfo.SmallPlacesData lastSmallPlacesData; private SmallPlacesConfig smallPlacesConfig; private Action callBack; private void Init() { } public override void AddEvent() { } public override void DelEvent() { } public override void AddButtonEvent() { Btn_Qianwang.onClick.AddListener(async () => { if (smallPlacesConfig.ID == 0) return; SmallPlacesConfig lastSmallPlacesConfig = ConfigComponent.Instance.Get(smallPlacesConfig.ID - 1); if (smallPlacesConfig.ID > 1 && (lastSmallPlacesData == null || lastSmallPlacesData.completionEventCount < lastSmallPlacesConfig.CompletionEventCount)) { TipMessagePanel.OpenTipMessagePanel( LanguageManager.Instance.Text(10375, lastSmallPlacesConfig.CompletionEventCount)); return; } if (lastSmallPlacesConfig.UnlockEnvetid != 0) { AccountFileInfo.EventList eventList = AccountFileInfo.Instance.playerData.completeEvents.FirstOrDefault(ce => ce.eventID == lastSmallPlacesConfig.UnlockEnvetid); EventConfig eventConfig = ConfigComponent.Instance.Get(lastSmallPlacesConfig.UnlockEnvetid); if (eventList == null || !eventList.isCompleted) { TipMessagePanel.OpenTipMessagePanel( LanguageManager.Instance.Text(10376, LanguageManager.Instance.Text(eventConfig.EventName))); return; } } if (smallPlacesConfig.ID == PlayerManager.Instance.CurrentsmallPlaces.id) { await UIManager.Instance.HideUIUIPanel(); await UIManager.Instance.HideUIUIPanel(); return; } PlacesInfoPanel placesInfoPanel = UIManager.Instance.GetComponent(); if (placesInfoPanel != null && !placesInfoPanel.IsClose) { placesInfoPanel.isChange = true; } SmallPlacesConfig currentSmallPlacesConfig = ConfigComponent.Instance.Get(PlayerManager.Instance.CurrentsmallPlaces.id); await UIManager.Instance.HideUIUIPanel(); await UIManager.Instance.HideUIUIPanel(); await PlayerManager.Instance.ChangeMap(smallPlacesConfig.ID); if (currentSmallPlacesConfig.PlacesId == smallPlacesConfig.PlacesId) { PlacesChangeInfoPanel placesChangeInfoPanel = await PlacesChangeInfoPanel.OpenPanel(smallPlacesConfig.ID); await placesChangeInfoPanel.UIClosed(); } else { BigPlacesChangeInfoPanel bigPlacesChangeInfoPanel = await BigPlacesChangeInfoPanel.OpenPanel(smallPlacesConfig.PlacesId); await bigPlacesChangeInfoPanel.UIClosed(); } callBack?.Invoke(true); callBack = null; }); Btn_Jiesuo.onClick.AddListener(async () => { if (smallPlacesConfig.ID == 0) return; //解锁下一个地图 if (currentSmallPlacesData == null && IsSmallPlacesDataUlock(smallPlacesConfig.ID)) { PlacesInfoPanel placesInfoPanel = UIManager.Instance.GetComponent(); if (placesInfoPanel != null && !placesInfoPanel.IsClose) { placesInfoPanel.isChange = true; } await UIManager.Instance.HideUIUIPanel(); await UIManager.Instance.HideUIUIPanel(); SmallPlacesConfig currentSmallPlacesConfig = ConfigComponent.Instance.Get(PlayerManager.Instance.CurrentsmallPlaces.id); //切换下一个地图 await PlayerManager.Instance.ChangeMap(smallPlacesConfig.ID); if (currentSmallPlacesConfig.PlacesId == smallPlacesConfig.PlacesId) { PlacesChangeInfoPanel placesChangeInfoPanel = await PlacesChangeInfoPanel.OpenPanel(smallPlacesConfig.ID); await placesChangeInfoPanel.UIClosed(); } else { BigPlacesChangeInfoPanel bigPlacesChangeInfoPanel = await BigPlacesChangeInfoPanel.OpenPanel(smallPlacesConfig.PlacesId); await bigPlacesChangeInfoPanel.UIClosed(); } callBack?.Invoke(true); callBack = null; } }); } public void CustomInit(int smallPlacesId, Action callBack) { this.callBack = callBack; smallPlacesConfig = ConfigComponent.Instance.Get(smallPlacesId); Text_Name.text = LanguageManager.Instance.Text(smallPlacesConfig.placeName); Text_Desc.text = LanguageManager.Instance.Text(smallPlacesConfig.placeDesc); lastSmallPlacesData = PlayerManager.Instance.GetSmallPlacesData(smallPlacesConfig.ID - 1); currentSmallPlacesData = PlayerManager.Instance.GetSmallPlacesData(smallPlacesConfig.ID); Btn_Qianwang.gameObject.SetActive(PlayerManager.Instance.CurrentsmallPlaces.id != smallPlacesConfig.ID); Icon_DIdian.gameObject.SetActive(PlayerManager.Instance.CurrentsmallPlaces.id == smallPlacesConfig.ID); Icon_Places.icon_name = smallPlacesConfig.placeIcon; bool isUlock = IsSmallPlacesDataUlock(smallPlacesConfig.ID); if (currentSmallPlacesData == null && isUlock) { Text_Tips.text = ""; Icon_Marsk.gameObject.SetActive(true); Btn_Jiesuo.gameObject.SetActive(true); } else if (!isUlock) { Icon_Marsk.gameObject.SetActive(true); Text_Tips.text = GetSmallPlacesDataTips(smallPlacesConfig.ID); Btn_Jiesuo.gameObject.SetActive(false); } else { Icon_Marsk.gameObject.SetActive(false); Btn_Jiesuo.gameObject.SetActive(false); } } private string GetSmallPlacesDataTips(int id) { SmallPlacesConfig smallPlacesConfig = ConfigComponent.Instance.Get(id); AccountFileInfo.SmallPlacesData currentSmallPlacesData = PlayerManager.Instance.GetSmallPlacesData(smallPlacesConfig.ID-1); if (currentSmallPlacesData == null) { return LanguageManager.Instance.Text(10377); } AccountFileInfo.SmallPlacesData lastSmallPlacesData = PlayerManager.Instance.GetSmallPlacesData(smallPlacesConfig.ID - 1); SmallPlacesConfig lastSmallPlacesConfig = ConfigComponent.Instance.Get(smallPlacesConfig.ID - 1); if (smallPlacesConfig.ID > 1 && (lastSmallPlacesData == null || lastSmallPlacesData.completionEventCount < lastSmallPlacesConfig.CompletionEventCount)) { return LanguageManager.Instance.Text(10375, lastSmallPlacesConfig.CompletionEventCount); } if (lastSmallPlacesConfig.UnlockEnvetid != 0) { AccountFileInfo.EventList eventList = AccountFileInfo.Instance.playerData.completeEvents.FirstOrDefault(ce => ce.eventID == lastSmallPlacesConfig.UnlockEnvetid); if (eventList == null || !eventList.isCompleted) { EventConfig eventConfig = ConfigComponent.Instance.Get(lastSmallPlacesConfig.UnlockEnvetid); return LanguageManager.Instance.Text(10376, LanguageManager.Instance.Text(eventConfig.EventName)); } } return ""; } private bool IsSmallPlacesDataUlock(int id) { AccountFileInfo.SmallPlacesData lastSmallPlacesData = PlayerManager.Instance.GetSmallPlacesData(id - 1); SmallPlacesConfig lastSmallPlacesConfig = ConfigComponent.Instance.Get(id - 1); if (id > 1 && (lastSmallPlacesData == null || lastSmallPlacesData.completionEventCount < lastSmallPlacesConfig.CompletionEventCount)) { return false; } if (lastSmallPlacesConfig.UnlockEnvetid != 0) { AccountFileInfo.EventList eventList = AccountFileInfo.Instance.playerData.completeEvents.FirstOrDefault(ce => ce.eventID == lastSmallPlacesConfig.UnlockEnvetid); if (eventList == null || !eventList.isCompleted) { return false; } } return true; } } }