136 lines
4.0 KiB
C#
136 lines
4.0 KiB
C#
using UnityEngine;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine.UI;
|
|
using GCGame.Table;
|
|
|
|
public class WelfareSevenDayCtr : WelfarePageBaseCS{
|
|
|
|
public static WelfareSevenDayCtr Instance;
|
|
void Awake()
|
|
{
|
|
Instance = this;
|
|
}
|
|
|
|
private void OnDestroy()
|
|
{
|
|
Instance = null;
|
|
}
|
|
|
|
public override void OnPacketRec(NodePageInfoRet packet)
|
|
{
|
|
base.OnPacketRec(packet);
|
|
InitSubNodeMenuItem();
|
|
}
|
|
|
|
public List<WelfareSevenDayMenuItem> _SubNodeMenuItemList;
|
|
public void InitSubNodeMenuItem()
|
|
{
|
|
for (int index = 0; index < _Packet._SubNodeList.Count && index < _SubNodeMenuItemList.Count; index++)
|
|
{
|
|
_SubNodeMenuItemList[index].InitMenuItem(_Packet._SubNodeList[index]._SubNodeId, index, _Packet._SubNodeList[index]._SubNodeState);
|
|
}
|
|
|
|
ShowFirstCanGeted();
|
|
}
|
|
|
|
//点击可以领取的界面
|
|
public void ShowFirstCanGeted()
|
|
{
|
|
int _FirstCanRecIndex = 0;
|
|
for (int index = 0; index < _Packet._SubNodeList.Count; index++)
|
|
{
|
|
if (_Packet._SubNodeList[index]._SubNodeState == (int)WelfareRootCtr.WlfareRewardState.HasGeted)
|
|
{
|
|
_FirstCanRecIndex++;
|
|
}
|
|
}
|
|
if(_FirstCanRecIndex > 6)
|
|
{
|
|
_FirstCanRecIndex = 0;
|
|
}
|
|
OnSubNodeMenuItemClick(_FirstCanRecIndex);
|
|
}
|
|
|
|
public UIContainerBase _RewContainer;
|
|
private int _CurSelectIndex = 0;
|
|
public void OnSubNodeMenuItemClick(int _Index)
|
|
{
|
|
_CurSelectIndex = _Index;
|
|
_RewContainer.InitContentItem(_Packet._SubNodeList[_Index]._RewList);
|
|
InitDayDesc();
|
|
InitShowModel();
|
|
InitBtnDesc();
|
|
InitMenuItemSelectedObj();
|
|
}
|
|
|
|
public void InitMenuItemSelectedObj()
|
|
{
|
|
for(int index = 0; index < _SubNodeMenuItemList.Count; index++)
|
|
{
|
|
_SubNodeMenuItemList[index].ShowSelectedObj(index == _CurSelectIndex);
|
|
}
|
|
}
|
|
|
|
public Text _BtnDesc;
|
|
readonly string _lockColor = "<color=#7c8194>{0}</color>";
|
|
readonly string _UnLockColor = "<color=#745146>{0}</color>";
|
|
public void InitBtnDesc()
|
|
{
|
|
switch(_Packet._SubNodeList[_CurSelectIndex]._SubNodeState)
|
|
{
|
|
case (int)WelfareRootCtr.WlfareRewardState.CanGet:
|
|
case (int)WelfareRootCtr.WlfareRewardState.CanReCheck:
|
|
_BtnDesc.text = string.Format(_UnLockColor, StrDictionary.GetClientDictionaryString("#{42624}"));
|
|
break;
|
|
case (int)WelfareRootCtr.WlfareRewardState.HasGeted:
|
|
_BtnDesc.text =string.Format(_lockColor, StrDictionary.GetClientDictionaryString("#{42625}"));
|
|
break;
|
|
default:
|
|
_BtnDesc.text = string.Format(_UnLockColor, StrDictionary.GetClientDictionaryString("#{42623}"));
|
|
break;
|
|
}
|
|
}
|
|
|
|
public Image _DayDescIcon;
|
|
public List<Sprite> _DayDescSpriteList;
|
|
public void InitDayDesc()
|
|
{
|
|
_DayDescIcon.overrideSprite = _DayDescSpriteList[_CurSelectIndex];
|
|
}
|
|
|
|
public UICameraTexture _ModelCamera;
|
|
public void InitShowModel()
|
|
{
|
|
var charModel = TableManager.GetCharModelByID(_Packet._SubNodeList[_CurSelectIndex]._CharModelId, 0);
|
|
if(charModel == null)
|
|
{
|
|
_ModelCamera.gameObject.SetActive(false);
|
|
return;
|
|
}
|
|
|
|
_ModelCamera.InitModelPath(charModel.ResPath, charModel);
|
|
}
|
|
|
|
public void OnGetBtnClick()
|
|
{
|
|
ReqGetWelfareRew req = new ReqGetWelfareRew();
|
|
req._NodeId = _NodeId;
|
|
req._SubNodeId = _Packet._SubNodeList[_CurSelectIndex]._SubNodeId;
|
|
req.SendMsg();
|
|
}
|
|
|
|
public override void OnDisable()
|
|
{
|
|
base.OnDisable();
|
|
|
|
for(int index = 0; index < _SubNodeMenuItemList.Count; index++)
|
|
{
|
|
if(_SubNodeMenuItemList[index]._SelectedObj.activeInHierarchy)
|
|
{
|
|
_SubNodeMenuItemList[index]._SelectedObj.SetActive(false);
|
|
}
|
|
}
|
|
}
|
|
}
|