备份CatanBuilding瘦身独立工程
This commit is contained in:
724
Assets/Scripts/UI/RewardItemNew.cs
Normal file
724
Assets/Scripts/UI/RewardItemNew.cs
Normal file
@@ -0,0 +1,724 @@
|
||||
using asap.core;
|
||||
using cfg;
|
||||
using Coffee.UIExtensions;
|
||||
using GameCore;
|
||||
using System.Collections.Generic;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
class ResAddEvent
|
||||
{
|
||||
public ResAddEvent(int id)
|
||||
{
|
||||
this.id = id;
|
||||
}
|
||||
public ResAddEvent(int id, int type, int subTyep)
|
||||
{
|
||||
this.id = id;
|
||||
this.Type = type;
|
||||
this.SubType = subTyep;
|
||||
}
|
||||
public int id;
|
||||
public int Type;
|
||||
public int SubType;
|
||||
/// <summary>
|
||||
/// 钞票 > 0 才使用
|
||||
/// </summary>
|
||||
public int addCount;
|
||||
}
|
||||
public class RewardItemNew : MonoBehaviour
|
||||
{
|
||||
private Tables _tables => GContext.container.Resolve<Tables>();
|
||||
public Button btn_click;
|
||||
public Animation ani;
|
||||
//public Image bgLight;
|
||||
public Image icon;
|
||||
public Image icon_card;
|
||||
public Image icon_card_logo;
|
||||
public Image icon_card_num;
|
||||
public Image icon_rod;
|
||||
public TMP_Text text_num;
|
||||
public TMP_Text text_title;
|
||||
public GameObject received;
|
||||
public CanvasGroup canvasGroup;
|
||||
public Transform reward_show;
|
||||
Transform RewardShow
|
||||
{
|
||||
get
|
||||
{
|
||||
if (reward_show == null)
|
||||
{
|
||||
reward_show = transform.Find("reward_show");
|
||||
}
|
||||
return reward_show;
|
||||
}
|
||||
}
|
||||
public RewardItemTransfer transfer;
|
||||
[HideInInspector]
|
||||
public int id = 0;
|
||||
private int showDropID = -1;
|
||||
private float count = 0;
|
||||
cfg.Item item;
|
||||
bool isEnable = true;
|
||||
Coffee.UIExtensions.UIParticleAttractor uIParticleAttractor;
|
||||
#if UNITY_EDITOR
|
||||
private void Reset()
|
||||
{
|
||||
InitPanel();
|
||||
}
|
||||
#endif
|
||||
private void Awake()
|
||||
{
|
||||
Transform icon_review = transform.Find("icon_review");
|
||||
if (icon_review != null)
|
||||
{
|
||||
icon_review.gameObject.SetActive(false);
|
||||
}
|
||||
}
|
||||
private void InitPanel()
|
||||
{
|
||||
canvasGroup = GetComponent<CanvasGroup>();
|
||||
btn_click = GetComponent<Button>();
|
||||
ani = GetComponent<Animation>();
|
||||
//bgLight = transform.Find("light").GetComponent<Image>();
|
||||
reward_show = transform.Find("reward_show");
|
||||
icon = transform.Find("icon").GetComponent<Image>();
|
||||
icon_card = transform.Find("icon_card").GetComponent<Image>();
|
||||
icon_card_logo = transform.Find("icon_card/logo").GetComponent<Image>();
|
||||
icon_card_num = transform.Find("icon_card/num").GetComponent<Image>();
|
||||
icon_rod = transform.Find("icon_rod").GetComponent<Image>();
|
||||
text_num = transform.Find("text_num").GetComponent<TMP_Text>();
|
||||
received = transform.Find("received").gameObject;
|
||||
text_title = transform.Find("text_title").GetComponent<TMP_Text>();
|
||||
}
|
||||
private void Start()
|
||||
{
|
||||
btn_click.onClick.AddListener(OnClick);
|
||||
}
|
||||
public void PlayOpen(bool reward_fishturntable_open = false)
|
||||
{
|
||||
if (reward_fishturntable_open)
|
||||
{
|
||||
ani.Play("reward_fishturntable_open");
|
||||
}
|
||||
else
|
||||
{
|
||||
ani.Play("reward_common_open");
|
||||
}
|
||||
}
|
||||
public void PlayOpen(string aniName)
|
||||
{
|
||||
ani.Play(aniName);
|
||||
}
|
||||
public async System.Threading.Tasks.Task PlayClose()
|
||||
{
|
||||
ani.Play("reward_common_close");
|
||||
await Awaiters.Seconds(0.3f);
|
||||
}
|
||||
public void SetReceived(bool _isReceived)
|
||||
{
|
||||
received.SetActive(_isReceived);
|
||||
}
|
||||
|
||||
void OnClick()
|
||||
{
|
||||
if (id > 0)
|
||||
{
|
||||
GContext.container.Resolve<PlayerItemData>().ShowItemTips(id, transform, count);
|
||||
}
|
||||
else if (showDropID > 0)
|
||||
{
|
||||
item_sanddig_tips.Show(transform.position, showDropID);
|
||||
}
|
||||
}
|
||||
public void SetRewardPopupData(ItemData itemData, bool isCanClick = true)
|
||||
{
|
||||
if (itemData == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
SetData(itemData, isCanClick: isCanClick);
|
||||
}
|
||||
public bool ParticleAttractorCheck(bool classification = false)
|
||||
{
|
||||
PlayClose();
|
||||
Item flyItem = item;
|
||||
float showCount = count;
|
||||
Image curIcon = icon;
|
||||
if (transfer != null && transfer.data != null)
|
||||
{
|
||||
curIcon = transfer.icon;
|
||||
flyItem = _tables.TbItem.GetOrDefault(transfer.data.exchangeId);
|
||||
showCount = transfer.data.exchangeCount;
|
||||
}
|
||||
if (flyItem == null || flyItem.Type == 12 || (flyItem.Type == 7 && flyItem.SubType == 1))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
string fxName = flyItem.Fx;
|
||||
ResAddEvent resAddEvent = new ResAddEvent(flyItem.ID, flyItem.Type, flyItem.SubType);
|
||||
resAddEvent.addCount = (int)showCount;
|
||||
if (string.IsNullOrEmpty(fxName))
|
||||
{
|
||||
GContext.Publish(resAddEvent);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (RewardShow == null)
|
||||
{
|
||||
GContext.Publish(resAddEvent);
|
||||
return false;
|
||||
}
|
||||
|
||||
Transform fxP = null;
|
||||
//1001 1002 另外一种配法
|
||||
if (classification)
|
||||
{
|
||||
ItemShow itemShow = _tables.TbItemShow.GetOrDefault(flyItem.ID);
|
||||
if (itemShow != null)
|
||||
{
|
||||
if (flyItem.ID == 1002)
|
||||
{
|
||||
showCount = (showCount / GContext.container.Resolve<PlayerItemData>().ExtraCoinMag());
|
||||
}
|
||||
fxName = itemShow.Fx[0];
|
||||
for (int i = itemShow.Count.Count - 1; i >= 0; i--)
|
||||
{
|
||||
if (showCount > itemShow.Count[i])
|
||||
{
|
||||
fxName = itemShow.Fx[i + 1];
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fxP = reward_show.Find(fxName);
|
||||
|
||||
if (fxP == null)
|
||||
{
|
||||
GContext.Publish(resAddEvent);
|
||||
return false;
|
||||
}
|
||||
GameObject fx = Instantiate(fxP.gameObject, reward_show);
|
||||
ParticleSystem particleSystem = fx.transform.Find("Scale/quan03").GetComponent<ParticleSystem>();
|
||||
if (particleSystem != null)
|
||||
{
|
||||
reward_show.gameObject.SetActive(true);
|
||||
fx.transform.position = transform.position;
|
||||
ParticleAttractorData particleAttractorData = new ParticleAttractorData()
|
||||
{
|
||||
IgnorePack = true,
|
||||
Type = flyItem.Type,
|
||||
SubType = flyItem.SubType,
|
||||
Priority = -1,
|
||||
};
|
||||
GContext.Publish(particleAttractorData);
|
||||
if (particleAttractorData.Priority > -1 && particleAttractorData.uIParticleAttractorCenter != null)
|
||||
{
|
||||
var particleRenderer = particleSystem.GetComponent<ParticleSystemRenderer>();
|
||||
var sprite = curIcon.sprite;
|
||||
if (sprite == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
//多个粒子飞向同一个target时,隐藏前一个粒子
|
||||
var uIParticleAttractorCenter = particleAttractorData.uIParticleAttractorCenter;
|
||||
var particleAttractor = uIParticleAttractorCenter.GetUIParticleAttractor();
|
||||
particleAttractor?.Clear();
|
||||
uIParticleAttractor = particleAttractor;
|
||||
Texture texture = sprite.texture;// await GContext.container.Resolve<IUIService>().GetTexture(item.Icon, "RewardPopupPanel");
|
||||
if (!enabled)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
//_TextureSample0
|
||||
particleRenderer.material.SetTexture("_TextureSample0", texture);
|
||||
particleRenderer.material.SetTextureScale("_TextureSample0", new Vector2(sprite.textureRect.width / texture.width, sprite.textureRect.height / texture.height));
|
||||
particleRenderer.material.SetTextureOffset("_TextureSample0", new Vector2(sprite.textureRect.x / texture.width, sprite.textureRect.y / texture.height));
|
||||
particleSystem.Clear();
|
||||
|
||||
var main = particleSystem.main;
|
||||
int maxCount = main.maxParticles;
|
||||
if (showCount < maxCount)
|
||||
{
|
||||
int addCount = (int)showCount;
|
||||
main.maxParticles = addCount;
|
||||
//var emission = particleSystem.emission;
|
||||
//emission.rateOverTime = 0;
|
||||
//emission.SetBursts(new ParticleSystem.Burst[] { new ParticleSystem.Burst(0.0f, addCount) });
|
||||
}
|
||||
particleAttractor.particleSystem = particleSystem;
|
||||
|
||||
AwaitFly(fx, particleAttractor, particleSystem, resAddEvent);
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
Destroy(fx);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Destroy(fx);
|
||||
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
async void AwaitFly(GameObject fx, UIParticleAttractor particleAttractor, ParticleSystem particleSystem, ResAddEvent resAddEvent)
|
||||
{
|
||||
await Awaiters.Seconds(0.3f);
|
||||
fx.SetActive(true);
|
||||
if (particleAttractor != null)
|
||||
{
|
||||
particleAttractor.enabled = true;
|
||||
}
|
||||
await Awaiters.Seconds(0.8f);
|
||||
GContext.Publish(resAddEvent);
|
||||
if (!enabled)
|
||||
{
|
||||
Destroy(fx);
|
||||
return;
|
||||
}
|
||||
await Awaiters.Seconds(1.2f);
|
||||
Destroy(fx);
|
||||
|
||||
if (particleAttractor != null && particleAttractor.particleSystem == particleSystem)
|
||||
{
|
||||
particleAttractor.Clear();
|
||||
particleAttractor.enabled = false;
|
||||
particleAttractor = null;
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 资源粒子飞入,只是表现
|
||||
/// </summary>
|
||||
/// <param name="classification">钞票有一套数量转换规则</param>
|
||||
/// <param name="ignorePack">有时候资源飞入要忽略 ParticleAttractorData.Type == -1 的全资源收集器,(比如 临时背包按钮) </param>
|
||||
/// <returns></returns>
|
||||
public async System.Threading.Tasks.Task ParticleAttractor(bool classification = false, bool ignorePack = false)
|
||||
{
|
||||
Item flyItem = item;
|
||||
float showCount = count;
|
||||
Image curIcon = icon;
|
||||
if (transfer != null && transfer.data != null)
|
||||
{
|
||||
curIcon = transfer.icon;
|
||||
flyItem = _tables.TbItem.GetOrDefault(transfer.data.exchangeId);
|
||||
showCount = transfer.data.exchangeCount;
|
||||
}
|
||||
if (flyItem == null || flyItem.Type == 12 || (flyItem.Type == 7 && flyItem.SubType == 1))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
ResAddEvent resAddEvent = new ResAddEvent(flyItem.ID, flyItem.Type, flyItem.SubType);
|
||||
resAddEvent.addCount = (int)showCount;
|
||||
string fxName = flyItem.Fx;
|
||||
|
||||
if (string.IsNullOrEmpty(fxName))
|
||||
{
|
||||
GContext.Publish(resAddEvent);
|
||||
return;
|
||||
}
|
||||
|
||||
if (RewardShow == null)
|
||||
{
|
||||
GContext.Publish(resAddEvent);
|
||||
return;
|
||||
}
|
||||
|
||||
Transform fxP = null;
|
||||
//1001 1002 另外一种配法
|
||||
if (classification)
|
||||
{
|
||||
ItemShow itemShow = _tables.TbItemShow.GetOrDefault(flyItem.ID);
|
||||
if (itemShow != null)
|
||||
{
|
||||
if (flyItem.ID == 1002)
|
||||
{
|
||||
showCount = (showCount / GContext.container.Resolve<PlayerItemData>().ExtraCoinMag());
|
||||
}
|
||||
fxName = itemShow.Fx[0];
|
||||
for (int i = itemShow.Count.Count - 1; i >= 0; i--)
|
||||
{
|
||||
if (showCount > itemShow.Count[i])
|
||||
{
|
||||
fxName = itemShow.Fx[i + 1];
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fxP = reward_show.Find(fxName);
|
||||
|
||||
if (fxP == null)
|
||||
{
|
||||
GContext.Publish(resAddEvent);
|
||||
return;
|
||||
}
|
||||
GameObject fx = Instantiate(fxP.gameObject, reward_show);
|
||||
ParticleSystem particleSystem = fx.transform.Find("Scale/quan03").GetComponent<ParticleSystem>();
|
||||
if (particleSystem != null)
|
||||
{
|
||||
reward_show.gameObject.SetActive(true);
|
||||
fx.transform.position = transform.position;
|
||||
ParticleAttractorData particleAttractorData = new ParticleAttractorData()
|
||||
{
|
||||
IgnorePack = ignorePack,
|
||||
Type = flyItem.Type,
|
||||
SubType = flyItem.SubType,
|
||||
Priority = -1,
|
||||
};
|
||||
GContext.Publish(particleAttractorData);
|
||||
if (particleAttractorData.Priority > -1 && particleAttractorData.uIParticleAttractorCenter != null)
|
||||
{
|
||||
var particleRenderer = particleSystem.GetComponent<ParticleSystemRenderer>();
|
||||
var sprite = curIcon.sprite;
|
||||
if (sprite == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
//多个粒子飞向同一个target时,隐藏前一个粒子
|
||||
var uIParticleAttractorCenter = particleAttractorData.uIParticleAttractorCenter;
|
||||
UIParticleAttractor particleAttractor = uIParticleAttractorCenter.GetUIParticleAttractor();
|
||||
particleAttractor?.Clear();
|
||||
uIParticleAttractor = particleAttractor;
|
||||
Texture texture = sprite.texture;// await GContext.container.Resolve<IUIService>().GetTexture(item.Icon, "RewardPopupPanel");
|
||||
if (!isEnable)
|
||||
{
|
||||
return;
|
||||
}
|
||||
//_TextureSample0
|
||||
particleRenderer.material.SetTexture("_TextureSample0", texture);
|
||||
particleRenderer.material.SetTextureScale("_TextureSample0", new Vector2(sprite.textureRect.width / texture.width, sprite.textureRect.height / texture.height));
|
||||
particleRenderer.material.SetTextureOffset("_TextureSample0", new Vector2(sprite.textureRect.x / texture.width, sprite.textureRect.y / texture.height));
|
||||
particleSystem.Clear();
|
||||
|
||||
var main = particleSystem.main;
|
||||
int maxCount = main.maxParticles;
|
||||
if (showCount < maxCount)
|
||||
{
|
||||
int addCount = (int)showCount;
|
||||
main.maxParticles = addCount;
|
||||
//var emission = particleSystem.emission;
|
||||
//emission.rateOverTime = 0;
|
||||
//emission.SetBursts(new ParticleSystem.Burst[] { new ParticleSystem.Burst(0.0f, addCount) });
|
||||
}
|
||||
fx.SetActive(true);
|
||||
if (particleAttractor != null)
|
||||
{
|
||||
particleAttractor.particleSystem = particleSystem;
|
||||
particleAttractor.enabled = true;
|
||||
}
|
||||
await Awaiters.Seconds(0.8f);
|
||||
if (!isEnable)
|
||||
{
|
||||
return;
|
||||
}
|
||||
GContext.Publish(resAddEvent);
|
||||
await Awaiters.Seconds(1.2f);
|
||||
if (!isEnable)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (particleAttractor != null && particleAttractor.particleSystem == particleSystem)
|
||||
{
|
||||
particleAttractor.Clear();
|
||||
particleAttractor.enabled = false;
|
||||
particleAttractor = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
Destroy(fx);
|
||||
}
|
||||
public void SetData(ItemData itemData, bool isCanClick = true, bool abbr = false, bool forceLight = false)
|
||||
{
|
||||
item = GContext.container.Resolve<Tables>().TbItem.GetOrDefault(itemData.id);
|
||||
|
||||
if (item == null)
|
||||
{
|
||||
GameDebug.LogWarning($"[PlayerItemData]AddItemCount: Not found id({itemData.id}) in DataMap");
|
||||
return;
|
||||
}
|
||||
|
||||
//Convert Universal TargetEvent TokenItem to cur TargetEvent ToeknItem
|
||||
if (item.Type == 10 && item.SubType == 11)
|
||||
{
|
||||
var tokenID = GContext.container.Resolve<FishingEventData>().collectingTargetInitTokenID;
|
||||
item = _tables.TbItem.GetOrDefault(tokenID);
|
||||
}
|
||||
if (item.Type == 7 && item.SubType == 1)
|
||||
{
|
||||
gameObject.SetActive(false);
|
||||
return;
|
||||
}
|
||||
if (transfer != null)
|
||||
{
|
||||
transfer.data = null;
|
||||
if (itemData.exchangeItemData != null
|
||||
&& itemData.exchangeItemData.exchangeCount > 0)
|
||||
{
|
||||
transfer.gameObject.SetActive(true);
|
||||
transfer.Init(itemData.exchangeItemData);
|
||||
}
|
||||
else
|
||||
{
|
||||
transfer.gameObject.SetActive(false);
|
||||
}
|
||||
}
|
||||
SetData(item, itemData.count, isCanClick, abbr, forceLight);
|
||||
}
|
||||
public void SetData(Item item, int count = 1, bool isCanClick = false, bool abbr = false, bool forceLight = false)
|
||||
{
|
||||
if (item == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
this.item = item;
|
||||
id = item.ID;
|
||||
showDropID = -1;
|
||||
this.count = count;
|
||||
gameObject.SetActive(true);
|
||||
SetReceived(false);
|
||||
canvasGroup.blocksRaycasts = isCanClick;
|
||||
//btn_click.enabled = isCanClick;
|
||||
icon.gameObject.SetActive(false);
|
||||
icon_card.gameObject.SetActive(false);
|
||||
icon_rod.gameObject.SetActive(false);
|
||||
string text;
|
||||
|
||||
//if (forceLight == true)
|
||||
//{
|
||||
// bgLight.gameObject.SetActive(true);
|
||||
//}
|
||||
//else
|
||||
//{
|
||||
// bgLight.gameObject.SetActive(item.Type == 3 && (item.SubType == 1 || item.SubType == 3));
|
||||
// if (item.Type == 3 && (item.SubType == 1 || item.SubType == 3))
|
||||
// {
|
||||
// GContext.container.Resolve<IUIService>().SetImageSprite(bgLight, $"light_event_challange_{item.Quality}", BasePanel.PanelName);
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// var lightIndex = item.Quality + 1 > 7 ? 7 : item.Quality + 1;
|
||||
// GContext.container.Resolve<IUIService>().SetImageSprite(bgLight, $"light_item_{lightIndex}", BasePanel.PanelName);
|
||||
// }
|
||||
//}
|
||||
|
||||
if (item.Type == 12)
|
||||
{
|
||||
text = LocalizationMgr.GetFormatTextValue("UI_PlayerGradePanel_2", count);
|
||||
}
|
||||
else if (item.Type == 2 && (item.SubType == 4 || item.SubType == 6))
|
||||
{
|
||||
text = $"{count}%";
|
||||
}
|
||||
else if (item.Type == 11 && item.SubType == 1)
|
||||
{
|
||||
var buff = _tables.TbFishBuff.GetOrDefault(item.RedirectID);
|
||||
text = LocalizationMgr.GetFormatTextValue("UI_COMMON_min", buff.CountDown / 60);
|
||||
//System.TimeSpan timeSpan = new System.TimeSpan();
|
||||
//if (buff.CountDown > 0)
|
||||
//{
|
||||
// timeSpan = new System.TimeSpan(0, 0, 0, buff.CountDown);
|
||||
//}
|
||||
//else if (buff.BuffParam is CollectionTargetExtraPoint)
|
||||
//{
|
||||
// timeSpan = GContext.container.Resolve<FishingEventData>().GetCollectingTargetEndTime() - ZZTimeHelper.UtcNow().UtcNowOffset();
|
||||
//}
|
||||
//else if (buff.BuffParam is SpMapExtraPoint)
|
||||
//{
|
||||
// timeSpan = GContext.container.Resolve<FishingEventData>().GetRankEndTime() - ZZTimeHelper.UtcNow().UtcNowOffset();
|
||||
//}
|
||||
//text = ConvertTools.ConvertTime2(timeSpan.Days, timeSpan.Hours, timeSpan.Minutes, timeSpan.Seconds);
|
||||
}
|
||||
else if (abbr || item.ID == 1002)
|
||||
{
|
||||
var num = ConvertTools.KeepThreeSignificantDigits(count);
|
||||
text = $"x{ConvertTools.GetNumberString(num)}";
|
||||
}
|
||||
else
|
||||
{
|
||||
text = $"x{ConvertTools.GetNumberString2(count)}";
|
||||
}
|
||||
if (item.Type == 5)
|
||||
{
|
||||
if (item.SubType == 1 || item.SubType == 2)
|
||||
{
|
||||
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(icon_card_logo, BgNameList[1], BasePanel.PanelName);
|
||||
uiService.SetImageSprite(icon_card_num, BgNameList[2], BasePanel.PanelName);
|
||||
icon_card.gameObject.SetActive(true);
|
||||
}
|
||||
}
|
||||
else if (item.Type == 3 && (item.SubType == 1 || item.SubType == 3))
|
||||
{
|
||||
icon_rod.gameObject.SetActive(true);
|
||||
GContext.container.Resolve<IUIService>().SetImageSprite(icon_rod, item.Icon, BasePanel.PanelName);
|
||||
}
|
||||
else if (item.Type == 11 && item.SubType == 1)
|
||||
{
|
||||
SetIcon(item.Icon);
|
||||
}
|
||||
else
|
||||
{
|
||||
SetIcon(item.Icon);
|
||||
text_num.gameObject.SetActive(true);
|
||||
}
|
||||
text_num.text = text;
|
||||
if (text_title != null)
|
||||
{
|
||||
text_title.text = LocalizationMgr.GetText(item.Name_l10n_key);
|
||||
}
|
||||
}
|
||||
|
||||
public void SetIcon(string iconName)
|
||||
{
|
||||
icon.gameObject.SetActive(true);
|
||||
GContext.container.Resolve<IUIService>().SetImageSprite(icon, iconName, BasePanel.PanelName);
|
||||
}
|
||||
public void SetData(int itemId, string text, bool isShowTipe = false)
|
||||
{
|
||||
if (transfer != null)
|
||||
{
|
||||
transfer.gameObject.SetActive(false);
|
||||
}
|
||||
|
||||
id = isShowTipe ? itemId : 0;
|
||||
|
||||
item = GContext.container.Resolve<Tables>().GetItemData(itemId);
|
||||
canvasGroup.blocksRaycasts = true;
|
||||
btn_click.enabled = true;
|
||||
text_num.text = text;
|
||||
if (text_title != null)
|
||||
{
|
||||
text_title.text = LocalizationMgr.GetText(item.Name_l10n_key);
|
||||
}
|
||||
//GContext.container.Resolve<IUIService>().SetImageSprite(icon, curItem.Icon, BasePanel.PanelName);
|
||||
icon.gameObject.SetActive(false);
|
||||
icon_card.gameObject.SetActive(false);
|
||||
icon_rod.gameObject.SetActive(false);
|
||||
if (item.Type == 5)
|
||||
{
|
||||
if (item.SubType == 1 || item.SubType == 2)
|
||||
{
|
||||
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(icon_card_logo, BgNameList[1], BasePanel.PanelName);
|
||||
uiService.SetImageSprite(icon_card_num, BgNameList[2], BasePanel.PanelName);
|
||||
icon_card.gameObject.SetActive(true);
|
||||
}
|
||||
}
|
||||
else if (item.Type == 3 && (item.SubType == 1 || item.SubType == 3))
|
||||
{
|
||||
icon_rod.gameObject.SetActive(true);
|
||||
GContext.container.Resolve<IUIService>().SetImageSprite(icon_rod, item.Icon, BasePanel.PanelName);
|
||||
}
|
||||
else if (item.Type == 11 && item.SubType == 1)
|
||||
{
|
||||
SetIcon(item.Icon);
|
||||
}
|
||||
else
|
||||
{
|
||||
SetIcon(item.Icon);
|
||||
}
|
||||
gameObject.SetActive(true);
|
||||
}
|
||||
public void SetData(string iconName, string textTitle, string textNum)
|
||||
{
|
||||
if (transfer != null)
|
||||
{
|
||||
transfer.gameObject.SetActive(false);
|
||||
}
|
||||
gameObject.SetActive(true);
|
||||
id = 0;
|
||||
item = null;
|
||||
if (text_num)
|
||||
{
|
||||
text_num.text = textNum;
|
||||
}
|
||||
if (text_title != null)
|
||||
{
|
||||
text_title.text = textTitle;
|
||||
}
|
||||
icon_card.gameObject.SetActive(false);
|
||||
SetIcon(iconName);
|
||||
}
|
||||
public void SetDropIcon(string iconName, int showDropID)
|
||||
{
|
||||
if (transfer != null)
|
||||
{
|
||||
transfer.gameObject.SetActive(false);
|
||||
}
|
||||
gameObject.SetActive(true);
|
||||
id = 0;
|
||||
item = null;
|
||||
if (text_num)
|
||||
{
|
||||
text_num.text = "";
|
||||
}
|
||||
if (text_title != null)
|
||||
{
|
||||
text_title.text = "";
|
||||
}
|
||||
this.showDropID = showDropID;
|
||||
canvasGroup.blocksRaycasts = true;
|
||||
btn_click.enabled = true;
|
||||
icon_card.gameObject.SetActive(false);
|
||||
SetIcon(iconName);
|
||||
}
|
||||
|
||||
private void OnDisable()
|
||||
{
|
||||
if (reward_show != null)
|
||||
{
|
||||
for (int i = reward_show.childCount - 1; i >= 0; i--)
|
||||
{
|
||||
Transform child = reward_show.GetChild(i);
|
||||
if (child != null && child.gameObject.activeSelf)
|
||||
{
|
||||
child.gameObject.SetActive(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void OnDestroy()
|
||||
{
|
||||
if (uIParticleAttractor != null)
|
||||
{
|
||||
uIParticleAttractor.enabled = false;
|
||||
uIParticleAttractor.particleSystem = null;
|
||||
uIParticleAttractor = null;
|
||||
}
|
||||
isEnable = false;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user