| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285 | 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 });                }            }        }        //进入游戏全部检测一次        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 == 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 =>                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.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;    }}
 |