| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290 | using System;using System.Collections.Generic;using System.Linq;using Common.Utility.CombatEvent;using Core.Audio;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 });                }            }        }        //进入游戏全部检测一次        foreach (var playerDataEventLinkData in AccountFileInfo.Instance.playerData.eventList)        {            foreach (var eventLinkData in playerDataEventLinkData.eventLinks)            {                CeekEventGroupComplete(eventLinkData.eventConditions);            }        }        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 == 0 && e.placeID == 0) ||                 (e.SmallPlacesId != 0 && e.SmallPlacesId == smallPlacesConfig.ID) ||                 (e.SmallPlacesId == 0 && e.placeID == smallPlacesConfig.PlacesId)) &&                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 =>                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);                    }                    AudioManager.Instance.PlayAudio("ui_chaozuoshibai.wav");                    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)));                        AudioManager.Instance.PlayAudio("ui_chaozuoshibai.wav");                        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;                EventManager.Instance.Dispatch(CustomEventType.CompleteUpdate, 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 3:                    return PlayerManager.Instance.myHero.level >= evt.EventValue[i];                //概率判断                case 7:                    int randomValue1 = Random.Range(0, 1001);                    return randomValue1 <= evt.EventValue[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;    }}
 |