139 lines
3.5 KiB
C#
139 lines
3.5 KiB
C#
|
using System.Collections;
|
|||
|
using System.Collections.Generic;
|
|||
|
using UnityEngine;
|
|||
|
using GCGame.Table;
|
|||
|
|
|||
|
public class PvpRewPanel : MonoBehaviour {
|
|||
|
|
|||
|
public static PvpRewPanel Instance;
|
|||
|
void Awake()
|
|||
|
{
|
|||
|
Instance = this;
|
|||
|
}
|
|||
|
|
|||
|
void OnDestroy()
|
|||
|
{
|
|||
|
Instance = null;
|
|||
|
}
|
|||
|
|
|||
|
private void OnEnable()
|
|||
|
{
|
|||
|
ShowDefaultFirst();
|
|||
|
}
|
|||
|
|
|||
|
public void ShowDefaultFirst()
|
|||
|
{
|
|||
|
RefreshMenuItemRewState();
|
|||
|
if (_MenuIndex == -1)
|
|||
|
{
|
|||
|
OnMenuItemClick(0);
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
OnMenuItemClick(_MenuIndex);
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
public enum PvpRewType
|
|||
|
{
|
|||
|
Day = 0,
|
|||
|
Rank,
|
|||
|
Season,
|
|||
|
Segment,
|
|||
|
}
|
|||
|
|
|||
|
public List<GameObject> _MenuMarkIconList;
|
|||
|
public UIContainerBase _RewInfoItemContainer;
|
|||
|
|
|||
|
public GameObject _DayRewRedIcon;
|
|||
|
public GameObject _RankRewRedIcon;
|
|||
|
|
|||
|
public void RefreshMenuItemRewState()
|
|||
|
{
|
|||
|
ShowDayRewRedIcon();
|
|||
|
ShowSeasonRewRedIcon();
|
|||
|
}
|
|||
|
|
|||
|
public void ShowDayRewRedIcon()
|
|||
|
{
|
|||
|
_DayRewRedIcon.SetActive(GameManager.gameManager.PlayerDataPool.pvpIfo.IsDayHaveRew);
|
|||
|
}
|
|||
|
|
|||
|
public void ShowSeasonRewRedIcon()
|
|||
|
{
|
|||
|
_RankRewRedIcon.SetActive(GameManager.gameManager.PlayerDataPool.pvpIfo.IsSeasonHaveRew);
|
|||
|
}
|
|||
|
|
|||
|
private int _MenuIndex = -1;
|
|||
|
public void OnMenuItemClick(int _Index)
|
|||
|
{
|
|||
|
if (_MenuIndex == _Index)
|
|||
|
return;
|
|||
|
_MenuIndex = _Index;
|
|||
|
for (int index = 0; index < _MenuMarkIconList.Count; index++)
|
|||
|
{
|
|||
|
_MenuMarkIconList[index].SetActive(index == _Index);
|
|||
|
}
|
|||
|
InitRewContainer();
|
|||
|
}
|
|||
|
|
|||
|
//外部调用接口
|
|||
|
public void RefreshRewState()
|
|||
|
{
|
|||
|
RefreshMenuItemRewState();
|
|||
|
_RewInfoItemContainer.ForeachActiveItem<PvpRewInfoItem>( item => {
|
|||
|
item.RefreshRewState();
|
|||
|
});
|
|||
|
}
|
|||
|
|
|||
|
public void InitRewContainer()
|
|||
|
{
|
|||
|
List<PvpRewInfoStruct> rewList = new List<PvpRewInfoStruct>();
|
|||
|
switch (_MenuIndex)
|
|||
|
{
|
|||
|
case (int)PvpRewType.Day:
|
|||
|
{
|
|||
|
foreach(var info in TableManager.GetHonorBattlefieldAwardDay())
|
|||
|
{
|
|||
|
rewList.Add(new PvpRewInfoStruct(PvpRewType.Day, info.Key));
|
|||
|
}
|
|||
|
}
|
|||
|
break;
|
|||
|
case (int)PvpRewType.Season:
|
|||
|
{
|
|||
|
foreach (var info in TableManager.GetHonorBattlefieldAwardSeason())
|
|||
|
{
|
|||
|
rewList.Add(new PvpRewInfoStruct(PvpRewType.Season, info.Key));
|
|||
|
}
|
|||
|
}
|
|||
|
break;
|
|||
|
case (int)PvpRewType.Rank:
|
|||
|
{
|
|||
|
foreach (var info in TableManager.GetHonorBattlefieldAwardRank())
|
|||
|
{
|
|||
|
rewList.Add(new PvpRewInfoStruct(PvpRewType.Rank, info.Key));
|
|||
|
}
|
|||
|
}
|
|||
|
break;
|
|||
|
case (int)PvpRewType.Segment:
|
|||
|
{
|
|||
|
foreach (var info in TableManager.GetHonorBattlefieldSegment())
|
|||
|
{
|
|||
|
if (info.Key == 1)
|
|||
|
continue; //初始段位 不记录奖励
|
|||
|
|
|||
|
rewList.Add(new PvpRewInfoStruct(PvpRewType.Segment, info.Key));
|
|||
|
}
|
|||
|
}
|
|||
|
break;
|
|||
|
}
|
|||
|
_RewInfoItemContainer.InitContentItem(rewList);
|
|||
|
}
|
|||
|
|
|||
|
public void OnCloseBtn()
|
|||
|
{
|
|||
|
UIManager.CloseUI(UIInfo.PvpRewPanel);
|
|||
|
}
|
|||
|
|
|||
|
}
|