150 lines
4.3 KiB
C#
150 lines
4.3 KiB
C#
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
using System.Collections;
|
|
using Games.Item;
|
|
using System.Collections.Generic;
|
|
using GCGame.Table;
|
|
using Module.Log;
|
|
|
|
public class MarketItemClassPage : UIControllerBase<MarketItemClassPage>
|
|
{
|
|
// Use this for initialization
|
|
void OnEnable ()
|
|
{
|
|
SetInstance(this);
|
|
}
|
|
|
|
void OnDisable()
|
|
{
|
|
SetInstance(null);
|
|
}
|
|
|
|
// Update is called once per frame
|
|
void Update ()
|
|
{
|
|
|
|
}
|
|
|
|
#region item class
|
|
|
|
public GameObject _GotoSysMarketGO;
|
|
public Text _GotoSysMarketTips;
|
|
public UIContainerSelect _ItemClassContainer;
|
|
|
|
|
|
|
|
private int _ClassType;
|
|
private int _ClassSubType;
|
|
private bool _IsPublicity;
|
|
|
|
public void ShowItemClass(int itemType, int subType, bool isPublicity)
|
|
{
|
|
_ClassType = itemType;
|
|
_ClassSubType = subType;
|
|
_IsPublicity = isPublicity;
|
|
|
|
if (itemType == 3 && subType == 1)
|
|
{
|
|
_GotoSysMarketGO.SetActive(true);
|
|
_GotoSysMarketTips.text = StrDictionary.GetClientDictionaryString("#{6351}");
|
|
}
|
|
else if (itemType == 3 && subType == 2)
|
|
{
|
|
_GotoSysMarketGO.SetActive(true);
|
|
_GotoSysMarketTips.text = StrDictionary.GetClientDictionaryString("#{6352}");
|
|
}
|
|
else
|
|
{
|
|
_GotoSysMarketGO.SetActive(false);
|
|
}
|
|
|
|
CG_ASK_CONSIGN_SALE_ITEMS_BY_CLASS packet = (CG_ASK_CONSIGN_SALE_ITEMS_BY_CLASS)PacketDistributed.CreatePacket(MessageID.PACKET_CG_ASK_CONSIGN_SALE_ITEMS_BY_CLASS);
|
|
packet.Classid = _ClassType;
|
|
packet.Subclassid = _ClassSubType;
|
|
if (MarketPlayerBuy.Instance())
|
|
{
|
|
packet.ItemState = (int)CG_ASK_CONSIGN_SALE_ITEMS_BY_CLASS.EUserShopItemState.EItemOnSale;
|
|
}
|
|
else
|
|
{
|
|
packet.ItemState = (int)CG_ASK_CONSIGN_SALE_ITEMS_BY_CLASS.EUserShopItemState.EItemOnShow;
|
|
}
|
|
|
|
{
|
|
packet.Istreasure = 0;
|
|
}
|
|
|
|
packet.SendPacket();
|
|
}
|
|
|
|
|
|
|
|
public void UpdateClassPage(GC_RET_ASK_CONSIGNSALE_ITEMS_BY_CLASS packet)
|
|
{
|
|
var showItems = new Dictionary<int, MarketPlayerClassItemInfo>();
|
|
var shopItemTabs = TableManager.GetUserShopItem().Values;
|
|
foreach (var shopItem in shopItemTabs)
|
|
{
|
|
if (shopItem.ClassId == _ClassType && shopItem.SubClassId == _ClassSubType)
|
|
{
|
|
if (!_IsPublicity || shopItem.NoticeTm > 0)
|
|
{
|
|
if (!showItems.ContainsKey(shopItem.ShowItemID))
|
|
{
|
|
MarketPlayerClassItemInfo classInfo = new MarketPlayerClassItemInfo();
|
|
classInfo.DataId = shopItem.Id;
|
|
classInfo.ItemDatas = new List<int>() { shopItem.Id };
|
|
classInfo.SellCnt = 0;
|
|
showItems.Add(shopItem.Id, classInfo);
|
|
}
|
|
else
|
|
{
|
|
showItems[shopItem.ShowItemID].ItemDatas.Add(shopItem.Id);
|
|
}
|
|
}
|
|
|
|
}
|
|
}
|
|
|
|
for (int i = 0; i < packet.dataIdCount; ++i)
|
|
{
|
|
var shopItemTab = TableManager.GetUserShopItemByID(packet.GetDataId(i), 0);
|
|
if (showItems.ContainsKey(shopItemTab.ShowItemID))
|
|
{
|
|
showItems[shopItemTab.ShowItemID].SellCnt += packet.GetSellNum(i);
|
|
}
|
|
else
|
|
{
|
|
LogModule.ErrorLog("Class item error");
|
|
}
|
|
}
|
|
_ItemClassContainer.InitSelectContent(showItems.Values, null, OnSelectItem);
|
|
}
|
|
|
|
private void OnSelectItem(object selectObj)
|
|
{
|
|
MarketPlayerClassItemInfo showItem = selectObj as MarketPlayerClassItemInfo;
|
|
|
|
if (showItem == null)
|
|
return;
|
|
|
|
LogModule.DebugLog("OnSelectItem:" + showItem.DataId);
|
|
if (MarketPlayerBuy.Instance())
|
|
{
|
|
MarketPlayerBuy.Instance().ShowItemList(showItem.ItemDatas, showItem.SellCnt, 2);
|
|
}
|
|
else if (MarketPlayerPublicity.Instance())
|
|
{
|
|
MarketPlayerPublicity.Instance().ShowItemList(showItem.ItemDatas, showItem.SellCnt, 2);
|
|
}
|
|
}
|
|
|
|
public void OnGotoPage()
|
|
{
|
|
Market.ShowSysMarket(_ClassType, _ClassSubType);
|
|
}
|
|
|
|
#endregion
|
|
|
|
}
|