86 lines
2.6 KiB
C#
86 lines
2.6 KiB
C#
|
using GCGame.Table;
|
|||
|
using System.Collections;
|
|||
|
using System.Collections.Generic;
|
|||
|
using UnityEngine;
|
|||
|
using UnityEngine.UI;
|
|||
|
using Module.Log;
|
|||
|
|
|||
|
public class ActivityalRewItem : MonoBehaviour {
|
|||
|
|
|||
|
public Image _ItemQuality;
|
|||
|
public Image _ItemIcon;
|
|||
|
public Text _ItemValDesc;
|
|||
|
public Text _ItemCount;
|
|||
|
|
|||
|
public GameObject _CanGetMark;
|
|||
|
public GameObject _GetedMark;
|
|||
|
|
|||
|
private int _CurRewDataId = -1;
|
|||
|
private int _CurValId = -1;
|
|||
|
public void InitItem(int rewValId, float SliderWidth)
|
|||
|
{
|
|||
|
_CurValId = rewValId;
|
|||
|
var tab = TableManager.GetActivityValRewByID(rewValId, 0);
|
|||
|
if(tab == null)
|
|||
|
{
|
|||
|
LogModule.ErrorLog("在ActivityValRew表找不到对应的活力值 : " + rewValId);
|
|||
|
this.gameObject.SetActive(false);
|
|||
|
return;
|
|||
|
}
|
|||
|
_ItemCount.text = tab.ItemNum1 + "";
|
|||
|
_CurRewDataId = tab.ItemDataId;
|
|||
|
|
|||
|
var commonItem = TableManager.GetCommonItemByID(tab.ItemDataId, 0);
|
|||
|
if(commonItem == null)
|
|||
|
{
|
|||
|
LogModule.ErrorLog("在CommonItem表中找不到对应的物品 : " + tab.ItemDataId);
|
|||
|
this.gameObject.SetActive(false);
|
|||
|
return;
|
|||
|
}
|
|||
|
|
|||
|
LoadAssetBundle.Instance.SetImageSprite(_ItemIcon, commonItem.Icon);
|
|||
|
LoadAssetBundle.Instance.SetImageSprite(_ItemQuality, GCGame.Utils.GetItemQualityFrame(commonItem.Quality));
|
|||
|
|
|||
|
_ItemValDesc.text = rewValId + StrDictionary.GetClientDictionaryString("#{6013}");
|
|||
|
|
|||
|
PositionItem(rewValId, SliderWidth);
|
|||
|
}
|
|||
|
|
|||
|
void PositionItem(int _CurVal, float SliderWidth)
|
|||
|
{
|
|||
|
transform.localPosition = new Vector3(SliderWidth * ((float)_CurVal / (float)ActivityController.GetCurLevelMaxVal()), 0, 0);
|
|||
|
}
|
|||
|
|
|||
|
private int _CurRewItemState = 0; //默认不可领取
|
|||
|
public void RefreshItemState(int state) //0.不可 1.可 2. 已
|
|||
|
{
|
|||
|
_CurRewItemState = state;
|
|||
|
_CanGetMark.SetActive(state == 1);
|
|||
|
_GetedMark.SetActive(state == 2);
|
|||
|
}
|
|||
|
|
|||
|
public void OnItemIcon()
|
|||
|
{
|
|||
|
if(_CurRewItemState == 0)
|
|||
|
{
|
|||
|
ItemTooltipsLogic.ShowItemTooltip(_CurRewDataId, ItemTooltipsLogic.ShowType.Info, _ItemIcon.transform.position);
|
|||
|
return;
|
|||
|
}
|
|||
|
|
|||
|
if(_CurRewItemState == 1)
|
|||
|
{
|
|||
|
//申请领奖
|
|||
|
ReqGetDailyActValReward req = new ReqGetDailyActValReward();
|
|||
|
req.nodeId = _CurValId;
|
|||
|
req.SendMsg();
|
|||
|
return;
|
|||
|
}
|
|||
|
|
|||
|
if(_CurRewItemState == 2)
|
|||
|
{
|
|||
|
GUIData.AddNotifyData(StrDictionary.GetClientDictionaryString("#{2175}"));
|
|||
|
return;
|
|||
|
}
|
|||
|
}
|
|||
|
}
|