Main/System/Equip/EquipModel.cs
@@ -27,12 +27,15 @@
    public List<int> lastDropIndexs = new List<int>(); //上一次掉落物品索引
    int lastAttackHeroID = 0;
    public override void Init()
    {
        DTCA814_tagMCMakeItemAnswer.MakeItemAnswerEvent += OnEquipResult;
        DTC0102_tagCDBPlayer.beforePlayerDataInitializeEventOnRelogin += BeforePlayerDataInitialize;
        EventBroadcast.Instance.RemoveListener<string, BattleDrops, Action>(EventName.BATTLE_DROP_ITEMS, OnDropEvent);
        EventBroadcast.Instance.AddListener<string, BattleDrops, Action>(EventName.BATTLE_DROP_ITEMS, OnDropEvent);
        EventBroadcast.Instance.AddListener<string, SkillConfig, TeamHero>(EventName.BATTLE_CAST_SKILL, OnSkillCast);
        EventBroadcast.Instance.AddListener<string>(EventName.RECORDPLAYER_END, RecordPlayerEnd);
        ParseConfig();
    }
@@ -41,6 +44,8 @@
        DTCA814_tagMCMakeItemAnswer.MakeItemAnswerEvent -= OnEquipResult;
        DTC0102_tagCDBPlayer.beforePlayerDataInitializeEventOnRelogin -= BeforePlayerDataInitialize;
        EventBroadcast.Instance.RemoveListener<string, BattleDrops, Action>(EventName.BATTLE_DROP_ITEMS, OnDropEvent);
        EventBroadcast.Instance.RemoveListener<string, SkillConfig, TeamHero>(EventName.BATTLE_CAST_SKILL, OnSkillCast);
        EventBroadcast.Instance.RemoveListener<string>(EventName.RECORDPLAYER_END, RecordPlayerEnd);
    }
@@ -82,6 +87,7 @@
        return -1;
    }
    //表现掉落和拾取分离开,先掉落等本武将回合完全结束再拾取
    void OnDropEvent(string guid, BattleDrops drops, Action action)
    {
        if (!string.IsNullOrEmpty(guid))
@@ -93,21 +99,57 @@
        action?.Invoke();
    }
    //拾取时机为下一武将(含敌我)攻击 或者 本轮结算(MainFightRequest 前)
    void OnSkillCast(string guid, SkillConfig skillConfig, TeamHero teamHero)
    {
        bool checkDrop = false;
        if (!string.IsNullOrEmpty(guid))
            return;
        //防范回收报错
        if (teamHero == null)
            checkDrop = true;
        //只通知玩家武将的战斗
        else if (teamHero.NPCID != 0)
            checkDrop = true;
        else if (teamHero.heroId != lastAttackHeroID)
        {
            lastAttackHeroID = teamHero.heroId;
            checkDrop = true;
        }
        if (checkDrop)
        {
            CalcAllFloorItems();
        }
    }
    void RecordPlayerEnd(string guid)
    {
        if (!string.IsNullOrEmpty(guid))
            return;
        CalcAllFloorItems();
    }
    //掉落通知
    public void NotifyItemDrop(List<int> indexs, RectTransform rect)
    {
        // 界面不显示则立即处理
        if (!UIManager.Instance.IsOpened<HomeWin>())
        {
            for (int i = 0; i < indexs.Count; i++)
            {
                CalcFloorEquip(indexs[i]);
            }
        }
        else
        {
        // if (!UIManager.Instance.IsOpened<HomeWin>())
        // {
        //     for (int i = 0; i < indexs.Count; i++)
        //     {
        //         CalcFloorEquip(indexs[i]);
        //     }
        // }
        // else
        // {
        //     OnItemDropEvent?.Invoke(indexs, rect);
        // }
            OnItemDropEvent?.Invoke(indexs, rect);
        }
    }
    public void CalcFloorEquip(int itemIndex)
@@ -119,7 +161,6 @@
        if (item == null)
            return;
        //非自动模式下,筛选装备打开装备操作界面
        if (IsEquip(item))
        {
@@ -131,6 +172,20 @@
        }
    }
    //处理所有掉落的物品
    public void CalcAllFloorItems()
    {
        if (PackManager.Instance.GetSinglePack(PackType.DropItem).GetItems().Count == 0)
        {
            return;
        }
        //构建所有物品
        foreach (var item in PackManager.Instance.GetSinglePack(PackType.DropItem).GetItems())
        {
            CalcFloorEquip(item.gridIndex);
        }
    }
    private void OnEquipResult(HA814_tagMCMakeItemAnswer info)
    {
        if (info.MakeType != (int)MakeType.EquipOP)