| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478 | using System.Collections.Generic;using System.Linq;using Core.Audio;using Core.Language;using Excel2Json;using Fort23.Core;using Fort23.UTool;using GameLogic.Combat;using GameLogic.Combat.CombatTool;using UnityEngine;namespace Fort23.Mono{    [UIBinding(prefab = "MainPanel")]    public partial class MainPanel : UIPanel    {        bool isShowSkillPanel = false;        // private ShengShiEventWidget shengShiEventWidget;        List<int> moRen = new List<int>() { 1001, 1002 };        List<EnergyWidget> widgets = new List<EnergyWidget>();        List<ShengShiConditionWidget> _shengShiConditionWidgets = new List<ShengShiConditionWidget>();        private void Init()        {            isAddStack = true;            IsShowAppBar = true;        }        protected override void AddEvent()        {            EventManager.Instance.AddEventListener(CustomEventType.ShengShiOnClick, ShengShiOnClick);            EventManager.Instance.AddEventListener(CustomEventType.CompleteEvent, CompleteEvent);            EventManager.Instance.AddEventListener(CustomEventType.CompleteUpdate, CompleteUpdate);            EventManager.Instance.AddEventListener(CustomEventType.RemoveEvent, RemoveEvent);            EventManager.Instance.AddEventListener(CustomEventType.ChangeMap, ChangeMapEvent);            EventManager.Instance.AddEventListener(CustomEventType.DaoYouCounUpdate, DaoYouCounUpdate);            EventManager.Instance.AddEventListener(CustomEventType.AlterName, AlterName);        }        private void DaoYouCounUpdate(IEventData e)        {            UpdateDaoYouCoun();        }        public async override CTask GetFocus()        {            await AppBarPanel.OpenPanel(this);            TitlePanel.ClosePanel();            base.GetFocus();            CustomInit();        }        public async void CustomInit()        {            if (AccountFileInfo.Instance.playerData.isTiggerPlot)            {                if (PlayerManager.Instance.PlayerName == "")                {                    AlterNamePanel alterNamePanel = await AlterNamePanel.OpenPanel();                    await alterNamePanel.UIClosed();                }                if (PlayerGuideManager.Instance.GuideIsCanDo(1))                {                    await PlayerGuideManager.Instance.SetGuid(1);                }                if (PlayerGuideManager.Instance.GuideIsCanDo(4))                {                    await PlayerGuideManager.Instance.SetGuid(4);                }            }        }        private void RemoveEvent(IEventData e)        {            Text_EventNum.text = EventSystemManager.Instance.GetShenShiCount().ToString();            CreatShengShiEvent();            ChagneShenshiBtnActive();        }        private void CompleteUpdate(IEventData e)        {            ChangeMap(null);            Text_EventNum.text = EventSystemManager.Instance.GetShenShiCount().ToString();            // fx_ui_renwu_chuxian.gameObject.SetActive(true);            // fx_ui_renwu_chuxian.Play();            CreatShengShiEvent();            ChagneShenshiBtnActive();            Slider_SmallJD.value = PlayerManager.Instance.CurrentsmallPlaces.completionEventCount;            SmallPlacesConfig smallPlacesConfig =                ConfigComponent.Instance.Get<SmallPlacesConfig>(PlayerManager.Instance.CurrentsmallPlaces.id);            if (PlayerManager.Instance.CurrentsmallPlaces.completionEventCount ==                smallPlacesConfig.CompletionEventCount)            {                AudioManager.Instance.PlayAudio("ui_jinduwancheng");            }            PlayEventCompletedEfx();        }        private void CompleteEvent(IEventData e)        {            PlayEventCompletedEfx();            fx_ui_renwu_chuxian.gameObject.SetActive(true);            fx_ui_renwu_chuxian.Play();        }        public void UpdateDaoYouCoun()        {            int count = AccountFileInfo.Instance.playerData.daoYouGuaiJiDatas.Count;            // foreach (var keyValuePair in AccountFileInfo.Instance.playerData.daoYouGuaiJiDatas)            // {            //     count += keyValuePair.Value.Count;            // }            if (count > 0)            {                Icon_Daoyou.gameObject.SetActive(true);                Text_DaoyouCount.text = count.ToString();            }            else            {                Icon_Daoyou.gameObject.SetActive(false);            }        }        private void ChagneShenshiBtnActive()        {            // Btn_Event.gameObject.SetActive(event > 0);        }        protected override void DelEvent()        {            EventManager.Instance.RemoveEventListener(CustomEventType.CompleteEvent, CompleteEvent);            EventManager.Instance.RemoveEventListener(CustomEventType.CompleteUpdate, CompleteUpdate);            EventManager.Instance.RemoveEventListener(CustomEventType.RemoveEvent, RemoveEvent);            EventManager.Instance.RemoveEventListener(CustomEventType.ShengShiOnClick, ShengShiOnClick);            EventManager.Instance.RemoveEventListener(CustomEventType.ChangeMap, ChangeMapEvent);            EventManager.Instance.RemoveEventListener(CustomEventType.DaoYouCounUpdate, DaoYouCounUpdate);        }        public override void AddButtonEvent()        {            Btn_Chat.onClick.AddListener(() => { ChatPanel.OpenPanel(); });            CameraSelect.onValueChanged.AddListener(CameraSelect_onValueChanged);            Btn_ChangeMap.onClick.AddListener(() =>            {                SmallPlacesConfig smallPlacesConfig =                    ConfigComponent.Instance.Get<SmallPlacesConfig>(PlayerManager.Instance.CurrentsmallPlaces.id);                PlacesInfoPanel.OpenPanel(smallPlacesConfig.PlacesId, null);            });            Btn_Event.onClick.AddListener(() =>            {                if (PlayerGuideManager.Instance.curPhase == 1)                {                    return;                }                EventSystemManager.Instance.isOpenUi = true;                DivineSenceEventPreviewPanel.OpenPanel();            });            Btn_Map.onClick.AddListener(() => { LevelChoosePanel.OpenPanel(); });            // Btn_DaoYou.onClick.AddListener(() => { DaoYouPanel.OpenPanel(); });            //            // Btn_Tower.onClick.AddListener(() => { TowerPanel.OpenPanel(1); });            Btn_QianKunDai.onClick.AddListener(() => { QiankundaiPanel.OpenPanel(); });            Btn_StartEvent.onClick.AddListener(async () =>            {                if (PlayerGuideManager.Instance.curPhase == 3)                {                    return;                }                if (PlayerGuideManager.Instance.GuideIsCanDo(1, 3))                {                    PlayerGuideManager.Instance.NextGuide();                }                AccountFileInfo.EventList eventList = AccountFileInfo.Instance.playerData.eventList.FirstOrDefault(e =>                    e.guid == AccountFileInfo.Instance.playerData.CurrentZuiZhongEventListId);                EventConfig eventConfig = ConfigComponent.Instance.Get<EventConfig>(eventList.eventID);                if (eventConfig.EventTriggerType == 4)                {                    if (eventList.isCompleted1)                    {                        EventSystemManager.Instance.CompleteEvent(eventList);                        return;                    }                }                if (eventList != null)                {                    EventSystemManager.Instance.CancelEvent();                    if (EventSystemManager.Instance.isTriggerEvent)                        return;                    if (eventList.isCompleted)                        return;                    await EventSystemManager.Instance.TriggerEvent(eventList);                }            });            Btn_Daoyou.onClick.AddListener(() => { DaoYouGuaJiPanel.OpenPanel(); });            Btn_Box.onClick.AddListener(() => { BoxPanel.OpenBoxPanel(); });            Btn_PlayerName.onClick.AddListener(async () => { AlterNamePanel.OpenPanel(); });        }        public override CTask<bool> AsyncInit(object[] uiData)        {            return base.AsyncInit(uiData);        }        public async override CTask Show()        {            await base.Show();            Text_PlayerName.text = PlayerManager.Instance.PlayerName;            SmallPlacesConfig smallPlacesConfig =                ConfigComponent.Instance.Get<SmallPlacesConfig>(PlayerManager.Instance.CurrentsmallPlaces.id);            Slider_SmallJD.maxValue = smallPlacesConfig.CompletionEventCount;            Slider_SmallJD.value = PlayerManager.Instance.CurrentsmallPlaces.completionEventCount;            ChagneShenshiBtnActive();            CreatShengShiEvent();            ChangeMap(null);            UpdateDaoYouCoun();            bool isHIde = false;            foreach (var skillInfo in PlayerManager.Instance.GongFaControl.allUseSkill)            {                if (skillInfo != null)                {                    isHIde = true;                    break;                }            }            if (!isHIde && !isShowSkillPanel)            {                isShowSkillPanel = true;                SkillSelectPanel.OpenSkillSelectPanel();            }            CameraSelect.value = 0.2f;            Text_EventNum.text = EventSystemManager.Instance.GetShenShiCount().ToString();            HeroPowerUpConfig[] heroPowerUpConfigs = ConfigComponent.Instance.GetAll<HeroPowerUpConfig>().ToList()                .Where(hpc =>                    hpc.jingjie1 == PlayerManager.Instance.myHero.powerUpConfig.jingjie1 &&                    hpc.jingjie2 == PlayerManager.Instance.myHero.powerUpConfig.jingjie2).ToArray();            int allexp = 0;            foreach (var heroPowerUpConfig in heroPowerUpConfigs)            {                allexp += heroPowerUpConfig.levelUpExp;            }            int currentMiao = (int)((TimeHelper.ClientNow() - PlayerManager.Instance.myHero.heroData.upTime) / 1000);            float heroAllexp = currentMiao * PlayerManager.Instance.myHero.powerUpConfig.AutoXiuwei;            heroAllexp = PlayerManager.Instance.myHero.heroData.exp + heroAllexp;            int bl = (int)((heroAllexp / allexp) * 100);            Text_jingjie.text =                LanguageManager.Instance.Text(PlayerManager.Instance.myHero.powerUpConfig.jingjieLanIDs[0]) +                LanguageManager.Instance.Text(PlayerManager.Instance.myHero.powerUpConfig.jingjieLanIDs[1]) + " " +                bl + "%";            foreach (var energyWidget in widgets)            {                UIManager.Instance.DormancyGComponent(energyWidget);            }            widgets.Clear();            foreach (var item in moRen)            {                EnergyWidget energyWidget =                    await UIManager.Instance.CreateGComponent<EnergyWidget>(null, Group_ResourceBar);                energyWidget.CustomInit(item);                widgets.Add(energyWidget);            }            PlayEventCompletedEfx();            // UpdateTaskInfo();        }        private void PlayEventCompletedEfx()        {            AccountFileInfo.EventList eventList = AccountFileInfo.Instance.playerData.eventList.FirstOrDefault(e =>                e.guid == AccountFileInfo.Instance.playerData.CurrentZuiZhongEventListId);            if (eventList != null)            {                var eventConfig = ConfigComponent.Instance.Get<EventConfig>(eventList.eventID);                if (eventConfig.EventTriggerType == 4)                {                    if (eventList.isCompleted1)                    {                        fx_ui_renwu_wancheng_loop.gameObject.SetActive(true);                        fx_ui_renwu_wancheng_loop.Play();                    }                }            }        }        private void AlterName(IEventData e)        {            Text_PlayerName.text = PlayerManager.Instance.PlayerName;        }        public async void ChangeMapEvent(IEventData e)        {            ChangeMap(e);            // SmallPlacesConfig smallPlacesConfig =            //     ConfigComponent.Instance.Get<SmallPlacesConfig>(PlayerManager.Instance.CurrentsmallPlaces.id);            //            // PlacesConfig placesConfig =            //     ConfigComponent.Instance.Get<PlacesConfig>(smallPlacesConfig.PlacesId);            // await TimerComponent.Instance.WaitAsync(500);            // PlacesChangeInfoPanel.OpenPanel(smallPlacesConfig.PlacesId);        }        public void ChangeMap(IEventData e)        {            SmallPlacesConfig smallPlacesConfig =                ConfigComponent.Instance.Get<SmallPlacesConfig>(PlayerManager.Instance.CurrentsmallPlaces.id);            PlacesConfig placesConfig =                ConfigComponent.Instance.Get<PlacesConfig>(smallPlacesConfig.PlacesId);            Text_bigMapName.text = LanguageManager.Instance.Text(placesConfig.placeName);            Text_ExplorationProgress.text = LanguageManager.Instance.Text(10302,                LanguageManager.Instance.Text(placesConfig.placeName),                LanguageManager.Instance.Text(smallPlacesConfig.placeName));            Slider_SmallJD.maxValue = smallPlacesConfig.CompletionEventCount;            Slider_SmallJD.value = PlayerManager.Instance.CurrentsmallPlaces.completionEventCount;        }        private void CameraSelect_onValueChanged(float value)        {            if (CombatController.currActiveCombat == null ||                CombatController.currActiveCombat.CombatCameraControllder == null)            {                return;            }            CombatController.currActiveCombat.CombatCameraControllder.CameraSelect_onValueChanged(value);        }        private void ShengShiOnClick(IEventData e)        {            Text_EventNum.text = EventSystemManager.Instance.GetShenShiCount().ToString();            ChagneShenshiBtnActive();            CreatShengShiEvent();        }        public async void CreatShengShiEvent()        {            foreach (var shengShiConditionWidget in _shengShiConditionWidgets)            {                UIManager.Instance.DormancyGComponent(shengShiConditionWidget);            }            _shengShiConditionWidgets.Clear();            AccountFileInfo.EventList eventList = AccountFileInfo.Instance.playerData.eventList.FirstOrDefault(e =>                e.guid == AccountFileInfo.Instance.playerData.CurrentZuiZhongEventListId);            if (eventList != null)            {                var randomEventConfig = ConfigComponent.Instance.Get<EventConfig>(eventList.eventID);                Text_EventName.text = LanguageManager.Instance.Text(randomEventConfig.EventName);                Text_EventTag.text = EventHelper.GetEventType(randomEventConfig.EventTag);                AccountFileInfo.EventLinkData eventLinkData =                    eventList.eventLinks.FirstOrDefault(el => el.eventLinkId == eventList.curStep);                EventLinkConfig evenkConfig = ConfigComponent.Instance.Get<EventLinkConfig>(eventLinkData.eventLinkId);                if (eventLinkData != null && eventLinkData.eventConditions != null &&                    eventLinkData.eventConditions.Count > 0)                {                    foreach (var eventConditionData in eventLinkData.eventConditions)                    {                        ShengShiConditionWidget shengShiConditionWidget =                            await UIManager.Instance.CreateGComponent<ShengShiConditionWidget>(null,                                EventConditionRoot);                        shengShiConditionWidget.CustomInit(eventConditionData);                        _shengShiConditionWidgets.Add(shengShiConditionWidget);                    }                }                else if (evenkConfig.EventConditionMessage != 0)                {                    ShengShiConditionWidget shengShiConditionWidget =                        await UIManager.Instance.CreateGComponent<ShengShiConditionWidget>(null, EventConditionRoot);                    shengShiConditionWidget.CustomInit(                        LanguageManager.Instance.Text(evenkConfig.EventConditionMessage));                    _shengShiConditionWidgets.Add(shengShiConditionWidget);                }            }            else            {                Text_EventName.text = "";                Text_EventTag.text = "";            }        }        // [CustomMethod(CustomMethodType.Update)]        // public void Update()        // {        //     if (Input.GetKeyDown(KeyCode.Y))        //     {        //         EventSystemManager.Instance.DetectRandomEvents();        //     }        //        //        //     int currentMiao = (int)((TimeHelper.ClientNow() - PlayerManager.Instance.myHero.heroData.upTime) / 1000);        //        //     float allexp = currentMiao * PlayerManager.Instance.myHero.powerUpConfig.AutoXiuwei;        //        //     Slider_Exp.value = PlayerManager.Instance.myHero.heroData.exp + allexp;        // }        public async static CTask<MainPanel> OpenPanel()        {            MainPanel mainPanel = await UIManager.Instance.LoadAndOpenPanel<MainPanel>(null);            return mainPanel;        }        public async override CTask Close()        {            foreach (var shengShiConditionWidget in _shengShiConditionWidgets)            {                UIManager.Instance.DormancyGComponent(shengShiConditionWidget);            }            _shengShiConditionWidgets.Clear();            foreach (var energyWidget in widgets)            {                UIManager.Instance.DormancyGComponent(energyWidget);            }            widgets.Clear();            await base.Close();        }    }}
 |