hch
2025-08-05 6d9a990ce3eff793946d7b43e9b48e4f7045c20e
Main/System/KnapSack/PackManager.cs
@@ -8,12 +8,42 @@
public class PackManager : GameSystemManager<PackManager>
{
    public event Action<PackType> refrechPackEvent; //刷新整个背包数据
    //物品(创建)刷新,可能批量创建注意效率; bool:true代表创建 false 刷新; 注意0707物品数量刷新不包含在此事件
    public event Action<PackType, string, bool> ChangeItemEvent; // 背包类型,GUID,是否创建
    //删除物品,可能批量删除注意效率
    public event Action<PackType, string> DeleteItemEvent; // 背包类型,GUID
    // 单物品刷新 在得到新物品、物品数量的改变,清理该物品时均会触发 ; 但0725整个背包刷新不触发,如果有需要单独数量刷新事件另外处理
    // 触发比较频繁,界面使用时可以做个汇总后延迟刷新
    public event Action<PackType, int, int> RefreshItemEvent; //背包类型,位置索引,物品id
    public event Action<PackType> gridRefreshEvent; //背包可用格子数刷新
    public event Action<int, int> useItemSuccessEvent; //物品使用成功 int 位置索引 int物品id
    public event Action<int> refreshItemDayUseCountEvent;  //刷新物品每日使用数量
    public event Action<int> refreshItemSumUseCountEvent;  //刷新物品总使用数量
    public bool isPlayBetterEquipEffect { get; set; }  //整理背包时是否播放特效
    private Dictionary<PackType, SinglePack> playerPackDict = new Dictionary<PackType, SinglePack>();
    private Dictionary<string, ItemModel> itemGUIDDict = new Dictionary<string, ItemModel>();
    private Dictionary<int, int> PackGirdServerBuyCountDict = new Dictionary<int, int>(); //背包类型:购买格子的次数
    //读表数据
    public Dictionary<int, int> PackMaxCountDict = new Dictionary<int, int>(); //背包类型:背包格子最大数量
    public Dictionary<int, int> PackInitCountDict = new Dictionary<int, int>(); //背包类型:初始数量
    public int initBagGridCount { get; private set; } //初始物品背包格子数
    public int[] itemPackSortTyps { get; private set; }    //背包物品的按类型排序
    public List<string> composeItemGuidList = new List<string>();  //合成列表物品guid
    //开格子
    public Dictionary<int, int> openGirdMoneyDict = new Dictionary<int, int>(); //背包类型:消耗货币类型
    public Dictionary<int, int[]> openGirdMoneyValueDict = new Dictionary<int, int[]>(); //背包类型:消耗货币值(按次数定价)
    public Dictionary<int, int[]> openGirdCountDict = new Dictionary<int, int[]>(); //背包类型:每次开的格子数量
    public static string StrengthAttrShift_RecordKey = "";
    public const string RecordKnapsackTitle = "RecordKnapsackTitle";
@@ -23,11 +53,7 @@
    Dictionary<int, List<int>> sharedUseCountItemDict { get; set; }
    bool isUpdatePlayerLv = false;
    //AlchemyModel alchemyModel { get { return ModelCenter.Instance.GetModel<AlchemyModel>(); } }
    //ItemTipsModel itemTipsModel { get { return ModelCenter.Instance.GetModel<ItemTipsModel>(); } }
    public int[] gameCashShow;  //代金券特殊显示 除以100
    public int[] autoUseItemIDs;
    public override void Init()
    {
@@ -56,9 +82,8 @@
        //     }
        // }
        ParseItemCount();
        autoUseItemIDs = JsonMapper.ToObject<int[]>(FuncConfigConfig.Get("ItemTipsNum").Numerical2);
    }
@@ -71,23 +96,7 @@
        // SysNotifyMgr.Instance.sysNotifyEvent -= RefreshSysInfo;
    }
    public Dictionary<int, string> textCountShow = new Dictionary<int, string>();
    public int[] textCountShow2;
    public List<int> gameCashShow = new List<int>();
    public void ParseItemCount()
    {
        var textConfig = FuncConfigConfig.Get("ItemCountShow");
        var json = JsonMapper.ToObject(textConfig.Numerical1);
        foreach (var key in json.Keys)
        {
            var itemID = int.Parse(key);
            textCountShow[itemID] = json[key].ToString();
        }
        textCountShow2 = JsonMapper.ToObject<int[]>(textConfig.Numerical2);
        gameCashShow = JsonMapper.ToObject<List<int>>(textConfig.Numerical3);
    }
    private void OnFuncStateChangeEvent(int id)
@@ -165,28 +174,7 @@
        // }
    }
    public event Action<PackType> refrechPackEvent; //刷新整个背包数据
    //物品(创建)刷新,可能批量创建注意效率; bool:true代表创建 false 刷新; 注意0707物品数量刷新不包含在此事件
    public event Action<PackType, string, bool> ChangeItemEvent; // 背包类型,GUID,是否创建
    //删除物品,可能批量删除注意效率
    public event Action<PackType, string> DeleteItemEvent; // 背包类型,GUID
    // 单物品刷新 在得到新物品、物品数量的改变,清理该物品时均会触发 ; 但0725整个背包刷新不触发,如果有需要单独数量刷新事件另外处理
    // 触发比较频繁,界面使用时可以做个汇总后延迟刷新
    public event Action<PackType, int, int> RefreshItemEvent; //背包类型,位置索引,物品id
    public event Action<PackType> gridRefreshEvent; //背包可用格子数刷新
    public event Action<int, int> useItemSuccessEvent; //物品使用成功 int 位置索引 int物品id
    public event Action<int> refreshItemDayUseCountEvent;  //刷新物品每日使用数量
    public event Action<int> refreshItemSumUseCountEvent;  //刷新物品总使用数量
    public bool isPlayBetterEquipEffect { get; set; }  //整理背包时是否播放特效
    #region 接收服务端数据
    private Dictionary<PackType, SinglePack> playerPackDict = new Dictionary<PackType, SinglePack>();
    private Dictionary<string, ItemModel> itemGUIDDict = new Dictionary<string, ItemModel>();
    public void UpdatePack(H0725_tagRolePackRefreshEx packInfo)
    {
@@ -270,7 +258,18 @@
    }
    public void UpdateBuyPackGirdCount(HA207_tagSCPackBuyInfo netPack)
    {
        for (int i = 0; i < netPack.BuyInfoList.Length; i++)
        {
            PackGirdServerBuyCountDict[netPack.BuyInfoList[i].PackType] = netPack.BuyInfoList[i].BuyCnt;
        }
    }
    public int[] BuyPackGirdNeedData(PackType packType)
    {
        return null;
    }
    public void UpdateUnlockedGridCount(H0724_tagRolePackCanUseCount useCount)
    {
@@ -475,20 +474,27 @@
    //     }
    // }
    #endregion
    #region 玩家装备特殊逻辑
    void ParseConfig()
    {
        ParsePackConfigIni();
        autoUseItemIDs = JsonMapper.ToObject<int[]>(FuncConfigConfig.Get("AutoUseItem").Numerical1);
        var config= FuncConfigConfig.Get("InitBagCellCount");
        initBagGridCount = int.Parse(config.Numerical1);
        PackInitCountDict = ConfigParse.ParseIntDict(config.Numerical2);
        config = FuncConfigConfig.Get("PackageSortPriority");
        itemPackSortTyps = ConfigParse.GetMultipleStr<int>(config.Numerical1);
        ParsePackConfigIni();
        config = FuncConfigConfig.Get("OpenPack");
        openGirdMoneyDict = ConfigParse.ParseIntDict(config.Numerical1);
        openGirdMoneyValueDict = ConfigParse.ParseIntArrayDict(config.Numerical2);
        openGirdCountDict = ConfigParse.ParseIntArrayDict(config.Numerical3);
        config = FuncConfigConfig.Get("ItemCountShow");
        gameCashShow = JsonMapper.ToObject<int[]>(config.Numerical1);
    }
    void ParsePackConfigIni()
@@ -526,6 +532,15 @@
        }
        return File.ReadAllLines(path);
    }
    public int GetCanBuyPackGirdCount(PackType type)
    {
        if (!PackMaxCountDict.ContainsKey((int)type))
        {
            return 0;
        }
        return PackMaxCountDict[(int)type] - GetSinglePack(type).unlockedGridCount;
    }
@@ -842,9 +857,6 @@
    const int ITEMPACK_REDKEY = 102011003;
    Redpoint redpointItemPack = new Redpoint(MainRedDot.RedPoint_BagFuncKey, ITEMPACK_REDKEY);
    const int LS_REDKEY = 102011015;
    Redpoint redpointLS = new Redpoint(MainRedDot.RedPoint_BagFuncKey, LS_REDKEY);
    private void UpdatePackRedpoint(PackType type)
    {
@@ -868,16 +880,7 @@
                }
                break;
            case PackType.Warehouse:
                if (singlePack.GetEmptyGridCount() <= 0)
                {
                    MainRedDot.Instance.redPointDepotFunc.state = RedPointState.Full;
                }
                else
                {
                    MainRedDot.Instance.redPointDepotFunc.state = RedPointState.None;
                }
                break;
        }
    }