145 lines
3.9 KiB
C#
145 lines
3.9 KiB
C#
|
using UnityEngine;
|
|||
|
using System.Collections;
|
|||
|
using UnityEngine.UI;
|
|||
|
using System.Collections.Generic;
|
|||
|
using GCGame.Table;
|
|||
|
|
|||
|
public class AucationItem : MonoBehaviour {
|
|||
|
|
|||
|
#region
|
|||
|
public Image _ItemQuality;
|
|||
|
public Image itemIcon;
|
|||
|
|
|||
|
|
|||
|
public Image markIcon;
|
|||
|
public Image hasPutIntoIcon;
|
|||
|
public Image hasSoldOutIcon;
|
|||
|
public Image oneTalkPriceIcon;
|
|||
|
public Image rareIcon;
|
|||
|
|
|||
|
public Slider mSlider;
|
|||
|
public Text itemName;
|
|||
|
public Text remainGroups;
|
|||
|
public Text SliderShowCount;
|
|||
|
#endregion
|
|||
|
|
|||
|
public int snatchTreasureId = -1; //对应表的ID
|
|||
|
public enum ItemType
|
|||
|
{
|
|||
|
Normal = 1,
|
|||
|
Rare = 2,
|
|||
|
}
|
|||
|
|
|||
|
|
|||
|
public void InitItem(Tab_SnatchTreasure snatchTreasureTab)
|
|||
|
{
|
|||
|
snatchTreasureId = snatchTreasureTab.Id;
|
|||
|
Tab_CommonItem commonItem = TableManager.GetCommonItemByID(snatchTreasureTab.ItemId, 0);
|
|||
|
if(commonItem != null)
|
|||
|
{
|
|||
|
LoadAssetBundle.Instance.SetImageSprite(itemIcon, commonItem.Icon);
|
|||
|
LoadAssetBundle.Instance.SetImageSprite(_ItemQuality, GCGame.Utils.GetItemQualityFrame(commonItem.Quality));
|
|||
|
if (commonItem.QualityEffect > 0)
|
|||
|
{
|
|||
|
CommonItemContainerItem.ShowQualityEffect(true, commonItem.QualityEffect, itemIcon.transform);
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
CommonItemContainerItem.ShowQualityEffect(false, commonItem.QualityEffect, itemIcon.transform);
|
|||
|
}
|
|||
|
|
|||
|
itemName.text = commonItem.Name + " X " + snatchTreasureTab.ItemNum;
|
|||
|
}
|
|||
|
|
|||
|
if(snatchTreasureTab.ItemType == (int)ItemType.Rare)
|
|||
|
{
|
|||
|
if (!rareIcon.gameObject.activeInHierarchy)
|
|||
|
{
|
|||
|
rareIcon.gameObject.SetActive(true);
|
|||
|
}
|
|||
|
}else
|
|||
|
{
|
|||
|
if(rareIcon.gameObject.activeInHierarchy)
|
|||
|
{
|
|||
|
rareIcon.gameObject.SetActive(false);
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
public void InitItemInfo(CurPageItemInfo info)
|
|||
|
{
|
|||
|
Tab_SnatchTreasure snatachTab = TableManager.GetSnatchTreasureByID(info.snatchId, 0);
|
|||
|
if(snatachTab == null)
|
|||
|
{
|
|||
|
return;
|
|||
|
}
|
|||
|
|
|||
|
if(info.selfHadPutIntoCount > 0)
|
|||
|
{
|
|||
|
hasPutIntoIcon.gameObject.SetActive(true);
|
|||
|
}else
|
|||
|
{
|
|||
|
hasPutIntoIcon.gameObject.SetActive(false);
|
|||
|
}
|
|||
|
|
|||
|
if (info.curHadCompletedCount > snatachTab.MaxGropOpenPerDay)
|
|||
|
{
|
|||
|
hasSoldOutIcon.gameObject.SetActive(true);
|
|||
|
}else
|
|||
|
{
|
|||
|
hasSoldOutIcon.gameObject.SetActive(false);
|
|||
|
}
|
|||
|
|
|||
|
if (snatachTab.SelfBetMaxNum == 1)
|
|||
|
{
|
|||
|
if (!oneTalkPriceIcon.gameObject.activeInHierarchy)
|
|||
|
{
|
|||
|
oneTalkPriceIcon.gameObject.SetActive(true);
|
|||
|
}
|
|||
|
} else
|
|||
|
{
|
|||
|
if(oneTalkPriceIcon.isActiveAndEnabled)
|
|||
|
{
|
|||
|
oneTalkPriceIcon.gameObject.SetActive(false);
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
remainGroups.text = StrDictionary.GetClientDictionaryString("#{3159}", (snatachTab.MaxGropOpenPerDay - info.curHadCompletedCount + 1)); //当前剩余的组数
|
|||
|
|
|||
|
//计算当前的Slider
|
|||
|
mSlider.value = (float)info.curHadPutIntoCount / (float)snatachTab.TotalBetMaxNum;
|
|||
|
|
|||
|
SliderShowCount.text = info.curHadPutIntoCount + "/" + snatachTab.TotalBetMaxNum;
|
|||
|
|
|||
|
|
|||
|
}
|
|||
|
|
|||
|
//设置Toggle开关的背景遮罩
|
|||
|
public bool itemState = false;
|
|||
|
public void InitItemState(bool isOn)
|
|||
|
{
|
|||
|
itemState = isOn; //记录当前的状态
|
|||
|
if (isOn)
|
|||
|
{
|
|||
|
if (!markIcon.gameObject.activeInHierarchy)
|
|||
|
{
|
|||
|
markIcon.gameObject.SetActive(true);
|
|||
|
}
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
if (markIcon.gameObject.activeInHierarchy)
|
|||
|
{
|
|||
|
markIcon.gameObject.SetActive(false);
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
}
|
|||
|
|
|||
|
public void OnItemClick()
|
|||
|
{
|
|||
|
AucationingPanelCtr.Instance.OnAucationItemClick(snatchTreasureId);
|
|||
|
}
|
|||
|
|
|||
|
}
|