376 lines
11 KiB
C#
376 lines
11 KiB
C#
using UnityEngine;
|
|
using System.Collections;
|
|
using UnityEngine.UI;
|
|
using System.Collections.Generic;
|
|
using GCGame.Table;
|
|
|
|
public class FetterPanelCtr : MonoBehaviour
|
|
{
|
|
public static FetterPanelCtr Instance;
|
|
private void Awake()
|
|
{
|
|
Instance = this;
|
|
GetMaxLevel();
|
|
}
|
|
|
|
private void OnDestroy()
|
|
{
|
|
Instance = null;
|
|
}
|
|
|
|
public GameObject gradeInfoDescPanel;
|
|
public Text curGrade;
|
|
public Text nextGradeAttrDesc;
|
|
public Text incNeedConsumeDesc;
|
|
|
|
public UIImgText combatValue;
|
|
public List<MarryStar> starList;
|
|
public List<Text> attrList;
|
|
public Text myFetterLevelDesc;
|
|
public Text otherFeterLevelDesc;
|
|
public Text addPerDesc;
|
|
public GameObject loverLevelDescObj;
|
|
public GameObject nextGradeAddAtrDescObj;
|
|
public GameObject btnRedTip; // 按钮上的红点提示
|
|
|
|
private void OnEnable()
|
|
{
|
|
GetGradelIncAttrDic();
|
|
Refresh();
|
|
ReqFetterInfo(); //请求当前的页面信息
|
|
}
|
|
|
|
// 用于红点更新,用于确保红点更新数据完整
|
|
// 正式打开页面会重新执行一遍,待优化
|
|
public void PreInit()
|
|
{
|
|
Awake();
|
|
GetGradelIncAttrDic();
|
|
Refresh();
|
|
ReqFetterInfo(); //请求当前的页面信息
|
|
}
|
|
|
|
//<等阶, 增加属性百分比>
|
|
private Dictionary<int, int> _GradeCanIncAttrDic = new Dictionary<int, int>();
|
|
public void GetGradelIncAttrDic()
|
|
{
|
|
var _FetterBase = TableManager.GetMarryFetter().Values;
|
|
foreach (var info in _FetterBase)
|
|
{
|
|
if(!_GradeCanIncAttrDic.ContainsKey(info.FetterGrade))
|
|
{
|
|
_GradeCanIncAttrDic.Add(info.FetterGrade, info.IncPercent);
|
|
}
|
|
}
|
|
GetMaxGradeAndAttrCanInc();
|
|
}
|
|
|
|
private int _MaxCanIncAttrGrade = -1;
|
|
private int _MaxAttrCanInc = -1;
|
|
public void GetMaxGradeAndAttrCanInc()
|
|
{
|
|
foreach(var info in _GradeCanIncAttrDic)
|
|
{
|
|
if(info.Key > _MaxCanIncAttrGrade)
|
|
{
|
|
_MaxCanIncAttrGrade = info.Key;
|
|
}
|
|
|
|
if(info.Value > _MaxAttrCanInc)
|
|
{
|
|
_MaxAttrCanInc = info.Value;
|
|
}
|
|
}
|
|
}
|
|
|
|
public void ReqFetterInfo()
|
|
{
|
|
ReqMarryFetterData req = new ReqMarryFetterData();
|
|
req.flag = 1;
|
|
req.SendMsg();
|
|
}
|
|
|
|
private int curFettetLevel = 0;
|
|
private int curLoveValue = 0;
|
|
private int otherFetterLevel = 0;
|
|
public void OnReceivePacket(RetMarryFetterData packet)
|
|
{
|
|
curFettetLevel = packet.myFetterLv;
|
|
curLoveValue = packet.curLoving;
|
|
otherFetterLevel = packet.partnerFetterLv;
|
|
Refresh();
|
|
|
|
UpdataRedTips();
|
|
}
|
|
|
|
private int maxLevel = -1;
|
|
public void GetMaxLevel()
|
|
{
|
|
var tabDic = TableManager.GetMarryFetter().Values;
|
|
foreach (var info in tabDic)
|
|
{
|
|
if (maxLevel < info.ID)
|
|
{
|
|
maxLevel = info.ID;
|
|
}
|
|
}
|
|
}
|
|
|
|
public void InitConsumeDescPanel()
|
|
{
|
|
Tab_MarryFetter fetterTab = TableManager.GetMarryFetterByID(curFettetLevel, 0);
|
|
if(fetterTab == null)
|
|
{
|
|
return;
|
|
}
|
|
|
|
curGrade.text = StrDictionary.GetClientDictionaryString("#{46518}", fetterTab.FetterGrade);
|
|
|
|
Tab_MarryStarBase starBase = TableManager.GetMarryStarBaseByID(fetterTab.FetterGrade, 0);
|
|
if (starBase == null)
|
|
{
|
|
return;
|
|
}
|
|
|
|
if (curLoveValue < fetterTab.NextLevelNeedExp)
|
|
{
|
|
incNeedConsumeDesc.text = StrDictionary.GetClientDictionaryString("#{46517}", fetterTab.NextLevelNeedExp, curLoveValue);
|
|
}
|
|
else
|
|
{
|
|
incNeedConsumeDesc.text = StrDictionary.GetClientDictionaryString("#{46516}", fetterTab.NextLevelNeedExp, curLoveValue);
|
|
}
|
|
|
|
nextGradeAddAtrDescObj.SetActive(curFettetLevel < maxLevel);
|
|
if(nextGradeAddAtrDescObj.gameObject.activeInHierarchy)
|
|
{
|
|
if(curFettetLevel % 10 == 0 && curFettetLevel != 0) //显示下一阶
|
|
{
|
|
starBase = TableManager.GetMarryStarBaseByID(fetterTab.FetterGrade + 1, 0);
|
|
}
|
|
if(starBase == null)
|
|
{
|
|
nextGradeAddAtrDescObj.SetActive(false);
|
|
return;
|
|
}
|
|
string attrId = "#{" + (starBase.GetAttrIdbyIndex(curFettetLevel % 10) + 10000) + "}";
|
|
nextGradeAttrDesc.text = StrDictionary.GetClientDictionaryString("#{3472}", StrDictionary.GetClientDictionaryString(attrId), starBase.GetAttrValuebyIndex(curFettetLevel % 10));
|
|
}
|
|
}
|
|
|
|
public void InitCombat()
|
|
{
|
|
Tab_MarryFetter marryFetter = TableManager.GetMarryFetterByID(curFettetLevel, 0);
|
|
if(marryFetter == null)
|
|
{
|
|
return;
|
|
}
|
|
combatValue.text = marryFetter.CombatValue.ToString();
|
|
}
|
|
|
|
public void InitAttrList()
|
|
{
|
|
Tab_MarryFetter marryFetter = TableManager.GetMarryFetterByID(curFettetLevel, 0);
|
|
if (marryFetter == null)
|
|
{
|
|
return;
|
|
}
|
|
|
|
for (int index = 0; index < attrList.Count; index++)
|
|
{
|
|
if(marryFetter.GetAttrIdbyIndex(index) == -1)
|
|
{
|
|
attrList[index].gameObject.SetActive(false);
|
|
}
|
|
else
|
|
{
|
|
attrList[index].gameObject.SetActive(true);
|
|
string attrId = "#{" + (marryFetter.GetAttrIdbyIndex(index) + 10000) + "}";
|
|
attrList[index].text = StrDictionary.GetClientDictionaryString("#{2124}", StrDictionary.GetClientDictionaryString(attrId), marryFetter.GetAttrValuebyIndex(index));
|
|
}
|
|
}
|
|
}
|
|
|
|
public void InitMarryStar()
|
|
{
|
|
for(int index = 0; index < starList.Count; index++)
|
|
{
|
|
starList[index].GetComponent<MarryStar>().InitMarryAttrStar(curFettetLevel, index);
|
|
}
|
|
}
|
|
|
|
public void RefreshFetterPanel(RetMarryTrainFetterData packet)
|
|
{
|
|
curFettetLevel = packet.myFetterLv;
|
|
curLoveValue = packet.curLoving;
|
|
otherFetterLevel = packet.partnerFetterLv;
|
|
Refresh();
|
|
}
|
|
|
|
public void Refresh()
|
|
{
|
|
Tab_MarryFetter marryFetter = TableManager.GetMarryFetterByID(curFettetLevel, 0);
|
|
if (marryFetter == null)
|
|
{
|
|
return;
|
|
}
|
|
|
|
InitAttrList();
|
|
InitMarryStar();
|
|
InitCombat();
|
|
InitDescPanel();
|
|
if (curFettetLevel < maxLevel)
|
|
{
|
|
gradeInfoDescPanel.SetActive(true);
|
|
InitConsumeDescPanel();
|
|
}
|
|
else
|
|
{
|
|
gradeInfoDescPanel.SetActive(false);
|
|
}
|
|
}
|
|
|
|
public void InitDescPanel()
|
|
{
|
|
|
|
Tab_MarryFetter fetterTab = TableManager.GetMarryFetterByID(curFettetLevel, 0);
|
|
if (fetterTab == null)
|
|
{
|
|
return;
|
|
}
|
|
|
|
myFetterLevelDesc.text = curGrade.text = StrDictionary.GetClientDictionaryString("#{46518}", fetterTab.FetterGrade);
|
|
|
|
|
|
loverLevelDescObj.gameObject.SetActive(true);
|
|
var otherFetter = TableManager.GetMarryFetterByID(otherFetterLevel, 0);
|
|
if (fetterTab == null)
|
|
{
|
|
return;
|
|
}
|
|
otherFeterLevelDesc.text = StrDictionary.GetClientDictionaryString("#{46518}", otherFetter.FetterGrade);
|
|
|
|
int lowLevel = curFettetLevel < otherFetterLevel ? curFettetLevel : otherFetterLevel;
|
|
var lowFetterTab = TableManager.GetMarryFetterByID(lowLevel, 0);
|
|
if (lowFetterTab == null)
|
|
{
|
|
return;
|
|
}
|
|
|
|
int _LowGrade = lowFetterTab.FetterGrade;
|
|
if(_LowGrade >= _MaxCanIncAttrGrade)
|
|
{
|
|
addPerDesc.text = StrDictionary.GetClientDictionaryString("#{46530}", lowFetterTab.IncPercent);
|
|
}
|
|
else
|
|
{
|
|
//取第一个比_LowGrade大的
|
|
foreach(var info in _GradeCanIncAttrDic)
|
|
{
|
|
if(info.Key > _LowGrade)
|
|
{
|
|
addPerDesc.text = StrDictionary.GetClientDictionaryString("#{46522}", lowFetterTab.IncPercent, info.Key);
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
public bool IsGainMaxLevel()
|
|
{
|
|
return curFettetLevel >= maxLevel;
|
|
}
|
|
|
|
public void OnAdvanceBtnClick()
|
|
{
|
|
if (GameManager.gameManager.m_RunningScene == 658)
|
|
{
|
|
GUIData.AddNotifyData(GCGame.Table.StrDictionary.GetClientDictionaryString("#{79512}"));
|
|
return;
|
|
}
|
|
if (!GameManager.gameManager.PlayerDataPool.IsMarried)
|
|
{
|
|
GUIData.AddNotifyData(StrDictionary.GetClientDictionaryString("#{46514}"));
|
|
return;
|
|
}
|
|
|
|
if(IsGainMaxLevel())
|
|
{
|
|
GUIData.AddNotifyData(StrDictionary.GetClientDictionaryString("#{46519}"));
|
|
return;
|
|
}
|
|
|
|
//当前恩爱值是否足够
|
|
Tab_MarryFetter marryFetter = TableManager.GetMarryFetterByID(curFettetLevel, 0);
|
|
if (marryFetter == null)
|
|
{
|
|
return;
|
|
}
|
|
|
|
if(curLoveValue < marryFetter.NextLevelNeedExp)
|
|
{
|
|
GUIData.AddNotifyData(StrDictionary.GetClientDictionaryString("#{46520}"));
|
|
return;
|
|
}
|
|
|
|
ReqMarryTrainFetterData req = new ReqMarryTrainFetterData();
|
|
req.flag = 1;
|
|
req.SendMsg();
|
|
}
|
|
|
|
public void UpdataRedTips()
|
|
{
|
|
if(btnRedTip == null)
|
|
{
|
|
return;
|
|
}
|
|
|
|
if(HasRedPoint())
|
|
{
|
|
if (btnRedTip.activeSelf != true)
|
|
{
|
|
btnRedTip.SetActive(true);
|
|
MarryRoot.Instance.UpdateRedTips(MarryRoot.RedTipType.Fetter, true);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
btnRedTip.SetActive(false);
|
|
MarryRoot.Instance.UpdateRedTips(MarryRoot.RedTipType.Fetter, false);
|
|
}
|
|
}
|
|
|
|
public static bool HasRedPoint()
|
|
{
|
|
if(!GameManager.gameManager.PlayerDataPool.IsMarried)
|
|
{
|
|
return false;
|
|
}
|
|
|
|
int temp_curFettetLevel = GameManager.gameManager.PlayerDataPool.MyFetterData.MyFetterLv;
|
|
int temp_curLoveValue = GameManager.gameManager.PlayerDataPool.MyFetterData.CurLoving;
|
|
int temp_maxLevel = -1;
|
|
|
|
var tabDic = TableManager.GetMarryFetter().Values;
|
|
foreach (var info in tabDic)
|
|
{
|
|
if (temp_maxLevel < info.ID)
|
|
{
|
|
temp_maxLevel = info.ID;
|
|
}
|
|
}
|
|
|
|
if (!(temp_curFettetLevel >= temp_maxLevel))
|
|
{
|
|
//当前恩爱值是否足够
|
|
Tab_MarryFetter marryFetter = TableManager.GetMarryFetterByID(temp_curFettetLevel, 0);
|
|
if (marryFetter != null && temp_curLoveValue > marryFetter.NextLevelNeedExp)
|
|
{
|
|
return true;
|
|
}
|
|
}
|
|
|
|
return false;
|
|
}
|
|
}
|