| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277 | using System;using System.Collections.Generic;using System.Linq;using Common.Utility.CombatEvent;using Core.Language;using Excel2Json;using Fort23.Core;using Fort23.Mono;using Fort23.UTool;using GameLogic.Bag;using GameLogic.Combat;using GameLogic.Combat.CombatTool;using GameLogic.Player;using UnityEngine;using Utility;using EventConfig = Excel2Json.EventConfig;using Random = UnityEngine.Random;public class EventSystemManager : Singleton<EventSystemManager>{    List<EventConfig> eventConfigs = new List<EventConfig>();    public AccountFileInfo.EventList CurrentEventList;    public bool isTriggerEvent;    List<DivineSenseConfig> divineSenseConfigs = new List<DivineSenseConfig>();    List<int> qualitys = new List<int>() { 1, 2, 3, 4, 5, 6 };    public bool isOpenUi;    Action onCompleteCallback;    public Map<int, List<EventConfig>> eventConfigsMap = new Map<int, List<EventConfig>>();    // public Map<int, AccountFileInfo.EventConditionData> EventConditionDataMap = new Map<int, AccountFileInfo.EventConditionData>();    public void CustomInit()    {        eventConfigs = ConfigComponent.Instance.GetAll<EventConfig>().ToList();        divineSenseConfigs = ConfigComponent.Instance.GetAll<DivineSenseConfig>().ToList();        foreach (var eventConfig in eventConfigs)        {            if (eventConfig.XiantuID != 0)            {                if (eventConfigsMap.ContainsKey(eventConfig.XiantuID))                {                    eventConfigsMap[eventConfig.XiantuID].Add(eventConfig);                }                else                {                    eventConfigsMap.Add(eventConfig.XiantuID, new List<EventConfig>() { eventConfig });                }            }        }        StaticUpdater.Instance.AddRenderUpdateCallBack(Update);        EventManager.Instance.AddEventListener(CustomEventType.DetectRandomEvent, RenfenceRandomEvent);        EventManager.Instance.AddEventListener(CustomEventType.AddItem, ItemUpdate);        EventManager.Instance.AddEventListener(CustomEventType.JingJieUpgrade, JingJieUpgrade);        EventManager.Instance.AddEventListener(CustomEventType.CancelEvent, Cancel);    }    private void Cancel(IEventData e)    {        CancelEvent();    }    private void JingJieUpgrade(IEventData e)    {        CeekEventCompletes(3, null);    }    private void ItemUpdate(IEventData e)    {        ItemUpdateData data = e as ItemUpdateData;        CeekEventCompletes(1, new[] { data.ItemInfo.itemID });        CeekEventCompletes(6, new[] { data.ItemInfo.itemID, data.Count });    }    private void RenfenceRandomEvent(IEventData e)    {        DetectRandomEvents();    }    private float timer = 0;    private void Update()    {        timer += Time.deltaTime;        if (timer > 1)        {            timer = 0;            HeroPowerUpConfig heroPowerUpConfig = PlayerManager.Instance.myHero.powerUpConfig;            if (AccountFileInfo.Instance.playerData.divineSensePoint < heroPowerUpConfig.ShenshiMax)            {                if (AccountFileInfo.Instance.playerData.todayDivineSensePoint <                    PlayerManager.Instance.gameConstantConfig.shenshiPointRecSPD[0])                {                    AccountFileInfo.Instance.playerData.todayDivineSensePoint +=                        PlayerManager.Instance.gameConstantConfig.shenshiPointRecSPD[1];                    AccountFileInfo.Instance.playerData.divineSensePoint +=                        PlayerManager.Instance.gameConstantConfig.shenshiPointRecSPD[1];                }                else                {                    AccountFileInfo.Instance.playerData.divineSensePoint +=                        PlayerManager.Instance.gameConstantConfig.shenshiPointRecSPD[2];                }                EventManager.Instance.Dispatch(CustomEventType.DivineSensePointChange, null);                AccountFileInfo.Instance.SavePlayerData();            }        }    }    public List<AccountFileInfo.EventList> UseDivinesense(int useCount, List<ItemInfo> useItems)    {        //使用神识先移除完成的事件        List<AccountFileInfo.EventList> removeEvents = new List<AccountFileInfo.EventList>();        foreach (var eventList in AccountFileInfo.Instance.playerData.eventList)        {            if (eventList.isCompleted)            {                removeEvents.Add(eventList);            }        }        foreach (var removeEvent in removeEvents)        {            AccountFileInfo.Instance.playerData.completeEvents.Add(removeEvent);            AccountFileInfo.Instance.playerData.eventList.Remove(removeEvent);        }        AccountFileInfo.Instance.SavePlayerData();        HeroPowerUpConfig heroPowerUpConfig = PlayerManager.Instance.myHero.powerUpConfig;        int count = (int)(AccountFileInfo.Instance.playerData.divineSensePoint /                          PlayerManager.Instance.gameConstantConfig.DetectEventCount);        if (count <= 0)        {            //神识值不够            return null;        }        int maxCount = heroPowerUpConfig.ShenshiMax / PlayerManager.Instance.gameConstantConfig.DetectEventCount;        count = count + GetShenShiCount() > maxCount ? maxCount - GetShenShiCount() : count;        if (useCount > count)        {            LogTool.Error("神识值不够");            return null;        }        CeekEventCompletes(8, new[] { 1 });        EventManager.Instance.Dispatch(CustomEventType.DivineSensePointChange, null);        var eventConfigs = DetectEvents(useCount, useItems);        if (eventConfigs == null || eventConfigs.Count == 0)        {            TipMessagePanel.OpenTipMessagePanel("没有可以触发的事件");            return default;        }        //扣除神识值 增加神识经验        int xiaoHao = eventConfigs.Count * PlayerManager.Instance.gameConstantConfig.DetectEventCount;        AccountFileInfo.Instance.playerData.divineSenseexp += xiaoHao;        AccountFileInfo.Instance.playerData.divineSensePoint -= xiaoHao;        // 神识升级逻辑        UpDivinesense();        AccountFileInfo.Instance.playerData.eventList.AddRange(eventConfigs);        UpdateZuizhongEventData();        AccountFileInfo.Instance.SavePlayerData();        return eventConfigs;    }    public void UpdateZuizhongEventData()    {        AccountFileInfo.EventList eventList = AccountFileInfo.Instance.playerData.eventList.FirstOrDefault(e =>            e.guid == AccountFileInfo.Instance.playerData.CurrentZuiZhongEventListId);        if (eventList == null || eventList.guid == 0)        {            var mainEventData = GetMainEventDta();            if (mainEventData != null)            {                AccountFileInfo.Instance.playerData.CurrentZuiZhongEventListId = mainEventData.guid;            }            else if (AccountFileInfo.Instance.playerData.eventList.Count > 0)            {                AccountFileInfo.Instance.playerData.CurrentZuiZhongEventListId =                    AccountFileInfo.Instance.playerData.eventList[0].guid;            }        }    }    private void UpDivinesense()    {        if (AccountFileInfo.Instance.playerData.divineSenseLevel >= divineSenseConfigs.Count)        {            return;        }        for (var i = AccountFileInfo.Instance.playerData.divineSenseLevel - 1; i < divineSenseConfigs.Count; i++)        {            if (AccountFileInfo.Instance.playerData.divineSenseexp >= divineSenseConfigs[i].exp)            {                AccountFileInfo.Instance.playerData.divineSenseexp -= divineSenseConfigs[i].exp;                AccountFileInfo.Instance.playerData.divineSenseLevel = divineSenseConfigs[i + 1].ID;            }        }        AccountFileInfo.Instance.SavePlayerData();    }    public int GetShenShiCount()    {        int count = 0;        foreach (var eventList in AccountFileInfo.Instance.playerData.eventList)        {            EventConfig eventConfig = ConfigComponent.Instance.Get<EventConfig>(eventList.eventID);            if (eventList == null || eventList.eventID == 0 || eventList.isCompleted ||                eventConfig.EventTriggerType == 4)                continue;            if (eventConfig.EventTriggerType != 5)            {                count++;            }        }        return count;    }    public bool BagIsEvent(int eventID)    {        foreach (var eventList in AccountFileInfo.Instance.playerData.eventList)        {            if (eventList.eventID == eventID)            {                return true;            }        }        return false;    }    public int GetBagEventCount(int eventID)    {        int count = 0;        foreach (var eventList in AccountFileInfo.Instance.playerData.eventList)        {            if (eventList.eventID == eventID)            {                count++;            }        }        return count;    }    // public bool IsRefenceEvent(int eventID)    // {    //     EventConfig eventConfig = ConfigComponent.Instance.Get<EventConfig>(eventID);    // }    public bool IsEventTrigger(int eventID)    {        foreach (var eventList in AccountFileInfo.Instance.playerData.completeEvents)        {            if (eventList.eventID == eventID)            {                return true;            }        }        return false;    }    private List<AccountFileInfo.EventList> DetectEvents(int eventCount, List<ItemInfo> useItems)    {        SmallPlacesConfig smallPlacesConfig =            ConfigComponent.Instance.Get<SmallPlacesConfig>(PlayerManager.Instance.CurrentsmallPlaces.id);        PlacesConfig bigMap = ConfigComponent.Instance.Get<PlacesConfig>(smallPlacesConfig.PlacesId);        DivineSenseConfig divineSenseConfig =            ConfigComponent.Instance.Get<DivineSenseConfig>(AccountFileInfo.Instance.playerData.divineSenseLevel);        LogTool.Log($"使用神识,神识等级:{AccountFileInfo.Instance.playerData.divineSenseLevel}");        List<AccountFileInfo.EventList> eventLists = new List<AccountFileInfo.EventList>();        //取消根据主线进度刷新啊支线任务        //现在改成优先刷新满足条件的支线任务然后判断概率是否刷新        //找出可以刷新的支线任务        // if (bigMap.ZhixianActivatedPercentage != null)        // {        //     List<EventConfig> zhiXianEvents = new List<EventConfig>();        //     for (var i = 0; i < bigMap.ZhixianActivatedPercentage.Length; i++)        //     {        //         if (PlayerManager.Instance.PlacesBl >= bigMap.ZhixianActivatedPercentage[i])        //         {        //             if (!BagIsEvent(bigMap.ZhixianID[i]) && !IsEventTrigger(bigMap.ZhixianID[i]) &&        //                 CanTriggerEvent(bigMap.ZhixianID[i]))        //             {        //                 zhiXianEvents.Add(ConfigComponent.Instance.Get<EventConfig>(bigMap.ZhixianID[i]));        //             }        //         }        //     }        //        //     foreach (var c in zhiXianEvents)        //     {        //         AccountFileInfo.EventList eventList = AddEvent(c.ID);        //         if (eventList != null)        //         {        //             eventLists.Add(eventList);        //             eventCount--;        //        //             if (eventCount == 0)        //             {        //                 return eventLists;        //             }        //         }        //     }        // }        for (int i = 0; i < eventCount; i++)        {            //刷新支线任务            List<EventConfig> zhiXianEvents = eventConfigs.Where(e =>                e.EventTriggerType == 6 && !BagIsEvent(e.ID) && !IsEventTrigger(e.ID) &&                e.SmallPlacesId == smallPlacesConfig.ID &&                eventLists.FirstOrDefault(el => el.eventID == e.ID) == null && CanTriggerEvent(e.ID)).ToList();            if (zhiXianEvents.Count > 0)            {                var zhixianEvnetConfig = zhiXianEvents[0];                int randomValueZhiXian = Random.Range(0, 101);                if (randomValueZhiXian <= zhixianEvnetConfig.RefreshProbability)                {                    AccountFileInfo.EventList eventList = AddEvent(zhixianEvnetConfig.ID);                    if (eventList != null)                    {                        eventLists.Add(eventList);                        LogTool.Log("刷新支线任务:id:" + zhixianEvnetConfig.ID);                        continue;                    }                }            }            int randomValue3 = Random.Range(0, 101);            //先刷事件关联的事件            if (randomValue3 <= PlayerManager.Instance.gameConstantConfig.RefreshRelevanceEventProbability)            {                bool isRefence = false;                foreach (var eventList in AccountFileInfo.Instance.playerData.eventList)                {                    foreach (var eventListEventLink in eventList.eventLinks)                    {                        foreach (var eventConditionData in eventListEventLink.eventConditions)                        {                            if (IsEvenkLinkComplete(eventConditionData))                                continue;                            EventConditionConfig eventConditionConfig =                                ConfigComponent.Instance.Get<EventConditionConfig>(eventConditionData.eventCondition);                            for (var i1 = 0; i1 < eventConditionConfig.RelatedEvents?.Length; i1++)                            {                                EventConfig eventConfig1 =                                    ConfigComponent.Instance.Get<EventConfig>(eventConditionConfig.RelatedEvents[i1]);                                int count = 0;                                foreach (var list in eventLists)                                {                                    if (list.eventID == eventConfig1.ID)                                    {                                        count++;                                    }                                }                                if (GetBagEventCount(eventConfig1.ID) + count >= eventConfig1.RefreshCount)                                {                                    continue;                                }                                int randomValue4 = Random.Range(0, 101);                                if (randomValue4 <= eventConfig1.RefreshProbability)                                {                                    var eventList1 = AddEvent(eventConfig1.ID);                                    if (eventList1 != null)                                    {                                        eventLists.Add(AddEvent(eventConfig1.ID));                                        isRefence = true;                                    }                                    else                                    {                                        LogTool.Error("管理事件没有刷新出来 id:" + eventConfig1.ID);                                    }                                    break;                                }                            }                        }                    }                }                if (isRefence)                    continue;            }            //概率            ItemInfo itemInfoType1 = null;            //类型            ItemInfo itemInfoType2 = null;            foreach (var itemInfo in useItems)            {                if (itemInfo.config.associateID == 6)                {                    itemInfoType1 = itemInfo;                }                else if (itemInfo.config.associateID == 7)                {                    itemInfoType2 = itemInfo;                }            }            float[] QualityBonusChance = divineSenseConfig.QualityBonusChance.ToArray();            if (itemInfoType1 != null)            {                QualityBonusChance[itemInfoType1.config.associateVlaue[0] - 1] *=                    itemInfoType1.config.associateVlaue[1];            }            //先掉落出品质            int quality = UtilTools.GetRandomByWeight(qualitys, QualityBonusChance);            // 获取通用事件            List<EventConfig> globalEvents = eventConfigs.Where(e =>                e.EventTriggerType == 1 && e.EventQuality == quality &&                eventLists.FirstOrDefault(el => el.eventID == e.ID) == null && CanTriggerEvent(e.ID) &&                CanEventType(e.ID, itemInfoType2)).ToList();            //场景特定事件            List<EventConfig> candidateEvents = eventConfigs.Where(e =>                bigMap.SpecialTaskID.Contains(e.ID) && e.EventQuality == quality &&                eventLists.FirstOrDefault(el => el.eventID == e.ID) == null && CanTriggerEvent(e.ID) &&                CanEventType(e.ID, itemInfoType2)).ToList();            if (candidateEvents.Count == 0 && globalEvents.Count == 0)            {                continue;            }            int randomValue1 = Random.Range(0, 101);            // 达到怪率刷新场景特定事件            //不然刷新通用事件(每个地图都可以刷的)            if (randomValue1 >= bigMap.DivineSenseGeneralProbability && candidateEvents.Count > 0)            {                int randomValue2 = Random.Range(0, candidateEvents.Count);                var eventList = AddEvent(candidateEvents[randomValue2].ID);                if (eventList != null)                {                    eventLists.Add(eventList);                }                else                {                    LogTool.Error("场景没有刷新出来 id:" + candidateEvents[randomValue2].ID);                }            }            else if (globalEvents.Count > 0)            {                List<int> quanzhong = new List<int>();                for (var i1 = 0; i1 < globalEvents.Count; i1++)                {                    quanzhong.Add(globalEvents[i1].RefreshProbability);                }                var eventconfig = UtilTools.GetRandomByWeight(globalEvents, quanzhong.ToArray());                // int randomValue2 = Random.Range(0, globalEvents.Count);                var eventList = AddEvent(eventconfig.ID);                if (eventList != null)                {                    eventLists.Add(eventList);                }                else                {                    LogTool.Error("通用事件没有刷新出来 id:" + eventconfig.ID);                }            }        }        if (eventLists.Count == 0)        {            LogTool.Error("没有可以触发的事件");            return null;        }        return eventLists;    }    //添加事件    public AccountFileInfo.EventList AddEvent(int eventID)    {        EventConfig eventConfig = ConfigComponent.Instance.Get<EventConfig>(eventID);        AccountFileInfo.EventList eventList = null;        if (eventConfig.ID == 0)        {            return null;        }        //主线任务只能刷一次        if (eventConfig.EventTriggerType == 4 || eventConfig.EventTriggerType == 6)        {            AccountFileInfo.EventList e =                AccountFileInfo.Instance.playerData.eventList.FirstOrDefault(e => e.eventID == eventID);            if (e == null)            {                e = AccountFileInfo.Instance.playerData.completeEvents.FirstOrDefault(e => e.eventID == eventID);                if (e == null)                {                    eventList = new AccountFileInfo.EventList();                    eventList.eventID = eventID;                }                else                {                    return null;                }                eventList.guid = IdGenerater.GenerateIdInt();                eventList.curStep = eventConfig.EventLinksId[0];                eventList.selectEventLinkIds.Add(eventConfig.EventLinksId[0]);                //记录英雄等级 神识刷出来的战斗等级不变                if (PlayerManager.Instance.myHero != null)                    eventList.heroLevel = PlayerManager.Instance.myHero.level.Value;            }        }        else        {            eventList = new AccountFileInfo.EventList();            eventList.eventID = eventID;            eventList.guid = IdGenerater.GenerateIdInt();            eventList.curStep = eventConfig.EventLinksId[0];            eventList.selectEventLinkIds.Add(eventConfig.EventLinksId[0]);            //记录英雄等级 神识刷出来的战斗等级不变            if (PlayerManager.Instance.myHero != null)                eventList.heroLevel = PlayerManager.Instance.myHero.level.Value;        }        //初始化神识链条,用于监听条件是否完成        if (eventList != null && eventConfig.EventType != 2)        {            foreach (var i in eventConfig.EventLinksId)            {                EventLinkConfig eventLinkConfig = ConfigComponent.Instance.Get<EventLinkConfig>(i);                AccountFileInfo.EventLinkData eventLinkData = new AccountFileInfo.EventLinkData();                eventLinkData.eventId = eventID;                eventLinkData.eventLinkId = i;                if (eventLinkConfig.ConditionId != null)                {                    foreach (var i1 in eventLinkConfig.ConditionId)                    {                        AccountFileInfo.EventConditionData                            eventConditionData = new AccountFileInfo.EventConditionData();                        eventConditionData.eventId = eventList.eventID;                        eventConditionData.eventCondition = i1;                        eventLinkData.eventConditions.Add(eventConditionData);                        //初始化先检测一些条件                        CeekTaskComplete(eventConditionData, 1, null);                        CeekTaskComplete(eventConditionData, 3, null);                    }                }                eventList.eventLinks.Add(eventLinkData);            }        }        return eventList;    }    /// <summary>    /// 触发随机事件    /// </summary>    public void DetectRandomEvents()    {        if (isTriggerEvent)            return;        if (isOpenUi)            return;        // 获取随机事件        List<EventConfig> randomEvents =            eventConfigs.Where(e => e.EventTriggerType == 2 && CanTriggerEvent(e.ID)).ToList();        if (randomEvents.Count == 0)        {            LogTool.Warning("没有可以刷新的事件");            return;        }        int idex = Random.Range(0, randomEvents.Count);        TriggerEvent(randomEvents[idex]);    }    /// <summary>    /// 挂机事件触发    /// </summary>    public void TriggerEvent(EventConfig evt)    {        if (isTriggerEvent)            return;        isTriggerEvent = true;        LogTool.Log($"触发事件: {evt.EventName} (ID: {evt.ID}, 品质: {evt.EventQuality})");        CombatDrive.Instance.CombatController.ChangeState(CombatController.idle);        AccountFileInfo.EventList eventList = AddEvent(evt.ID);        CurrentEventList = eventList;        DialogueManager.Instance.StartDialogue(eventList, evt.EventLinksId[0], evt.ID,            () => { CompleteEvent(evt.ID); });    }    /// <summary>    /// 其他类型事件触发    /// </summary>    public async CTask TriggerEvent(AccountFileInfo.EventList evt, Action oncompleteCallBack = null,        Action uiOpenOverCallBack = null)    {        // ChancleEvent();        if (isTriggerEvent)            return;        EventConfig eventConfig = ConfigComponent.Instance.Get<EventConfig>(evt.eventID);        SmallPlacesConfig smallPlacesConfig =            ConfigComponent.Instance.Get<SmallPlacesConfig>(PlayerManager.Instance.CurrentsmallPlaces.id);        if (eventConfig.SmallPlacesId > 0)        {            if (eventConfig.SmallPlacesId != PlayerManager.Instance.CurrentsmallPlaces.id)            {                AccountFileInfo.SmallPlacesData lastSmallPlacesData =                    PlayerManager.Instance.GetSmallPlacesData(eventConfig.SmallPlacesId - 1);                SmallPlacesConfig lastSmallPlacesConfig =                    ConfigComponent.Instance.Get<SmallPlacesConfig>(eventConfig.SmallPlacesId - 1);                SmallPlacesConfig currentSmallPlacesConfig =                    ConfigComponent.Instance.Get<SmallPlacesConfig>(eventConfig.SmallPlacesId);                if (currentSmallPlacesConfig.ID > 1 && (lastSmallPlacesData == null ||                                                        lastSmallPlacesData.completionEventCount <                                                        lastSmallPlacesConfig.CompletionEventCount))                {                    TipMessagePanel tipMessagePanel = await TipMessagePanel.OpenTipMessagePanel(                        LanguageManager.Instance.Text(10379,                            LanguageManager.Instance.Text(lastSmallPlacesConfig.placeName),                            lastSmallPlacesConfig.CompletionEventCount));                    if (PlayerGuideManager.Instance.GuideIsCanDo(3))                    {                        PlayerGuideManager.Instance.SetGuid(3);                    }                    return;                }                if (lastSmallPlacesConfig.UnlockEnvetid != 0)                {                    AccountFileInfo.EventList eventList =                        AccountFileInfo.Instance.playerData.completeEvents.FirstOrDefault(ce =>                            ce.eventID == lastSmallPlacesConfig.UnlockEnvetid);                    if (eventList == null || !eventList.isCompleted)                    {                        var econfig = ConfigComponent.Instance.Get<EventConfig>(lastSmallPlacesConfig.UnlockEnvetid);                        TipMessagePanel.OpenTipMessagePanel(LanguageManager.Instance.Text(10380,                            LanguageManager.Instance.Text(lastSmallPlacesConfig.placeName),                            LanguageManager.Instance.Text(econfig.EventName)));                        return;                    }                }                SmallPlacesConfig SmallPlacesConfig =                    ConfigComponent.Instance.Get<SmallPlacesConfig>(eventConfig.SmallPlacesId);                CTask<bool> cT = CTask<bool>.Create();                PlacesInfoPanel.OpenPanel(SmallPlacesConfig.PlacesId, (b) => { cT.SetResult(b); });                await cT;                if (eventConfig.SmallPlacesId != PlayerManager.Instance.CurrentsmallPlaces.id)                {                    return;                }                // if (!cT.Result)                // {                //     return;                // }            }        }        else if (eventConfig.placeID > 0)        {            if (eventConfig.placeID != smallPlacesConfig.PlacesId)            {                CTask<bool> cT = CTask<bool>.Create();                PlacesInfoPanel.OpenPanel(eventConfig.placeID, (b) => { cT.SetResult(b); });                await cT;                smallPlacesConfig =                    ConfigComponent.Instance.Get<SmallPlacesConfig>(PlayerManager.Instance.CurrentsmallPlaces.id);                if (eventConfig.placeID != smallPlacesConfig.PlacesId)                {                    return;                }            }        }        CTask cTask = CTask.Create();        this.onCompleteCallback = oncompleteCallBack;        isTriggerEvent = true;        LogTool.Log(            $"触发事件: {LanguageManager.Instance.Text(eventConfig.EventName)} (ID: {eventConfig.ID}, 品质: {eventConfig.EventQuality})");        int dialogueID = 0;        if (evt.curStep == 0)        {            dialogueID = eventConfig.EventLinksId[0];        }        else        {            dialogueID = evt.curStep;        }        CurrentEventList = evt;        CombatDrive.Instance.CombatController.ChangeState(CombatController.idle);        await DialogueManager.Instance.StartDialogue(CurrentEventList, dialogueID, eventConfig.ID, () =>        {            EventConfig eventConfig = ConfigComponent.Instance.Get<EventConfig>(CurrentEventList.eventID);            if (eventConfig.EventTriggerType != 4)            {                CompleteEvent(CurrentEventList);            }            else            {                CurrentEventList.isCompleted1 = true;                AccountFileInfo.Instance.SavePlayerData();                CombatDrive.Instance.CombatController.ChangeState(CombatController.update);                onCompleteCallback?.Invoke();                onCompleteCallback = null;            }            cTask.SetResult();        }, () =>        {            CancelEvent(CurrentEventList);            cTask.SetResult();        });        uiOpenOverCallBack?.Invoke();        DivineSenceEventPreviewPanel divineSenceEventPreviewPanel =            UIManager.Instance.GetComponent<DivineSenceEventPreviewPanel>();        AppBarPanel appBarPanel = UIManager.Instance.GetComponent<AppBarPanel>();        // DivineSenceInfoPanel divineSenceInfoPanel = UIManager.Instance.GetComponent<DivineSenceInfoPanel>();        if (divineSenceEventPreviewPanel != null && !divineSenceEventPreviewPanel.IsClose)        {            divineSenceEventPreviewPanel.GObjectPoolInterface.SetActive(false);        }        if (appBarPanel != null && !appBarPanel.IsClose)        {            appBarPanel.GObjectPoolInterface.SetActive(false);        }        // if (divineSenceInfoPanel != null)        // {        //     divineSenceInfoPanel.GObjectPoolInterface.SetActive(false);        // }        await cTask;        if (divineSenceEventPreviewPanel != null && !divineSenceEventPreviewPanel.IsClose)        {            divineSenceEventPreviewPanel.GObjectPoolInterface.SetActive(true);        }        if (appBarPanel != null && !appBarPanel.IsClose)        {            appBarPanel.GObjectPoolInterface.SetActive(true);        }        // if (divineSenceInfoPanel != null)        // {        //     divineSenceInfoPanel.GObjectPoolInterface.SetActive(true);        // }    }    //任务是否完成    public bool IsEvenkLinkComplete(AccountFileInfo.EventConditionData eventCondition)    {        EventConditionConfig eventConditionConfig =            ConfigComponent.Instance.Get<EventConditionConfig>(eventCondition.eventCondition);        if (eventCondition != null)        {            return eventCondition.fishCount >= eventConditionConfig.finishCount;        }        return false;    }    public bool CeekEventGroupComplete(List<AccountFileInfo.EventConditionData> eventConditions)    {        Map<int, List<AccountFileInfo.EventConditionData>> eventConditionDataGroup =            new Map<int, List<AccountFileInfo.EventConditionData>>();        foreach (var eventConditionData in eventConditions)        {            EventConditionConfig eventConditionConfig =                ConfigComponent.Instance.Get<EventConditionConfig>(eventConditionData.eventCondition);            if (!eventConditionDataGroup.ContainsKey(eventConditionConfig.Operation))            {                eventConditionDataGroup.Add(eventConditionConfig.Operation,                    new List<AccountFileInfo.EventConditionData>());            }            eventConditionDataGroup[eventConditionConfig.Operation].Add(eventConditionData);        }        bool isUlock = true;        //分组检测 其中一个组绑定成功就可以执行        foreach (var keyValuePair in eventConditionDataGroup)        {            isUlock = true;            foreach (var eventConditionData in keyValuePair.Value)            {                if (!IsEvenkLinkComplete(eventConditionData))                {                    isUlock = false;                }            }            if (isUlock)            {                return isUlock;            }        }        return isUlock;    }    public void CeekEventCompletes(int type, int[] value)    {        foreach (var playerDataEventLinkData in AccountFileInfo.Instance.playerData.eventList)        {            foreach (var eventLinkData in playerDataEventLinkData.eventLinks)            {                foreach (var eventConditionData in eventLinkData.eventConditions)                {                    CeekTaskComplete(eventConditionData, type, value);                }            }        }        EventManager.Instance.Dispatch(CustomEventType.RemoveEvent, null);    }    public void CeekTaskComplete(AccountFileInfo.EventConditionData conditionData, int type, int[] value)    {        EventConditionConfig eventConditionConfig =            ConfigComponent.Instance.Get<EventConditionConfig>(conditionData.eventCondition);        if (IsEvenkLinkComplete(conditionData))            return;        switch (type)        {            //检测背包道具            case 1:                if (eventConditionConfig.ConditionType == 1)                {                    conditionData.fishCount +=                        (int)PlayerManager.Instance.BagController.GetItemCount(eventConditionConfig.ConditionPara[0]);                    if (IsEvenkLinkComplete(conditionData))                    {                        // CompleteTask(conditionData.guid);                    }                }                break;            //境界检测            case 3:                if (eventConditionConfig.ConditionType == 3 && PlayerManager.Instance.myHero.powerUpConfig.ID >=                    eventConditionConfig.ConditionPara[0])                {                    conditionData.fishCount++;                    if (IsEvenkLinkComplete(conditionData))                    {                        // CompleteTask(conditionData.guid);                    }                }                break;            //战斗胜利            case 5:                if (eventConditionConfig.ConditionType == 5 && eventConditionConfig.ConditionPara[0] == value[0])                {                    conditionData.fishCount++;                    if (IsEvenkLinkComplete(conditionData))                    {                        // CompleteEvent(conditionData.guid);                    }                }                break;            //获得道具            case 6:                if (eventConditionConfig.ConditionType == 6 && eventConditionConfig.ConditionPara[0] == value[0])                {                    conditionData.fishCount += value[1];                    if (IsEvenkLinkComplete(conditionData))                    {                        // CompleteEvent(conditionData.guid);                    }                }                break;            //使用神识            case 8:                if (eventConditionConfig.ConditionType == 8)                {                    conditionData.fishCount += value[0];                    if (IsEvenkLinkComplete(conditionData))                    {                    }                }                break;        }        AccountFileInfo.Instance.SavePlayerData();    }    private void CompleteTask(object taskID)    {    }    //指定type事件    private bool CanEventType(int eventID, ItemInfo itemInfo)    {        if (itemInfo == null)        {            return true;        }        var evt = eventConfigs.Find(e => e.ID == eventID);        if (evt.PrizeType != null && evt.PrizeType.Contains(itemInfo.config.associateVlaue[0]))        {            return true;        }        return false;    }    /// <summary>    /// 检查事件是否满足触发条件。    /// </summary>    private bool CanTriggerEvent(int eventID)    {        var evt = eventConfigs.Find(e => e.ID == eventID);        if (evt.ID == 0)            return false;        if (evt.EventConditionId == null)            return true;        for (var i = 0; i < evt.EventConditionId.Length; i++)        {            switch (evt.EventConditionId[i])            {                //背包道具检测                case 1:                    return PlayerManager.Instance.BagController.GetItemCount(evt.EventValue[i]) >= evt.EventCount[i];                //境界判断                case 2:                    return PlayerManager.Instance.myHero.level >= evt.EventCount[i];                //概率判断                case 3:                    int randomValue1 = Random.Range(0, 1001);                    return randomValue1 <= evt.EventCount[i];                //完成事件判断                case 10:                    AccountFileInfo.EventList eventList =                        AccountFileInfo.Instance.playerData.completeEvents.FirstOrDefault(ce =>                            ce.eventID == evt.EventValue[i]);                    return eventList != null;            }        }        return true;    }    /// <summary>    /// 完成事件    /// </summary>    /// <param name="eventID">事件ID</param>    public void CompleteEvent(int evtId)    {        isTriggerEvent = false;        LogTool.Log($"完成挂机事件{evtId}");        EventConfig eventConfig = ConfigComponent.Instance.Get<EventConfig>(evtId);        AccountFileInfo.EventList eventList = new AccountFileInfo.EventList();        eventList.eventID = evtId;        AccountFileInfo.Instance.playerData.completeEvents.Add(eventList);        int placesId = PlayerManager.Instance.GetMaxSmallPlacesId();        AccountFileInfo.SmallPlacesData smallPlacesData = PlayerManager.Instance.GetSmallPlacesData(placesId);        if (smallPlacesData != null)        {            smallPlacesData.completionEventCount++;        }        SmallPlacesConfig smallPlacesConfig =            ConfigComponent.Instance.Get<SmallPlacesConfig>(PlayerManager.Instance.CurrentsmallPlaces.id);        AccountFileInfo.PlacesData placesData = PlayerManager.Instance.GetPlacesData(smallPlacesConfig.PlacesId);        if (placesData.progress < 100)            placesData.progress += eventConfig.Score;        AccountFileInfo.Instance.SavePlayerData();        CombatDrive.Instance.CombatController.ChangeState(CombatController.update);        EventManager.Instance.Dispatch(CustomEventType.CompleteEvent, null);    }    /// <summary>    /// 完成事件    /// </summary>    /// <param name="eventID">事件ID</param>    public async void CompleteEvent(AccountFileInfo.EventList eventList, bool isTriggerEvent = false)    {        this.isTriggerEvent = isTriggerEvent;        LogTool.Log($"完成事件{eventList.eventID}");        EventConfig eventConfig = ConfigComponent.Instance.Get<EventConfig>(eventList.eventID);        AccountFileInfo.EventList ceventList =            AccountFileInfo.Instance.playerData.completeEvents.FirstOrDefault(ce => ce.eventID == eventList.eventID);        int placesId = PlayerManager.Instance.GetMaxSmallPlacesId();        AccountFileInfo.SmallPlacesData smallPlacesData = PlayerManager.Instance.GetSmallPlacesData(placesId);        if (smallPlacesData != null)        {            smallPlacesData.completionEventCount++;        }        if (ceventList == null)        {            PlacesConfig[] placesConfigs = ConfigComponent.Instance.GetAll<PlacesConfig>();            int pId = 0;            for (var i = 0; i < placesConfigs.Length; i++)            {                if (placesConfigs[i].MainTaskID == null || placesConfigs[i].ZhixianID == null)                    continue;                if (placesConfigs[i].MainTaskID.Contains(eventConfig.ID) ||                    placesConfigs[i].ZhixianID.Contains(eventConfig.ID))                {                    pId = placesConfigs[i].ID;                    break;                }            }            if (pId == 0)            {                SmallPlacesConfig smallPlacesConfig =                    ConfigComponent.Instance.Get<SmallPlacesConfig>(PlayerManager.Instance.CurrentsmallPlaces.id);                AccountFileInfo.PlacesData                    placesData = PlayerManager.Instance.GetPlacesData(smallPlacesConfig.PlacesId);                placesData.progress += eventConfig.Score;            }            else            {                PlayerManager.Instance.GetPlacesData(pId).progress += eventConfig.Score;            }        }        List<ItemInfo> itemInfos = new List<ItemInfo>();        if (eventConfig.PrizeIDs != null)        {            for (var i = 0; i < eventConfig.PrizeIDs.Length; i++)            {                DropConfig dropConfig = ConfigComponent.Instance.Get<DropConfig>(eventConfig.PrizeIDs[i]);                if (dropConfig.dropType == 3)                {                    if (eventConfig.PrizeNums[i] < 0)                    {                        List<ItemInfo> items =                            DropManager.Instance.Drop(dropConfig.dropGroupID[0], eventConfig.PrizeNums[i]);                        if (items != null)                            itemInfos.AddRange(items);                    }                    else                    {                        ItemInfo itemInfo = new ItemInfo(dropConfig.dropGroupID[0], eventConfig.PrizeNums[i]);                        itemInfos.Add(itemInfo);                    }                }                else                {                    List<ItemInfo> items = DropManager.Instance.DropItem(eventConfig.PrizeIDs[i]);                    if (items != null)                        itemInfos.AddRange(items);                }                // itemInfos.Add(new ItemInfo(eventConfig.PrizeIDs[i], eventConfig.PrizeNums[i]));            }        }        foreach (var eventListItemInfo in eventList.itemInfos)        {            itemInfos.Add(new ItemInfo(eventListItemInfo));        }        PlayerManager.Instance.BagController.AddItem(itemInfos);        if (eventConfig.EventTriggerType == 4)        {            eventList.isCompleted = true;            AccountFileInfo.Instance.playerData.completeEvents.Add(eventList);            AccountFileInfo.Instance.playerData.eventList.Remove(eventList);            TaskInfoPanel taskInfoPanel = await TaskInfoPanel.OpenPanel(eventList, 2);            await taskInfoPanel.UIClosed();        }        else        {            //先不移除 下次探索神识移除            eventList.isCompleted = true;        }        if (itemInfos != null && itemInfos.Count > 0)        {            RewardsPanel rewardsPanel = await RewardsPanel.OpenPanel(itemInfos);            await rewardsPanel.UIClosed();        }        if (AccountFileInfo.Instance.playerData.CurrentZuiZhongEventListId == eventList.guid)        {            AccountFileInfo.Instance.playerData.CurrentZuiZhongEventListId = 0;            UpdateZuizhongEventData();        }        AccountFileInfo.Instance.SavePlayerData();        CombatDrive.Instance.CombatController.ChangeState(CombatController.update);        EventManager.Instance.Dispatch(CustomEventType.CompleteEvent, null);        EventManager.Instance.Dispatch(CustomEventType.CompleteUpdate, null);        onCompleteCallback?.Invoke();        onCompleteCallback = null;    }    /// <summary>    /// 完成事件    /// </summary>    /// <param name="eventID">事件ID</param>    public void CompleteEvent(AccountFileInfo.EventLinkData eventLinkData)    {    }    /// <summary>    /// 取消事件    /// </summary>    /// <param name="eventID">事件ID</param>    public void CancelEvent(AccountFileInfo.EventList eventList)    {        LogTool.Log($"取消事件{eventList.eventID}");        isTriggerEvent = false;        EventManager.Instance.Dispatch(CustomEventType.CompleteUpdate, null);        // EventManager.Instance.Dispatch(CustomEventType.CompleteEvent, null);        CombatDrive.Instance.CombatController.ChangeState(CombatController.update);        onCompleteCallback?.Invoke();        onCompleteCallback = null;        if (PlayerGuideManager.Instance.GuideIsCanDo(2))        {            PlayerGuideManager.Instance.SetGuid(2);        }    }    public void RemoveEvent(AccountFileInfo.EventList eventList)    {        AccountFileInfo.Instance.playerData.eventList.Remove(eventList);        AccountFileInfo.Instance.SavePlayerData();        EventManager.Instance.Dispatch(CustomEventType.RemoveEvent, null);    }    /// <summary>    /// 获得主线事件    /// </summary>    /// <returns></returns>    public AccountFileInfo.EventList GetMainEventDta()    {        foreach (var eventList in AccountFileInfo.Instance.playerData.eventList)        {            EventConfig eventConfig = ConfigComponent.Instance.Get<EventConfig>(eventList.eventID);            if (eventConfig.EventTriggerType == 4)            {                return eventList;            }        }        return null;    }    public void CancelEvent()    {        CombatDrive.Instance.CombatController.ChangeState(CombatController.update);        DialogueManager.Instance.ChancleEvent();        CurrentEventList = null;        isTriggerEvent = false;    }}
 |