Files
JJBB/Assets/Project/Script/GUI/CaptainWelfare/CaptainWelfareWeekRewItem.cs

98 lines
3.2 KiB
C#
Raw Normal View History

2024-08-23 15:49:34 +08:00
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using GCGame.Table;
public class CaptainWelfareWeekRewItem : MonoBehaviour {
public Button _rewBtn;
public Text _val;
public GameObject _txObj;
public int _curItemIndex = -1;
private Tab_TeamLeaderAwardWeek weekRewTab = null;
public void InitItem(int teamWeekRewId)
{
_curItemIndex = teamWeekRewId;
weekRewTab = TableManager.GetTeamLeaderAwardWeekByID(teamWeekRewId, 0);
if(weekRewTab == null)
{
gameObject.SetActive(false);
return;
}
//默认的显示
RefreshItemState(_curRewItemState);
InitNeedExp();
}
private int _curRewNeedVal = -1;
private void InitNeedExp()
{
_curRewNeedVal = weekRewTab.WeekNeedExp;
_val.text = weekRewTab.WeekNeedExp.ToString();
}
private enum CAPTAINWEEKREWSTATE
{
NONE = 0, //不能领取
CAN, //可领取
GETTED, //已领取
}
private int _curRewItemState = 0;
public void RefreshItemState(int state)
{
_curRewItemState = state;
InitBGIcon();
if (CaptainWelfareRewPreviewCtr.Instance
&& CaptainWelfareRewPreviewCtr.Instance.gameObject.activeInHierarchy
&& CaptainWelfareRewPreviewCtr.Instance._CurIndex == _curItemIndex)
CaptainWelfareRewPreviewCtr.Instance.InitItemState(state);
}
public void InitBGIcon()
{
_txObj.SetActive(_curRewItemState == (int)CAPTAINWEEKREWSTATE.CAN);
_rewBtn.interactable = true;
switch (_curRewItemState)
{
case (int)CAPTAINWEEKREWSTATE.NONE:
LoadAssetBundle.Instance.SetImageSprite(_rewBtn.image, weekRewTab.IconBGPath, delegate (bool isSucess, GameObject obj) { _rewBtn.image.SetNativeSize(); });
break;
case (int)CAPTAINWEEKREWSTATE.CAN:
LoadAssetBundle.Instance.SetImageSprite(_rewBtn.image, weekRewTab.IconMarkBGPath, delegate (bool isSucess, GameObject obj) { _rewBtn.image.SetNativeSize(); });
break;
case (int)CAPTAINWEEKREWSTATE.GETTED:
LoadAssetBundle.Instance.SetImageSprite(_rewBtn.image, weekRewTab.IconGetedBGPath, delegate (bool isSucess, GameObject obj) { _rewBtn.image.SetNativeSize(); });
break;
}
}
public void OnItemClick()
{
//if (_curRewItemState == (int)CAPTAINWEEKREWSTATE.GETTED)
//{
// GUIData.AddNotifyData(StrDictionary.GetClientDictionaryString("#{2939}"));
// return;
//}
//if (_curRewItemState == (int)CAPTAINWEEKREWSTATE.NONE)
//{
// //提示还差多少Point
// if(CaptainWelfareRoot.Instance)
// GUIData.AddNotifyData(StrDictionary.GetClientDictionaryString("#{68004}", _curRewNeedVal- CaptainWelfareRoot.Instance._packet.exp_week));
//}else
//{
// ReqCetTeamLeaderAwardWeek req = new ReqCetTeamLeaderAwardWeek();
// req.index = _curItemIndex;
// req.SendMsg();
//}
CaptainWelfareRoot.Instance.OnWeekItemClick(_curItemIndex, _curRewItemState);
}
}