备份CatanBuilding瘦身独立工程
This commit is contained in:
121
Assets/Scripts/UI/Turntable/TurntablelInfoRewardItem.cs
Normal file
121
Assets/Scripts/UI/Turntable/TurntablelInfoRewardItem.cs
Normal file
@@ -0,0 +1,121 @@
|
||||
using cfg;
|
||||
using UnityEngine;
|
||||
using TMPro;
|
||||
using GameCore;
|
||||
using asap.core;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class TurntablelInfoRewardItem : MonoBehaviour
|
||||
{
|
||||
|
||||
public WheelDrop wheelDrop;
|
||||
public WheelDrop preWheelDrop;
|
||||
UnityEngine.UI.Image icon;
|
||||
TMP_Text text_num;
|
||||
public int orignalNum = 0;
|
||||
public int rewardMulti = 1;
|
||||
ItemData itemData;
|
||||
GameObject newitem;
|
||||
GameObject arrow;
|
||||
Button btn_click;
|
||||
Image icon_card;
|
||||
Image logo;
|
||||
Image card_num;
|
||||
void Awake()
|
||||
{
|
||||
wheelDrop = null;
|
||||
text_num = transform.Find("text_num").GetComponent<TMP_Text>();
|
||||
icon = transform.Find("icon").GetComponent<UnityEngine.UI.Image>();
|
||||
newitem = transform.Find("new").gameObject;
|
||||
arrow = transform.Find("arrow").gameObject;
|
||||
|
||||
icon_card = transform.Find("icon_card").GetComponent<Image>();
|
||||
logo = transform.Find("icon_card/logo").GetComponent<Image>();
|
||||
card_num = transform.Find("icon_card/num").GetComponent<Image>();
|
||||
btn_click = GetComponent<Button>();
|
||||
}
|
||||
private void Start()
|
||||
{
|
||||
if (btn_click != null)
|
||||
{
|
||||
btn_click.onClick.AddListener(OnClick);
|
||||
}
|
||||
}
|
||||
|
||||
void OnClick()
|
||||
{
|
||||
if (itemData == null || itemData.id == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
GContext.container.Resolve<PlayerItemData>().ShowItemTips(itemData.id, transform);
|
||||
}
|
||||
public void Init()
|
||||
{
|
||||
int dropID = wheelDrop.DropID;
|
||||
if (GContext.container.Resolve<FishingEventData>().freecount > 0)
|
||||
{
|
||||
dropID = wheelDrop.ExtraDropID;
|
||||
text_num.gameObject.SetActive(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
text_num.gameObject.SetActive(wheelDrop.Type != 9);
|
||||
}
|
||||
itemData = GContext.container.Resolve<PlayerItemData>().GetItemDataOne(dropID);
|
||||
orignalNum = (int)itemData.count;
|
||||
UpDisplay();
|
||||
}
|
||||
public void UpDisplay()
|
||||
{
|
||||
arrow.SetActive(false);
|
||||
newitem.SetActive(false);
|
||||
text_num.text = ConvertTools.GetNumberString(orignalNum);
|
||||
var item = GContext.container.Resolve<Tables>().TbItem.Get(itemData.id);
|
||||
if (item.Type == 5)
|
||||
{
|
||||
IUIService uiService = GContext.container.Resolve<IUIService>();
|
||||
List<string> BgNameList;
|
||||
if (item.SubType == 1)
|
||||
{
|
||||
var fishCard = GContext.container.Resolve<Tables>().TbFishCardDrop.GetOrDefault(item.RedirectID);
|
||||
BgNameList = fishCard.BgNameList;
|
||||
}
|
||||
else
|
||||
{
|
||||
var fishCard = GContext.container.Resolve<Tables>().TbGeneralCardWeight.GetOrDefault(item.RedirectID);
|
||||
BgNameList = fishCard.BgNameList;
|
||||
}
|
||||
uiService.SetImageSprite(icon_card, BgNameList[0], BasePanel.PanelName);
|
||||
uiService.SetImageSprite(logo, BgNameList[1], BasePanel.PanelName);
|
||||
uiService.SetImageSprite(card_num, BgNameList[2], BasePanel.PanelName);
|
||||
icon_card.gameObject.SetActive(true);
|
||||
icon.gameObject.SetActive(false);
|
||||
}
|
||||
else
|
||||
{
|
||||
icon_card.gameObject.SetActive(false);
|
||||
icon.gameObject.SetActive(true);
|
||||
GContext.container.Resolve<IUIService>().SetImageSprite(icon, item.Icon, BasePanel.PanelName);
|
||||
}
|
||||
if (preWheelDrop != null)
|
||||
{
|
||||
int dropID = preWheelDrop.DropID;
|
||||
if (GContext.container.Resolve<FishingEventData>().freecount > 0)
|
||||
{
|
||||
dropID = preWheelDrop.ExtraDropID;
|
||||
}
|
||||
ItemData preItem = GContext.container.Resolve<PlayerItemData>().GetItemDataOne(dropID);
|
||||
if (itemData.id != preItem.id)
|
||||
{
|
||||
newitem.SetActive(true);
|
||||
}
|
||||
else if ((int)itemData.count > (int)preItem.count)
|
||||
{
|
||||
arrow.SetActive(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user