138 lines
4.1 KiB
C#
138 lines
4.1 KiB
C#
|
using UnityEngine;
|
|||
|
using System.Collections;
|
|||
|
using UnityEngine.UI;
|
|||
|
using GCGame.Table;
|
|||
|
using System.Collections.Generic;
|
|||
|
|
|||
|
public class AdvanceWishPanelCtr : MonoBehaviour {
|
|||
|
|
|||
|
public Slider wishSlider;
|
|||
|
public Text valueDesc;
|
|||
|
public AdvanceStarPanelCtr starPanel;
|
|||
|
public int _CurWishValue;
|
|||
|
private Dictionary<int, int> GradeStarDic = new Dictionary<int, int>();
|
|||
|
|
|||
|
public Text _WishDesc; //祝福值作用描述
|
|||
|
public Text _WishDayDecDesc; //祝福值每日减少描述
|
|||
|
public void GetAllGradeStarCount()
|
|||
|
{
|
|||
|
var AllStarCountDic = TableManager.GetAdvanceBase().Values;
|
|||
|
GradeStarDic = new Dictionary<int, int>();
|
|||
|
foreach (var info in AllStarCountDic)
|
|||
|
{
|
|||
|
if((info.Id - info.Level) / 1000 -1 == curAdvanceType)
|
|||
|
{
|
|||
|
if (!GradeStarDic.ContainsKey(info.Grade))
|
|||
|
{
|
|||
|
GradeStarDic.Add(info.Grade, info.GradeTotalStar);
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
private int curAdvanceType;
|
|||
|
private int curBaseId;
|
|||
|
public void InitWishPanel(AdvanceInfo info)
|
|||
|
{
|
|||
|
//baseId
|
|||
|
curBaseId = (info.type + 1) * 1000 + info.level;
|
|||
|
Tab_AdvanceBase advanceBase = TableManager.GetAdvanceBaseByID(curBaseId, 0);
|
|||
|
if (advanceBase == null)
|
|||
|
{
|
|||
|
return;
|
|||
|
}
|
|||
|
|
|||
|
int nextBaseId = curBaseId + 1;
|
|||
|
Tab_AdvanceBase nextAdvanceBase = TableManager.GetAdvanceBaseByID(nextBaseId, 0);
|
|||
|
if (nextAdvanceBase == null)
|
|||
|
{
|
|||
|
return;
|
|||
|
}
|
|||
|
|
|||
|
//当前祝福值百分比
|
|||
|
wishSlider.value = (float)info.wish / (float)nextAdvanceBase.WishValueLimit;
|
|||
|
valueDesc.text = info.wish + "/" + nextAdvanceBase.WishValueLimit;
|
|||
|
_CurWishValue = info.wish;
|
|||
|
curAdvanceType = info.type;
|
|||
|
GetAllGradeStarCount();
|
|||
|
RefreshStarPanel(curBaseId);
|
|||
|
InitWishDesc();
|
|||
|
InitWishDayDecDesc(advanceBase.DayDecWishValuePercent > 0);
|
|||
|
}
|
|||
|
|
|||
|
public void InitWishDesc()
|
|||
|
{
|
|||
|
switch(curAdvanceType)
|
|||
|
{
|
|||
|
case (int)AdvanceBase.AdvanceType.Ride:
|
|||
|
{
|
|||
|
_WishDesc.gameObject.SetActive(false);
|
|||
|
}
|
|||
|
break;
|
|||
|
default:
|
|||
|
{
|
|||
|
_WishDesc.gameObject.SetActive(true);
|
|||
|
_WishDesc.text = StrDictionary.GetClientDictionaryString("#{42713}");
|
|||
|
}
|
|||
|
break;
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
|
|||
|
private int _CurAdvanceType = -1;
|
|||
|
public void RefreshWishPanel(AdvanceRetInfo info)
|
|||
|
{
|
|||
|
if(_CurAdvanceType != info.type)
|
|||
|
{
|
|||
|
GetAllGradeStarCount();
|
|||
|
_CurAdvanceType = info.type;
|
|||
|
}
|
|||
|
int baseId = (info.type + 1) * 1000 + info.level;
|
|||
|
Tab_AdvanceBase advanceBase = TableManager.GetAdvanceBaseByID(baseId, 0);
|
|||
|
if (advanceBase == null)
|
|||
|
{
|
|||
|
return;
|
|||
|
}
|
|||
|
|
|||
|
RefreshStarPanel(baseId);
|
|||
|
int nextBaseId = baseId + 1;
|
|||
|
Tab_AdvanceBase nextAdvanceBase = TableManager.GetAdvanceBaseByID(nextBaseId, 0);
|
|||
|
if (nextAdvanceBase == null)
|
|||
|
{
|
|||
|
return;
|
|||
|
}
|
|||
|
|
|||
|
//当前祝福值百分比
|
|||
|
wishSlider.value = (float)info.wish / (float)nextAdvanceBase.WishValueLimit;
|
|||
|
valueDesc.text = info.wish + "/" + nextAdvanceBase.WishValueLimit;
|
|||
|
_CurWishValue = info.wish;
|
|||
|
InitWishDayDecDesc(advanceBase.DayDecWishValuePercent > 0);
|
|||
|
}
|
|||
|
|
|||
|
public void InitWishDayDecDesc(bool _IsDec)
|
|||
|
{
|
|||
|
_WishDayDecDesc.text = StrDictionary.GetClientDictionaryString(_IsDec ? "#{42715}" : "#{42714}");
|
|||
|
}
|
|||
|
|
|||
|
public void RefreshStarPanel(int baseId)
|
|||
|
{
|
|||
|
Tab_AdvanceBase advanceBase = TableManager.GetAdvanceBaseByID(baseId, 0);
|
|||
|
if(advanceBase == null)
|
|||
|
{
|
|||
|
return;
|
|||
|
}
|
|||
|
|
|||
|
int curGradeStarCount = GradeStarDic.ContainsKey(advanceBase.Grade) ? GradeStarDic[advanceBase.Grade] : -1;
|
|||
|
if(curGradeStarCount == -1)
|
|||
|
{
|
|||
|
starPanel.gameObject.SetActive(false);
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
starPanel.gameObject.SetActive(true);
|
|||
|
starPanel.InitAdvaceStarItem(curGradeStarCount, advanceBase.Star);
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
}
|