From 1c9b3fb4b45d2096a4c7bf5ef4bb7a7ffac3b7fe Mon Sep 17 00:00:00 2001
From: hch <305670599@qq.com>
Date: 星期四, 08 一月 2026 01:47:14 +0800
Subject: [PATCH] 266 【内政】古宝系统
---
Main/System/KnapSack/VirtualPackManager.cs | 405 ++++++++++++++++++++++++++++-----------------------------
1 files changed, 198 insertions(+), 207 deletions(-)
diff --git a/Main/System/KnapSack/VirtualPackManager.cs b/Main/System/KnapSack/VirtualPackManager.cs
index 623bfb6..2cbb883 100644
--- a/Main/System/KnapSack/VirtualPackManager.cs
+++ b/Main/System/KnapSack/VirtualPackManager.cs
@@ -7,55 +7,46 @@
public class VirtualPackManager : GameSystemManager<VirtualPackManager>
{
- Dictionary<PackType, List<VirtualPackItem>> virtualPackItems
- = new Dictionary<PackType, List<VirtualPackItem>>();
- Dictionary<PackType, ObjectPool<VirtualPackItem>> m_VirtualItemPool
- = new Dictionary<PackType, ObjectPool<VirtualPackItem>>();
- Dictionary<PackType, int> virtualPackCapacityDict = new Dictionary<PackType, int>();
+ // Dictionary<PackType, List<VirtualPackItem>> virtualPackItems
+ // = new Dictionary<PackType, List<VirtualPackItem>>();
+ // Dictionary<PackType, ObjectPool<VirtualPackItem>> m_VirtualItemPool
+ // = new Dictionary<PackType, ObjectPool<VirtualPackItem>>();
+ // Dictionary<PackType, int> virtualPackCapacityDict = new Dictionary<PackType, int>();
- public event Action<PackType> virtualPackRefresh;
- int getA206Count = 0; //鏀跺埌浜嗗嚑娆206鍖�
- bool isFrist = false; //鏄笉鏄涓�娆¤幏寰楄仛榄傜鐗�
+ // public event Action<PackType> virtualPackRefresh;
+ // int getA206Count = 0; //鏀跺埌浜嗗嚑娆206鍖�
Dictionary<int, int> noPackItemCountDict = new Dictionary<int, int>(); //鏃犻渶鑳屽寘鐨勭墿鍝佹暟閲忓埛鏂帮紝鑷姩杞寲涓烘暟鍊�
public event Action OnNoPackItemCountRefresh;
public void OnBeforePlayerDataInitialize()
{
- foreach (var packType in virtualPackItems.Keys)
- {
- var pool = m_VirtualItemPool[packType];
- var items = virtualPackItems[packType];
- foreach (var item in items)
- {
- pool.Release(item);
- }
- }
- virtualPackItems.Clear();
+ // foreach (var packType in virtualPackItems.Keys)
+ // {
+ // var pool = m_VirtualItemPool[packType];
+ // var items = virtualPackItems[packType];
+ // foreach (var item in items)
+ // {
+ // pool.Release(item);
+ // }
+ // }
+ // virtualPackItems.Clear();
noPackItemCountDict.Clear();
- getA206Count = 0;
- isFrist = false;
}
- public void OnPlayerLoginOk()
- {
- isFrist = noPackItemCountDict.Count == 0;
- }
public override void Init()
{
base.Init();
ParseConfig();
- m_VirtualItemPool.Add(PackType.GatherSoul, new ObjectPool<VirtualPackItem>(OnGetItem, OnReleaseItem));
- m_VirtualItemPool.Add(PackType.RunePack, new ObjectPool<VirtualPackItem>(OnGetItem, OnReleaseItem));
- DTC0102_tagCDBPlayer.beforePlayerDataInitializeEvent += OnBeforePlayerDataInitialize;
- DTC0403_tagPlayerLoginLoadOK.playerLoginOkEvent += OnPlayerLoginOk;
+ // m_VirtualItemPool.Add(PackType.GatherSoul, new ObjectPool<VirtualPackItem>(OnGetItem, OnReleaseItem));
+ // m_VirtualItemPool.Add(PackType.RunePack, new ObjectPool<VirtualPackItem>(OnGetItem, OnReleaseItem));
+ DTC0102_tagCDBPlayer.beforePlayerDataInitializeEventOnRelogin += OnBeforePlayerDataInitialize;
}
public override void Release()
{
base.Release();
- DTC0102_tagCDBPlayer.beforePlayerDataInitializeEvent -= OnBeforePlayerDataInitialize;
- DTC0403_tagPlayerLoginLoadOK.playerLoginOkEvent -= OnPlayerLoginOk;
+ DTC0102_tagCDBPlayer.beforePlayerDataInitializeEventOnRelogin -= OnBeforePlayerDataInitialize;
}
void ParseConfig()
@@ -63,157 +54,157 @@
// virtualPackCapacityDict.Add(PackType.RunePack, int.Parse(funcConfig.Numerical1));
}
- public bool IsVirtualPack(PackType packType)
- {
- switch (packType)
- {
- case PackType.GatherSoul:
- case PackType.RunePack:
- return true;
- }
- return false;
- }
+ // public bool IsVirtualPack(PackType packType)
+ // {
+ // switch (packType)
+ // {
+ // case PackType.GatherSoul:
+ // case PackType.RunePack:
+ // return true;
+ // }
+ // return false;
+ // }
- public int GetPackCapacity(PackType packType)
- {
- if (virtualPackCapacityDict.ContainsKey(packType))
- {
- return virtualPackCapacityDict[packType];
- }
- return 0;
- }
+ // public int GetPackCapacity(PackType packType)
+ // {
+ // if (virtualPackCapacityDict.ContainsKey(packType))
+ // {
+ // return virtualPackCapacityDict[packType];
+ // }
+ // return 0;
+ // }
- public int GetPackRemainCount(PackType packType)
- {
- var capacity = GetPackCapacity(packType);
- return capacity - GetPackItemCount(packType);
- }
+ // public int GetPackRemainCount(PackType packType)
+ // {
+ // var capacity = GetPackCapacity(packType);
+ // return capacity - GetPackItemCount(packType);
+ // }
- public int GetPackItemCount(PackType packType)
- {
- if (virtualPackItems.ContainsKey(packType))
- {
- return virtualPackItems[packType].Count;
- }
- return 0;
- }
+ // public int GetPackItemCount(PackType packType)
+ // {
+ // if (virtualPackItems.ContainsKey(packType))
+ // {
+ // return virtualPackItems[packType].Count;
+ // }
+ // return 0;
+ // }
- public int GetItemCountById(PackType packType, int id)
- {
- var count = 0;
- List<int> list;
- if (TryGetItems(packType, out list))
- {
- for (int i = 0; i < list.Count; i++)
- {
- VirtualPackItem item;
- if (TryGetItem(packType, list[i], out item)
- && item.id == id)
- {
- count++;
- }
- }
- }
- return count;
- }
+ // public int GetItemCountById(PackType packType, int id)
+ // {
+ // var count = 0;
+ // List<int> list;
+ // if (TryGetItems(packType, out list))
+ // {
+ // for (int i = 0; i < list.Count; i++)
+ // {
+ // VirtualPackItem item;
+ // if (TryGetItem(packType, list[i], out item)
+ // && item.id == id)
+ // {
+ // count++;
+ // }
+ // }
+ // }
+ // return count;
+ // }
- public void GetItemIndexs(PackType packType, ref List<int> list)
- {
- list.Clear();
- List<VirtualPackItem> _list;
- if (virtualPackItems.TryGetValue(packType, out _list))
- {
- for (int i = 0; i < _list.Count; i++)
- {
- list.Add(_list[i].index);
- }
- }
- }
+ // public void GetItemIndexs(PackType packType, ref List<int> list)
+ // {
+ // list.Clear();
+ // List<VirtualPackItem> _list;
+ // if (virtualPackItems.TryGetValue(packType, out _list))
+ // {
+ // for (int i = 0; i < _list.Count; i++)
+ // {
+ // list.Add(_list[i].index);
+ // }
+ // }
+ // }
- public bool TryGetItems(PackType packType, out List<int> list)
- {
- list = new List<int>();
- List<VirtualPackItem> _list;
- if (virtualPackItems.TryGetValue(packType, out _list))
- {
- for (int i = 0; i < _list.Count; i++)
- {
- list.Add(_list[i].index);
- }
- return true;
- }
- return false;
- }
+ // public bool TryGetItems(PackType packType, out List<int> list)
+ // {
+ // list = new List<int>();
+ // List<VirtualPackItem> _list;
+ // if (virtualPackItems.TryGetValue(packType, out _list))
+ // {
+ // for (int i = 0; i < _list.Count; i++)
+ // {
+ // list.Add(_list[i].index);
+ // }
+ // return true;
+ // }
+ // return false;
+ // }
- public bool TryGetItem<T>(PackType packType, int packIndex, out T item) where T : VirtualPackItem
- {
- item = default(T);
- if (virtualPackItems.ContainsKey(packType))
- {
- var _index = virtualPackItems[packType].FindIndex((x) =>
- {
- return x.index == packIndex;
- });
- if (_index != -1)
- {
- item = virtualPackItems[packType][_index] as T;
- }
- return _index != -1;
- }
- return false;
- }
+ // public bool TryGetItem<T>(PackType packType, int packIndex, out T item) where T : VirtualPackItem
+ // {
+ // item = default(T);
+ // if (virtualPackItems.ContainsKey(packType))
+ // {
+ // var _index = virtualPackItems[packType].FindIndex((x) =>
+ // {
+ // return x.index == packIndex;
+ // });
+ // if (_index != -1)
+ // {
+ // item = virtualPackItems[packType][_index] as T;
+ // }
+ // return _index != -1;
+ // }
+ // return false;
+ // }
- public void OnReceiveServerPack(HA204_tagMCVPackRefresh package)
- {
- var packType = (PackType)package.PackType;
- if (!IsVirtualPack(packType))
- {
- return;
- }
- List<VirtualPackItem> list;
- if (!virtualPackItems.TryGetValue(packType, out list))
- {
- list = new List<VirtualPackItem>();
- virtualPackItems.Add(packType, list);
- }
- SetVirtualItem(packType, ref list, package.VPacklItemList);
- if (virtualPackRefresh != null)
- {
- virtualPackRefresh((PackType)package.PackType);
- }
+ // public void OnReceiveServerPack(HA204_tagMCVPackRefresh package)
+ // {
+ // var packType = (PackType)package.PackType;
+ // if (!IsVirtualPack(packType))
+ // {
+ // return;
+ // }
+ // List<VirtualPackItem> list;
+ // if (!virtualPackItems.TryGetValue(packType, out list))
+ // {
+ // list = new List<VirtualPackItem>();
+ // virtualPackItems.Add(packType, list);
+ // }
+ // SetVirtualItem(packType, ref list, package.VPacklItemList);
+ // if (virtualPackRefresh != null)
+ // {
+ // virtualPackRefresh((PackType)package.PackType);
+ // }
- }
+ // }
- public void OnReceiveServerPack(HA205_tagMCVPackClear package)
- {
- var packType = (PackType)package.PackType;
- if (!IsVirtualPack(packType))
- {
- return;
- }
- List<VirtualPackItem> list;
- if (virtualPackItems.TryGetValue(packType, out list))
- {
- var pool = m_VirtualItemPool[packType];
- for (int i = 0; i < package.Count; i++)
- {
- var index = package.ItemPlaceList[i];
- var items = list.FindAll((x) =>
- {
- return x.index == index;
- });
- foreach (var item in items)
- {
- list.Remove(item);
- pool.Release(item);
- }
- }
- if (virtualPackRefresh != null)
- {
- virtualPackRefresh(packType);
- }
- }
- }
+ // public void OnReceiveServerPack(HA205_tagMCVPackClear package)
+ // {
+ // var packType = (PackType)package.PackType;
+ // if (!IsVirtualPack(packType))
+ // {
+ // return;
+ // }
+ // List<VirtualPackItem> list;
+ // if (virtualPackItems.TryGetValue(packType, out list))
+ // {
+ // var pool = m_VirtualItemPool[packType];
+ // for (int i = 0; i < package.Count; i++)
+ // {
+ // var index = package.ItemPlaceList[i];
+ // var items = list.FindAll((x) =>
+ // {
+ // return x.index == index;
+ // });
+ // foreach (var item in items)
+ // {
+ // list.Remove(item);
+ // pool.Release(item);
+ // }
+ // }
+ // if (virtualPackRefresh != null)
+ // {
+ // virtualPackRefresh(packType);
+ // }
+ // }
+ // }
public void UpdateAutoItemCountRefresh(HA206_tagMCAutoItemCountRefresh netPack)
@@ -243,46 +234,46 @@
- void SetVirtualItem(PackType packType, ref List<VirtualPackItem> list, HA204_tagMCVPackRefresh.tagMCVPackItem[] items)
- {
- var pool = m_VirtualItemPool[packType];
- for (int i = 0; i < items.Length; i++)
- {
- var item = list.Find((x) =>
- {
- return x.index == items[i].ItemPlace;
- });
- if (item != null)
- {
- item.Release();
- }
- else
- {
- if (pool.inactivedCount > 0)
- {
- item = pool.Get();
- list.Add(item);
- }
- }
- if (item == null)
- {
- item = VirtualPackItem.Get(packType);
- list.Add(item);
- }
- item.ParsePackItem(items[i].ItemPlace, items[i].ItemData);
+ // void SetVirtualItem(PackType packType, ref List<VirtualPackItem> list, HA204_tagMCVPackRefresh.tagMCVPackItem[] items)
+ // {
+ // var pool = m_VirtualItemPool[packType];
+ // for (int i = 0; i < items.Length; i++)
+ // {
+ // var item = list.Find((x) =>
+ // {
+ // return x.index == items[i].ItemPlace;
+ // });
+ // if (item != null)
+ // {
+ // item.Release();
+ // }
+ // else
+ // {
+ // if (pool.inactivedCount > 0)
+ // {
+ // item = pool.Get();
+ // list.Add(item);
+ // }
+ // }
+ // if (item == null)
+ // {
+ // item = VirtualPackItem.Get(packType);
+ // list.Add(item);
+ // }
+ // item.ParsePackItem(items[i].ItemPlace, items[i].ItemData);
- }
- }
+ // }
+ // }
- static void OnGetItem(VirtualPackItem item)
- {
+ // static void OnGetItem(VirtualPackItem item)
+ // {
- }
+ // }
- static void OnReleaseItem(VirtualPackItem item)
- {
- item.Release();
- }
+ // static void OnReleaseItem(VirtualPackItem item)
+ // {
+ // item.Release();
+ // }
}
public abstract class VirtualPackItem
--
Gitblit v1.8.0