Files

672 lines
24 KiB
C#
Raw Permalink Normal View History

2024-08-23 15:49:34 +08:00
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
using GCGame.Table;
using Games.Item;
using System;
public class Market
{
#region marketItemClass
public class MarketItemClass
{
public int ItemClass;
public int ItemSubClass;
public int ItemSubClass2;
public MarketItemClass(int itemClass, int itemSubClass)
{
ItemClass = itemClass;
ItemSubClass = itemSubClass;
}
}
public static string GetMarketClassName(int itemClass, int itemSubClass)
{
switch (itemClass)
{
case 999: //关注
return StrDictionary.GetClientDictionaryString("#{6234}");
case 998: //所有公示
return StrDictionary.GetClientDictionaryString("#{6235}");
case 1://装备法宝
switch (itemSubClass)
{
case 1://普通装备
return StrDictionary.GetClientDictionaryString("#{6207}");
case 2://珍品装备
return StrDictionary.GetClientDictionaryString("#{6208}");
case 3://法宝
return StrDictionary.GetClientDictionaryString("#{6209}");
}
return StrDictionary.GetClientDictionaryString("#{6206}");
case 2://食品药品
switch (itemSubClass)
{
case 1://药品
return StrDictionary.GetClientDictionaryString("#{6211}");
case 2://食品
return StrDictionary.GetClientDictionaryString("#{6212}");
case 3://状态药
return StrDictionary.GetClientDictionaryString("#{6213}");
}
return StrDictionary.GetClientDictionaryString("#{6210}");
case 3: //强化材料
switch (itemSubClass)
{
case 1://宝石
return StrDictionary.GetClientDictionaryString("#{6215}");
case 2://吴山石
return StrDictionary.GetClientDictionaryString("#{6216}");
case 3://金刚钻
return StrDictionary.GetClientDictionaryString("#{6217}");
case 4://装备洗练
return StrDictionary.GetClientDictionaryString("#{6218}");
}
return StrDictionary.GetClientDictionaryString("#{6214}");
case 4: //灵兽技能
switch (itemSubClass)
{
case 1://被动技能
return StrDictionary.GetClientDictionaryString("#{6203}");
case 2://自动技能
return StrDictionary.GetClientDictionaryString("#{6204}");
}
return StrDictionary.GetClientDictionaryString("#{6202}");
case 5: //经验丹书
return StrDictionary.GetClientDictionaryString("#{6205}");
case 6: //技能秘籍
switch (itemSubClass)
{
case 1://普通秘籍
return StrDictionary.GetClientDictionaryString("#{6220}");
case 2://绝技
return StrDictionary.GetClientDictionaryString("#{6221}");
}
return StrDictionary.GetClientDictionaryString("#{6219}");
case 7: //灵兽培养
switch (itemSubClass)
{
case 1://灵兽
return StrDictionary.GetClientDictionaryString("#{6223}");
case 2://灵兽道具
return StrDictionary.GetClientDictionaryString("#{6224}");
}
return StrDictionary.GetClientDictionaryString("#{6222}");
case 8: //生活技能
switch (itemSubClass)
{
case 1://采集
return StrDictionary.GetClientDictionaryString("#{6226}");
case 2://钓鱼
return StrDictionary.GetClientDictionaryString("#{6227}");
case 3://炼药
return StrDictionary.GetClientDictionaryString("#{6228}");
case 4://烹饪
return StrDictionary.GetClientDictionaryString("#{6229}");
case 5://工艺
return StrDictionary.GetClientDictionaryString("#{6230}");
}
return StrDictionary.GetClientDictionaryString("#{6225}");
case 9: //其他
switch (itemSubClass)
{
case 1://其他
return StrDictionary.GetClientDictionaryString("#{6231}");
case 2://藏宝图
return StrDictionary.GetClientDictionaryString("#{6232}");
case 3://礼包
return StrDictionary.GetClientDictionaryString("#{6233}");
case 4://珍品道具
return StrDictionary.GetClientDictionaryString("#{6236}");
}
return StrDictionary.GetClientDictionaryString("#{6231}");
}
return "";
}
public static string GetEquipClassName(int itemClass, int itemSubClass)
{
switch (itemClass)
{
case 20://等级
switch (itemSubClass)
{
case 1://0~69
return StrDictionary.GetClientDictionaryString("#{6251}");
case 2://70~89
return StrDictionary.GetClientDictionaryString("#{6252}");
case 3://90~109
return StrDictionary.GetClientDictionaryString("#{6253}");
case 4://110~129
return StrDictionary.GetClientDictionaryString("#{6254}");
case 5://130~150
return StrDictionary.GetClientDictionaryString("#{6255}");
}
return StrDictionary.GetClientDictionaryString("#{6250}");
case 21://大类
switch (itemSubClass)
{
case -1:
return StrDictionary.GetClientDictionaryString("#{6385}");
case 1://武器
return StrDictionary.GetClientDictionaryString("#{6257}");
case 2://头部
return StrDictionary.GetClientDictionaryString("#{6258}");
case 3://上衣
return StrDictionary.GetClientDictionaryString("#{6259}");
case 4://手套
return StrDictionary.GetClientDictionaryString("#{6260}");
case 5://手镯
return StrDictionary.GetClientDictionaryString("#{6261}");
case 6://鞋子
return StrDictionary.GetClientDictionaryString("#{6262}");
case 7://吊坠
return StrDictionary.GetClientDictionaryString("#{6263}");
case 8://戒指
return StrDictionary.GetClientDictionaryString("#{6264}");
case 9://副武器
return StrDictionary.GetClientDictionaryString("#{6265}");
case 10://腰带
return StrDictionary.GetClientDictionaryString("#{6266}");
}
return StrDictionary.GetClientDictionaryString("#{6256}");
case 1://小类
switch (itemSubClass)
{
case 1://天机
return StrDictionary.GetClientDictionaryString("#{6268}");
case 2://六扇
return StrDictionary.GetClientDictionaryString("#{6269}");
case 3://蜀山
return StrDictionary.GetClientDictionaryString("#{6270}");
case 4://玄女
return StrDictionary.GetClientDictionaryString("#{6271}");
}
return StrDictionary.GetClientDictionaryString("#{6267}");
case 2://小类
case 3://小类
switch (itemSubClass)
{
case 1://天机
return StrDictionary.GetClientDictionaryString("#{6272}");
case 2://六扇
return StrDictionary.GetClientDictionaryString("#{6273}");
case 3://蜀山
return StrDictionary.GetClientDictionaryString("#{6274}");
}
return StrDictionary.GetClientDictionaryString("#{6267}");
case 4://手套
return StrDictionary.GetClientDictionaryString("#{6260}");
case 5://手镯
return StrDictionary.GetClientDictionaryString("#{6261}");
case 6://鞋子
return StrDictionary.GetClientDictionaryString("#{6262}");
case 7://吊坠
return StrDictionary.GetClientDictionaryString("#{6263}");
case 8://戒指
return StrDictionary.GetClientDictionaryString("#{6264}");
case 9://副武器
return StrDictionary.GetClientDictionaryString("#{6265}");
case 10://腰带
return StrDictionary.GetClientDictionaryString("#{6266}");
case 22://品质
switch (itemSubClass)
{
case 2://绿
return StrDictionary.GetClientDictionaryString("#{6281}");
case 3://蓝
return StrDictionary.GetClientDictionaryString("#{6276}");
case 4://红
return StrDictionary.GetClientDictionaryString("#{6277}");
case 5://紫
return StrDictionary.GetClientDictionaryString("#{6278}");
case 6://鬼
return StrDictionary.GetClientDictionaryString("#{6279}");
}
return StrDictionary.GetClientDictionaryString("#{6275}");
case 30://法宝位置
switch (itemSubClass)
{
case 1://金
return StrDictionary.GetClientDictionaryString("#{6368}");
case 2://木
return StrDictionary.GetClientDictionaryString("#{6369}");
case 3://水
return StrDictionary.GetClientDictionaryString("#{6370}");
case 4://火
return StrDictionary.GetClientDictionaryString("#{6371}");
case 5://土
return StrDictionary.GetClientDictionaryString("#{6372}");
case -1:
return StrDictionary.GetClientDictionaryString("#{6385}");
}
return StrDictionary.GetClientDictionaryString("#{6373}");
case 31://法宝等级
switch (itemSubClass)
{
//case 1://金
// return StrDictionary.GetClientDictionaryString("#{6375}");
case 1://80
return StrDictionary.GetClientDictionaryString("#{6376}");
case 2://110
return StrDictionary.GetClientDictionaryString("#{6377}");
case 3://140
return StrDictionary.GetClientDictionaryString("#{6378}");
case 4://170
return StrDictionary.GetClientDictionaryString("#{6379}");
}
return StrDictionary.GetClientDictionaryString("#{6250}");
}
return "";
}
public class LevelPair
{
public int MinLevel;
public int MaxLevel;
}
public static Dictionary<int, LevelPair> _EquipLevelClass;
public static Dictionary<int, LevelPair> EquipLevelClass
{
get
{
if (_EquipLevelClass == null)
{
InitMarketLevel();
}
return _EquipLevelClass;
}
}
public static Dictionary<int, LevelPair> _MagicLevelClass;
public static Dictionary<int, LevelPair> MagicLevelClass
{
get
{
if (_MagicLevelClass == null)
{
InitMarketLevel();
}
return _MagicLevelClass;
}
}
private static void InitMarketLevel()
{
_EquipLevelClass = new Dictionary<int, LevelPair>();
_MagicLevelClass = new Dictionary<int, LevelPair>();
var equipLevelRecords = TableManager.GetMarketFilterLevel().Values;
foreach (var equipLvRecord in equipLevelRecords)
{
foreach(var item in equipLvRecord)
{
if (item.IsEquip == 1)
{
_EquipLevelClass.Add(item.Id, new LevelPair() { MinLevel = item.LevelMin, MaxLevel = item.LevelMax });
}
else
{
_MagicLevelClass.Add(item.Id, new LevelPair() { MinLevel = item.LevelMin, MaxLevel = item.LevelMax });
}
}
}
}
#endregion
#region search item
public static void SearchItem(List<int> searchItem, bool isInPublicity, bool isRare = false)
{
if (searchItem.Count == 1)
{
var historys = PlayerPreferenceData.GetMarketSearchHistory();
if (historys.Contains(searchItem[0]))
{
historys.Remove(searchItem[0]);
}
historys.Insert(0, searchItem[0]);
PlayerPreferenceData.SaveMarketSearchHistory();
}
//CG_ASK_CONSIGN_SALE_ITEMS_BY_ID packet = (CG_ASK_CONSIGN_SALE_ITEMS_BY_ID)PacketDistributed.CreatePacket(MessageID.PACKET_CG_ASK_CONSIGN_SALE_ITEMS_BY_ID);
//packet.DataId = searchItem.Id;
//packet.Minindex = 0;
//packet.Maxindex = 9;
//if (isInPublicity)
//{
// packet.Itemstate = (int)CG_ASK_CONSIGN_SALE_ITEMS_BY_CLASS.EUserShopItemState.EItemOnShow;
//}
//else
//{
// packet.Itemstate = (int)CG_ASK_CONSIGN_SALE_ITEMS_BY_CLASS.EUserShopItemState.EItemOnSale;
//}
//packet.SendPacket();
if (!isInPublicity)
{
MarketPlayerBuy.Instance().ShowItemList(searchItem, 10, 2);
}
else
{
MarketPlayerPublicity.Instance().ShowItemList(searchItem, 10, 2);
}
}
#endregion
#region show market item
public static void ShowDefault()
{
Hashtable hash = new Hashtable();
hash.Add("ShowItem", -1);
UIManager.ShowUI(UIInfo.MarketRoot, ShowMarketUIOver, hash);
}
public static void ShowMarketStr(string itemDataStr)
{
int itemData = int.Parse(itemDataStr);
ShowMarket(itemData);
}
public static void ShowSysMarketStr(string classTypeStr, string subClassTypeStr)
{
int classType = int.Parse(classTypeStr);
int subClassType = int.Parse(subClassTypeStr);
ShowSysMarket(classType, subClassType);
}
public static void ShowPlayerShopMarketStr(string classTypeStr, string subClassTypeStr)
{
int classType = int.Parse(classTypeStr);
int subClassType = int.Parse(subClassTypeStr);
ShowPlayerShopMarket(classType, subClassType);
}
public static void ShowMarket(int itemData)
{
Hashtable hash = new Hashtable();
hash.Add("ShowItem", itemData);
var functionOpenTab = TableManager.GetFunctionOpenByID(105, 0);
if (functionOpenTab == null)
{
return;
}
var _OpenVIPLevel = functionOpenTab.OpenVipLv;
if (GameManager.gameManager.PlayerDataPool.VipCost < _OpenVIPLevel)
{
GUIData.AddNotifyData(string.Format("当前VIP等级不足VIP等级{0}开放", _OpenVIPLevel));
return;
}
if (!MarketLogic.Instance())
{
UIManager.ShowUI(UIInfo.MarketRoot, ShowMarketUIOver, hash);
}
else
{
ShowItemPage(hash);
}
}
public static void ShowMarketFocus()
{
Hashtable hash = new Hashtable();
hash.Add("ShowFocus", true);
if (!MarketLogic.Instance())
{
UIManager.ShowUI(UIInfo.MarketRoot, ShowMarketUIOver, hash);
}
else
{
ShowItemFocus(hash);
}
}
public static void ShowSysMarket(int classType, int subClassType)
{
Hashtable hash = new Hashtable();
hash.Add("ClassType", classType);
hash.Add("SubClassType", subClassType);
if (!MarketLogic.Instance())
{
UIManager.ShowUI(UIInfo.MarketRoot, ShowMarketUIOver, hash);
}
else
{
ShowSysMarketPage(hash);
}
}
public static void ShowPlayerShopMarket(int classType, int subClassType)
{
Hashtable hash = new Hashtable();
hash.Add("ClassType", classType);
hash.Add("SubClassType", subClassType);
var functionOpenTab = TableManager.GetFunctionOpenByID(105, 0);
if (functionOpenTab == null)
{
return;
}
var _OpenVIPLevel = functionOpenTab.OpenVipLv;
if (GameManager.gameManager.PlayerDataPool.VipCost < _OpenVIPLevel)
{
GUIData.AddNotifyData(string.Format("当前VIP等级不足VIP等级{0}开放", _OpenVIPLevel));
return;
}
if (!MarketLogic.Instance())
{
UIManager.ShowUI(UIInfo.MarketRoot, ShowPlayShopByMenuType, hash);
}
else
{
ShowSysMarketPage(hash);
}
}
private static void ShowMarketUIOver(bool sucessed, object param)
{
Hashtable hash = param as Hashtable;
if (hash == null)
return;
if (hash.ContainsKey("ClassType"))
{
ShowSysMarketPage(hash);
}
else if (hash.ContainsKey("ShowItem"))
{
ShowItemPage(hash);
}
else if (hash.ContainsKey("ShowFocus"))
{
ShowItemFocus(hash);
}
}
private static void ShowSysMarketPage(Hashtable hash)
{
int classType = (int)hash["ClassType"];
int subClassType = (int)hash["SubClassType"];
MarketLogic.Instance()._TagPanel.ShowPage(0);
MarketLogic.Instance()._MarketSysLogic._TagPanel.ShowPage(0);
MarketLogic.Instance()._MarketSysLogic.OnMenuSelect(classType, subClassType);
}
private static void ShowPlayShopByMenuType(bool sucessed, object param)
{
Hashtable hash = param as Hashtable;
int classID = (int)hash["ClassType"];
int subClassID = (int)hash["SubClassType"];
MarketLogic.Instance()._TagPanel.ShowPage(1);
MarketLogic.Instance()._MarketPlayerLogic._TagPanel.ShowPage(0);
MarketPlayerBuy.Instance().OnMenuSelect(new Market.MarketItemClass(classID, subClassID));
}
private static void ShowItemPage(Hashtable hash)
{
int itemDataID = (int)hash["ShowItem"];
var sysTab = TableManager.GetExchangeMarketByID(itemDataID, 0);
if (sysTab != null)
{
MarketLogic.Instance()._TagPanel.ShowPage(0);
MarketLogic.Instance()._MarketSysLogic._TagPanel.ShowPage(0);
MarketLogic.Instance()._MarketSysLogic.OnMenuSelect(sysTab.ClassType, sysTab.ClassSubType, itemDataID);
return;
}
var playerTab = TableManager.GetUserShopItemByID(itemDataID, 0);
if (playerTab != null)
{
MarketLogic.Instance()._TagPanel.ShowPage(1);
MarketLogic.Instance()._MarketPlayerLogic._TagPanel.ShowPage(0);
Tab_ItemGetPath GetPath = TableManager.GetItemGetPathByID(itemDataID, 0);
if (GetPath != null )
{
string data = GetPath.GetItemPathbyIndex(5);
data = data.Trim('"');
int id = string.IsNullOrEmpty(data) ? -1 : Convert.ToInt32(data);
if(id == 1)
{
MarketPlayerBuy.Instance().OnMenuSelect(new Market.MarketItemClass(playerTab.ClassId, playerTab.SubClassId));
}
else
{
MarketPlayerBuy.Instance().ShowItemList(new List<int>() { itemDataID }, 10);
}
}
else
{
MarketPlayerBuy.Instance().ShowItemList(new List<int>() { itemDataID }, 10);
}
return;
}
}
private static void ShowItemFocus(Hashtable hash)
{
MarketLogic.Instance()._TagPanel.ShowPage(1);
MarketLogic.Instance()._MarketPlayerLogic._TagPanel.ShowPage(0);
if (MarketPlayerBuy.Instance())
{
MarketPlayerBuy.Instance().ShowFocusPage();
}
}
#endregion
#region player shop info
public static ulong ShopGUID;
public static string ShopName = "";
public static int ShopOpenTime;
public static int ShopSlotCnt;
public static int StoreMoney;
public static int MaintainMoney;
public static List<ulong> WatchItemGuids = new List<ulong>();
public static List<MarketPlayerListItemInfo> WatchItems = new List<MarketPlayerListItemInfo>();
public static void AskShopInfo()
{
ShopName = "";
CG_REQ_USER_SHOP_INFO shopInfo = (CG_REQ_USER_SHOP_INFO)PacketDistributed.CreatePacket(MessageID.PACKET_CG_REQ_USER_SHOP_INFO);
shopInfo.Guid = GameManager.gameManager.PlayerDataPool.MainPlayerBaseAttr.Guid;
shopInfo.SendPacket();
}
public static void SetShopInfo(GC_OPEN_USER_SHOP_RET packet)
{
ShopGUID = packet.StoredId;
ShopName = packet.StoreName;
ShopOpenTime = packet.OpenTm;
ShopSlotCnt = packet.OpenSlot;
StoreMoney = packet.StoreMoney;
MaintainMoney = packet.MaintainMoney;
WatchItemGuids.Clear();
for (int i = 0; i < packet.itemGuidCount; ++i)
{
WatchItemGuids.Add(packet.GetItemGuid(i));
}
MatchWatchItem();
if (MarketLogic.Instance())
{
if (MarketPlayerSell.Instance())
{
MarketPlayerSell.Instance().UpdateShopInfo();
}
else if (MarketPlayerBuy.Instance())
{
MarketPlayerBuy.Instance().UpdateShopInfo();
}
else if (MarketPlayerPublicity.Instance())
{
MarketPlayerPublicity.Instance().UpdateShopInfo();
}
}
}
private static void MatchWatchItem()
{
List<MarketPlayerListItemInfo> removeItems = new List<MarketPlayerListItemInfo>();
foreach (var watchItem in WatchItems)
{
if (!WatchItemGuids.Contains(watchItem.Guid))
{
removeItems.Add(watchItem);
}
}
foreach (var removeItem in removeItems)
{
WatchItems.Remove(removeItem);
}
}
public static void UpdateWatchItems(GC_RET_USER_SHOP_FOCUS_ITEMS packet)
{
WatchItems.Clear();
for (int i = 0; i < packet.dataidCount; ++i)
{
MarketPlayerListItemInfo item = new MarketPlayerListItemInfo();
item.DataId = packet.GetDataid(i);
item.Guid = packet.GetGuid(i);
item.IsWatched = packet.GetItemstate(i) == 0 ? 1 : 0;
item.Price = packet.GetPrice(i);
item.SellCnt = packet.GetStackcount(i);
item.WatchCnt = packet.GetFocusnum(i);
item.WatchTime = packet.GetOnsalcetm(i);
WatchItems.Add(item);
}
if (MarketPlayerBuy.Instance())
{
MarketPlayerBuy.Instance().UpdateShopInfo();
}
else if (MarketPlayerPublicity.Instance())
{
MarketPlayerPublicity.Instance().UpdateShopInfo();
}
}
#endregion
}