110 lines
3.4 KiB
C#
110 lines
3.4 KiB
C#
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
using UnityEngine.EventSystems;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using System;
|
|
using GCGame.Table;
|
|
|
|
public class MarketSystemItem : UIItemSelect
|
|
{
|
|
|
|
public Image _ItemIcon;
|
|
public Image _ItemQuality;
|
|
public Text _ItemName;
|
|
public UICurrencyItem _Price;
|
|
public Text _PriceUp;
|
|
public Text _PriceDown;
|
|
public Text _BuyLimit;
|
|
public Text _SellEmpty;
|
|
|
|
private ExchangeShopItem _ShowMarketItem;
|
|
public ExchangeShopItem ShowMarketItem
|
|
{
|
|
get
|
|
{
|
|
return _ShowMarketItem;
|
|
}
|
|
}
|
|
|
|
public override void Show(Hashtable hash)
|
|
{
|
|
base.Show();
|
|
|
|
var marketItem = (ExchangeShopItem)hash["InitObj"];
|
|
UpdateMarketItem(marketItem);
|
|
}
|
|
|
|
public void UpdateMarketItem(ExchangeShopItem marketItem)
|
|
{
|
|
if (_InitInfo != null)
|
|
{
|
|
(_InitInfo as ExchangeShopItem).HadBuyNum = marketItem.HadBuyNum;
|
|
}
|
|
_ShowMarketItem = marketItem;
|
|
var commonItem = TableManager.GetCommonItemByID(marketItem.DataId, 0);
|
|
var marketItemTab = TableManager.GetExchangeMarketByID(marketItem.DataId, 0);
|
|
|
|
_ItemQuality.gameObject.SetActive(true);
|
|
LoadAssetBundle.Instance.SetImageSprite(_ItemIcon, commonItem.Icon);
|
|
LoadAssetBundle.Instance.SetImageSprite(_ItemQuality, GCGame.Utils.GetItemQualityFrame(commonItem));
|
|
if (commonItem.QualityEffect > 0)
|
|
{
|
|
CommonItemContainerItem.ShowQualityEffect(true, commonItem.QualityEffect, _ItemIcon.transform);
|
|
}
|
|
else
|
|
{
|
|
CommonItemContainerItem.ShowQualityEffect(false, commonItem.QualityEffect, _ItemIcon.transform);
|
|
}
|
|
|
|
_ItemName.text = commonItem.Name;
|
|
if (marketItem.CurPrice < 0)
|
|
{
|
|
_SellEmpty.gameObject.SetActive(true);
|
|
_Price.gameObject.SetActive(false);
|
|
_PriceUp.gameObject.SetActive(false);
|
|
_PriceDown.gameObject.SetActive(false);
|
|
_BuyLimit.text = "";
|
|
}
|
|
else
|
|
{
|
|
_SellEmpty.gameObject.SetActive(false);
|
|
_Price.gameObject.SetActive(true);
|
|
_Price.ShowCurrency(MONEYTYPE.MONEYTYPE_YUANBAO_BIND, marketItem.NewPrice);
|
|
float delta = (marketItem.NewPrice - marketItem.CurPrice) / ((float)marketItem.CurPrice) * 100.0f;
|
|
if (delta > 0)
|
|
{
|
|
_PriceUp.gameObject.SetActive(true);
|
|
_PriceDown.gameObject.SetActive(false);
|
|
_PriceUp.text = string.Format("{0:0.00}", delta) + "%";
|
|
}
|
|
else if (delta < 0)
|
|
{
|
|
_PriceUp.gameObject.SetActive(false);
|
|
_PriceDown.gameObject.SetActive(true);
|
|
_PriceDown.text = string.Format("{0:0.00}", delta) + "%";
|
|
}
|
|
else
|
|
{
|
|
_PriceUp.gameObject.SetActive(false);
|
|
_PriceDown.gameObject.SetActive(false);
|
|
}
|
|
|
|
if (marketItemTab.LimitNum > 0)
|
|
{
|
|
_BuyLimit.text = StrDictionary.GetClientDictionaryString("#{9300}", marketItemTab.LimitNum - marketItem.HadBuyNum);
|
|
}
|
|
else
|
|
{
|
|
_BuyLimit.text = "";
|
|
}
|
|
}
|
|
}
|
|
|
|
public void OnShowItemTips()
|
|
{
|
|
ItemTooltipsLogic.ShowItemTooltip(_ShowMarketItem.DataId, ItemTooltipsLogic.ShowType.Info, transform.position);
|
|
OnItemClick();
|
|
}
|
|
}
|