855 lines
30 KiB
C#
855 lines
30 KiB
C#
using UnityEngine;
|
||
using System.Collections;
|
||
using System.Collections.Generic;
|
||
using GCGame.Table;
|
||
using Module.Log;
|
||
using UnityEngine.UI;
|
||
|
||
public class AdvancePanelCtr : MonoBehaviour {
|
||
|
||
public List<AdvanceIncAttrItem> incAttrItemList;
|
||
public AdvanceInfo advanceInfo; // 页面初始化使用的进阶信息,每次接收到新的协议会更新
|
||
public AdvanceWishPanelCtr wishPanel;
|
||
public AdvanceItemPanelCtr itemPanel;
|
||
|
||
public GameObject modelPanel;
|
||
|
||
public GameObject canAdvancePanel;
|
||
public GameObject cantAdcancePanel;
|
||
|
||
public List<GameObject> attrIncList;
|
||
public GameObject advanceWishPanel;
|
||
public GameObject advanceItemPanel;
|
||
|
||
public GameObject maxLevelIcon;
|
||
|
||
public UICameraTexture curModelCameraTexture;
|
||
public UIImgText _CurCombatVal;
|
||
public UICameraTexture nextModelCameraTexture;
|
||
public UIImgText _NextCombatVal;
|
||
public UICameraTexture maxModelCmaeraTexture;
|
||
public UIImgText _MaxCombatVal;
|
||
|
||
//翅膀高度问题 上调80
|
||
public Transform _CurModelRawIamgeTrans;
|
||
public Transform _NextModelRawIamgeTrans;
|
||
|
||
public Text curModelGrade;
|
||
public Text curModelName;
|
||
public Text nextModelGrade;
|
||
public Text nextModelName;
|
||
public Text maxModelGrade;
|
||
public Text maxModelName;
|
||
|
||
public Transform wishValueTextParent;
|
||
public GameObject wishValueTextPrefab;
|
||
|
||
public bool isMaxLevel = false;
|
||
public static AdvancePanelCtr Instance;
|
||
|
||
private void Awake()
|
||
{
|
||
Instance = this;
|
||
InitWishFloatTextPool();
|
||
}
|
||
|
||
public void PreInit()
|
||
{
|
||
Awake();
|
||
}
|
||
|
||
public void InitAdvancePanel(AdvanceInfo info)
|
||
{
|
||
advanceInfo = info;
|
||
InitAdvancePanel(advanceInfo.baseId, advanceInfo.type, advanceInfo._RemainAdvanceItemCount);
|
||
}
|
||
|
||
|
||
private List<int> curTypeLevelBaseIdList;
|
||
private Dictionary<int, int> curTypeGradeModelIdDic;
|
||
|
||
private Tab_AdvanceBase maxAdvanceBase = null;
|
||
public Tab_AdvanceBase MaxAdvanceBase
|
||
{
|
||
get { return maxAdvanceBase; }
|
||
}
|
||
|
||
private int curAdvanceLevel; //当前进阶等级
|
||
public int CurAdvanceLevel
|
||
{
|
||
get { return curAdvanceLevel; }
|
||
}
|
||
|
||
private int curAdvanceGrade; //当前进阶等阶
|
||
public int CurAdvanceGrade
|
||
{
|
||
get { return curAdvanceGrade; }
|
||
}
|
||
|
||
private int curAdvanceBaseId;
|
||
public int CurAdvanceBaseId
|
||
{
|
||
get { return curAdvanceBaseId; }
|
||
}
|
||
|
||
private int curAdvanceType;//当前进阶类型
|
||
public void InitAdvancePanel(int baseId, int type, int remainItemCount)
|
||
{
|
||
curAdvanceType = type;
|
||
maxModelCmaeraTexture._CanDrag = AdvanceMountPanelCtr.Instance.m_AdvanceType == AdvanceBase.AdvanceType.Ride || AdvanceMountPanelCtr.Instance.m_AdvanceType == AdvanceBase.AdvanceType.Wing;
|
||
curTypeLevelBaseIdList = new List<int>();
|
||
curTypeGradeModelIdDic = new Dictionary<int, int>();
|
||
|
||
var allBaseDic = TableManager.GetAdvanceBase().Values;
|
||
foreach (var baseInfo in allBaseDic)
|
||
{
|
||
if (baseInfo.Id / 1000 - 1 == type)
|
||
{
|
||
curTypeLevelBaseIdList.Add(baseInfo.Id);
|
||
|
||
if (!curTypeGradeModelIdDic.ContainsKey(baseInfo.Grade))
|
||
{
|
||
curTypeGradeModelIdDic.Add(baseInfo.Grade, baseInfo.Id);
|
||
}
|
||
}
|
||
}
|
||
curTypeLevelBaseIdList.Sort(SortByLevel);
|
||
|
||
if (curTypeLevelBaseIdList.Count > 0)
|
||
maxAdvanceBase = TableManager.GetAdvanceBaseByID(curTypeLevelBaseIdList[curTypeLevelBaseIdList.Count - 1], 0);
|
||
if (maxAdvanceBase == null)
|
||
{
|
||
return;
|
||
}
|
||
|
||
Tab_AdvanceBase advanceBase = TableManager.GetAdvanceBaseByID(baseId, 0);
|
||
if (advanceBase == null)
|
||
{
|
||
return;
|
||
}
|
||
|
||
advanceWishPanel.gameObject.SetActive(advanceBase.Level < maxAdvanceBase.Level ? true : false);
|
||
advanceItemPanel.gameObject.SetActive(advanceBase.Level < maxAdvanceBase.Level ? true : false);
|
||
maxLevelIcon.gameObject.SetActive(advanceBase.Level < maxAdvanceBase.Level ? false : true);
|
||
//初始化AttrItem
|
||
InitAttrItem(baseId, (curTypeLevelBaseIdList.IndexOf(baseId) + 1) < curTypeLevelBaseIdList.Count ? curTypeLevelBaseIdList[curTypeLevelBaseIdList.IndexOf(baseId) + 1] : 0);
|
||
|
||
if (advanceWishPanel.activeInHierarchy)
|
||
{
|
||
wishPanel.InitWishPanel(advanceInfo);
|
||
}
|
||
|
||
//if (advanceItemPanel.activeInHierarchy)
|
||
//{
|
||
itemPanel.InitItemPanel(advanceInfo);
|
||
//}
|
||
|
||
modelPanel.SetActive(true);
|
||
canAdvancePanel.SetActive(advanceBase.Grade < maxAdvanceBase.Grade ? true : false);
|
||
cantAdcancePanel.SetActive(advanceBase.Grade < maxAdvanceBase.Grade ? false : true);
|
||
|
||
if (canAdvancePanel.activeInHierarchy)
|
||
{
|
||
|
||
if (curTypeGradeModelIdDic.ContainsKey(advanceBase.Grade) && curTypeGradeModelIdDic.ContainsKey(advanceBase.Grade + 1))
|
||
{
|
||
StartCoroutine(ShowMountModel(curTypeGradeModelIdDic[advanceBase.Grade], curTypeGradeModelIdDic[advanceBase.Grade + 1]));
|
||
}
|
||
}
|
||
else
|
||
{
|
||
if (cantAdcancePanel.activeInHierarchy && curTypeGradeModelIdDic.ContainsKey(advanceBase.Grade))
|
||
{
|
||
StartCoroutine(ShowMountModel(curTypeGradeModelIdDic[advanceBase.Grade]));
|
||
}
|
||
}
|
||
|
||
|
||
curAdvanceLevel = advanceBase.Level;
|
||
curAdvanceGrade = advanceBase.Grade;
|
||
curAdvanceBaseId = baseId;
|
||
|
||
RecordCurAdvanceInfo(advanceBase.Id);
|
||
UpdateRedPoint();
|
||
}
|
||
|
||
public bool UpdateRedPoint()
|
||
{
|
||
if(itemPanel != null)
|
||
{
|
||
return itemPanel.UpdateRedPoint();
|
||
}
|
||
else
|
||
{
|
||
LogModule.ErrorLog("Can't get advanceItemPanelCtr, can't update red point tips !!!");
|
||
return false;
|
||
}
|
||
}
|
||
|
||
//刷新界面
|
||
private bool _IsAutoAdvanceCauseAdvance = false;
|
||
public void RefreshAdvancePanelInfo(AdvanceRetInfo info)
|
||
{
|
||
int curBaseId = (info.type + 1) * 1000 + info.level;
|
||
Tab_AdvanceBase advanceBase = TableManager.GetAdvanceBaseByID(curBaseId, 0);
|
||
if (advanceBase == null)
|
||
{
|
||
return;
|
||
}
|
||
|
||
if (maxAdvanceBase == null)
|
||
{
|
||
return;
|
||
}
|
||
|
||
if (advanceBase.Level > curAdvanceLevel)
|
||
{
|
||
|
||
for (int index = 0; index < attrIncList.Count; index++)
|
||
{
|
||
attrIncList[index].gameObject.SetActive(advanceBase.Level < maxAdvanceBase.Level ? true : false);
|
||
}
|
||
advanceWishPanel.gameObject.SetActive(advanceBase.Level < maxAdvanceBase.Level ? true : false);
|
||
advanceItemPanel.gameObject.SetActive(advanceBase.Level < maxAdvanceBase.Level ? true : false);
|
||
maxLevelIcon.gameObject.SetActive(advanceBase.Level < maxAdvanceBase.Level ? false : true);
|
||
}
|
||
|
||
if (advanceBase.Level > curAdvanceLevel) //等级提升才刷新属性
|
||
{
|
||
curAdvanceLevel = advanceBase.Level;
|
||
InitAttrItem(curBaseId, (curTypeLevelBaseIdList.IndexOf(curBaseId) + 1) < curTypeLevelBaseIdList.Count ? curTypeLevelBaseIdList[curTypeLevelBaseIdList.IndexOf(curBaseId) + 1] : 0);
|
||
itemPanel.RefreshNeedCostPanel(advanceBase.Id + 1);
|
||
}
|
||
|
||
//金钱不足停止
|
||
if (info.incWish <= 0 && info.wish >= 0)
|
||
{
|
||
if (itemPanel.isOnAdvance == true) //当前金钱不足
|
||
{
|
||
JudgeMoneyLogic.IsMoneyEnough(MONEYTYPE.MONEYTYPE_YUANBAO, itemPanel.lackItemCount * itemPanel.curNeedCostItemPrice);
|
||
}
|
||
}
|
||
|
||
if (advanceBase.Grade > curAdvanceGrade)
|
||
{
|
||
if(itemPanel.isOnAdvance)
|
||
{
|
||
_IsAutoAdvanceCauseAdvance = true;
|
||
}else
|
||
{
|
||
_IsAutoAdvanceCauseAdvance = false;
|
||
}
|
||
//关闭进阶界面的自动进阶
|
||
itemPanel.isOnAdvance = false;
|
||
itemPanel.SetAdvanceBtnState();
|
||
}
|
||
|
||
if (advanceItemPanel.activeInHierarchy)
|
||
itemPanel.RefreshPanelInfo(advanceBase.Id, info.wish, info.remainAdvanceItemCount);
|
||
if (advanceWishPanel.activeInHierarchy)
|
||
wishPanel.RefreshWishPanel(info);
|
||
|
||
if (info.incWish > 0)
|
||
{
|
||
CreateWishValueText(info.incWish, info.isCrit);
|
||
}
|
||
int type = (advanceBase.Id - advanceBase.Level) / 1000 - 1;
|
||
if (advanceBase.Grade >= maxAdvanceBase.Grade)
|
||
{
|
||
if (!modelPanel.activeInHierarchy)
|
||
{
|
||
modelPanel.SetActive(true);
|
||
}
|
||
|
||
canAdvancePanel.gameObject.SetActive(false);
|
||
cantAdcancePanel.gameObject.SetActive(true);
|
||
|
||
if (advanceBase.Grade > curAdvanceGrade)
|
||
{
|
||
curAdvanceGrade = advanceBase.Grade;
|
||
StartCoroutine(ShowMountModel(curBaseId));
|
||
}
|
||
}
|
||
else
|
||
{
|
||
canAdvancePanel.gameObject.SetActive(true);
|
||
//cantAdcancePanel.gameObject.SetActive(false);
|
||
|
||
//进阶刷新模型
|
||
if (advanceBase.Grade > curAdvanceGrade)
|
||
{
|
||
ShowGainNewAnimation(curBaseId);
|
||
curAdvanceGrade = advanceBase.Grade;
|
||
if(gameObject.activeInHierarchy)
|
||
StartCoroutine(ShowMountModel(curTypeGradeModelIdDic[curAdvanceGrade], curTypeGradeModelIdDic[curAdvanceGrade + 1]));
|
||
}
|
||
|
||
RecordCurAdvanceInfo(advanceBase.Id);
|
||
}
|
||
}
|
||
|
||
public void ShowCurAndNextAnimation(int curBaseId, int nextBaseId)
|
||
{
|
||
//Tab_AdvanceBase curAdvanceBase = TableManager.GetAdvanceBaseByID(curBaseId, 0);
|
||
//Tab_AdvanceBase nextAdvanceBase = TableManager.GetAdvanceBaseByID(nextBaseId, 0);
|
||
//if(curAdvanceBase != null && nextAdvanceBase != null)
|
||
//{
|
||
// Tab_CharModel curCharModel = TableManager.GetCharModelByID(curAdvanceBase.ModelId, 0);
|
||
// Tab_CharModel nextCharModel = TableManager.GetCharModelByID(nextAdvanceBase.ModelId, 0);
|
||
// if(curCharModel != null && nextCharModel != null)
|
||
// {
|
||
|
||
// }
|
||
//}
|
||
//curAnimation.ShowAnimation(curBaseId);
|
||
//nextAnimation.ShowAnimation(nextBaseId);
|
||
}
|
||
|
||
public void ShowMaxAnimation(int maxBaseId)
|
||
{
|
||
//maxAnimation.ShowAnimation(maxBaseId);
|
||
}
|
||
|
||
private int lastBaseId = -1;
|
||
|
||
/// <summary>
|
||
/// 通过id记录保存当前进阶信息
|
||
/// </summary>
|
||
/// <param name="baseId">进阶id</param>
|
||
public void RecordCurAdvanceInfo(int baseId)
|
||
{
|
||
if (lastBaseId == baseId)
|
||
{
|
||
return;
|
||
}
|
||
|
||
lastBaseId = baseId;
|
||
|
||
Tab_AdvanceBase advanceBase = TableManager.GetAdvanceBaseByID(baseId, 0);
|
||
if (advanceBase == null)
|
||
{
|
||
return;
|
||
}
|
||
|
||
int type = (advanceBase.Id - advanceBase.Level) / 1000 - 1;
|
||
switch (type)
|
||
{
|
||
case (int)AdvanceBase.AdvanceType.Ride:
|
||
GameManager.gameManager.PlayerDataPool.m_AdvanceData.RideGrade = advanceBase.Grade;
|
||
GameManager.gameManager.PlayerDataPool.m_AdvanceData.RideLevel = advanceBase.Level;
|
||
break;
|
||
case (int)AdvanceBase.AdvanceType.Wing:
|
||
GameManager.gameManager.PlayerDataPool.m_AdvanceData.WingGrade = advanceBase.Grade;
|
||
GameManager.gameManager.PlayerDataPool.m_AdvanceData.WingLevel = advanceBase.Level;
|
||
break;
|
||
case (int)AdvanceBase.AdvanceType.Piano:
|
||
GameManager.gameManager.PlayerDataPool.m_AdvanceData.GodWeaponGrade = advanceBase.Grade;
|
||
GameManager.gameManager.PlayerDataPool.m_AdvanceData.GodWeaponLevel = advanceBase.Level;
|
||
break;
|
||
case (int)AdvanceBase.AdvanceType.Qilinbi:
|
||
GameManager.gameManager.PlayerDataPool.m_AdvanceData.WishGrade = advanceBase.Grade;
|
||
GameManager.gameManager.PlayerDataPool.m_AdvanceData.WishLevel = advanceBase.Level;
|
||
break;
|
||
case (int)AdvanceBase.AdvanceType.Soul:
|
||
GameManager.gameManager.PlayerDataPool.m_AdvanceData.SealGrade = advanceBase.Grade;
|
||
GameManager.gameManager.PlayerDataPool.m_AdvanceData.SealLevel = advanceBase.Level;
|
||
break;
|
||
case (int)AdvanceBase.AdvanceType.Mask:
|
||
GameManager.gameManager.PlayerDataPool.m_AdvanceData.MaskGrade = advanceBase.Grade;
|
||
GameManager.gameManager.PlayerDataPool.m_AdvanceData.MaskLevel = advanceBase.Level;
|
||
break;
|
||
case (int)AdvanceBase.AdvanceType.Huopao:
|
||
GameManager.gameManager.PlayerDataPool.m_AdvanceData.CrownGrade = advanceBase.Grade;
|
||
GameManager.gameManager.PlayerDataPool.m_AdvanceData.CrownLevel = advanceBase.Level;
|
||
break;
|
||
}
|
||
}
|
||
|
||
//当前正在显示的FloatText
|
||
private List<GameObject> _AllShowingWishFloatTextList = new List<GameObject>();
|
||
public void CreateWishValueText(int incWish, bool isCrit)
|
||
{
|
||
if (!gameObject.activeInHierarchy)
|
||
return;
|
||
|
||
_AllShowingWishFloatTextList.Add(GetWishFloatTextFromPool());
|
||
_AllShowingWishFloatTextList[_AllShowingWishFloatTextList.Count - 1].SetActive(true);
|
||
_AllShowingWishFloatTextList[_AllShowingWishFloatTextList.Count - 1].transform.localPosition = Vector3.zero;
|
||
_AllShowingWishFloatTextList[_AllShowingWishFloatTextList.Count - 1].GetComponent<AdvanceWishValueFloatText>().InitText(incWish, isCrit);
|
||
}
|
||
|
||
public List<GameObject> _AllWishFloatTexPool;
|
||
public void InitWishFloatTextPool()
|
||
{
|
||
_AllWishFloatTexPool = new List<GameObject>();
|
||
for (int index = 0; index < 10; index ++)
|
||
{
|
||
CreateWishFloatTextAndAddToPool();
|
||
}
|
||
}
|
||
|
||
public void CreateWishFloatTextAndAddToPool()
|
||
{
|
||
GameObject textPrefab = GameObject.Instantiate(wishValueTextPrefab);
|
||
textPrefab.transform.SetParent(wishValueTextParent);
|
||
textPrefab.transform.localPosition = Vector3.zero;
|
||
textPrefab.transform.localScale = Vector3.one;
|
||
textPrefab.transform.localRotation = Quaternion.Euler(Vector3.zero);
|
||
|
||
AddWishFloatTextToPool(textPrefab);
|
||
}
|
||
|
||
public void AddWishFloatTextToPool(GameObject obj)
|
||
{
|
||
obj.SetActive(false);
|
||
obj.transform.localPosition = Vector3.zero;
|
||
if(!_AllWishFloatTexPool.Contains(obj))
|
||
_AllWishFloatTexPool.Add(obj);
|
||
}
|
||
|
||
public GameObject GetWishFloatTextFromPool()
|
||
{
|
||
if(_AllWishFloatTexPool.Count > 0)
|
||
{
|
||
var obj = _AllWishFloatTexPool[_AllWishFloatTexPool.Count - 1];
|
||
_AllWishFloatTexPool.Remove(obj);
|
||
return obj;
|
||
}else
|
||
{
|
||
CreateWishFloatTextAndAddToPool();
|
||
return GetWishFloatTextFromPool();
|
||
}
|
||
}
|
||
|
||
private void OnDisable()
|
||
{
|
||
ClearAllFloatText();
|
||
CloseAutoAdvanceBtn();
|
||
}
|
||
|
||
private void OnDestroy()
|
||
{
|
||
Instance = null;
|
||
for (int index = 0; index < _AllWishFloatTexPool.Count; index++)
|
||
{
|
||
Destroy(_AllWishFloatTexPool[index]);
|
||
}
|
||
_AllWishFloatTexPool.Clear();
|
||
}
|
||
|
||
public bool IsCleanWish()
|
||
{
|
||
if (!isMaxLevel)
|
||
{
|
||
int curAdvanceLevel = AdvanceCanadvanceCtr.GetInstance().GetAdvanceLevel((AdvanceBase.AdvanceType)curAdvanceType);
|
||
int advanceBaseId = (curAdvanceType + 1) * 1000 + curAdvanceLevel;
|
||
var advanceBaseTab = TableManager.GetAdvanceBaseByID(advanceBaseId, 0);
|
||
if (advanceBaseTab != null)
|
||
{
|
||
if (advanceBaseTab.DayDecWishValuePercent > 0)
|
||
{
|
||
return true;
|
||
}
|
||
}
|
||
}
|
||
return false;
|
||
}
|
||
|
||
public bool IsCloseAdvancePanel()
|
||
{
|
||
bool isClose = true;
|
||
if (!isMaxLevel)
|
||
{
|
||
int curAdvanceLevel = AdvanceCanadvanceCtr.GetInstance().GetAdvanceLevel((AdvanceBase.AdvanceType)curAdvanceType);
|
||
int advanceBaseId = (curAdvanceType + 1) * 1000 + curAdvanceLevel;
|
||
var advanceBaseTab = TableManager.GetAdvanceBaseByID(advanceBaseId, 0);
|
||
if(advanceBaseTab != null)
|
||
{
|
||
if(advanceBaseTab.DayDecWishValuePercent > 0)
|
||
{
|
||
MessageBoxLogic.OpenOKCancelBox(StrDictionary.GetClientDictionaryString("#{46225}"), "", delegate() {
|
||
UIManager.CloseUI(UIInfo.MessageBox);
|
||
isClose = false;
|
||
}, delegate() {
|
||
UIManager.CloseUI(UIInfo.MessageBox);
|
||
isClose = true;
|
||
});
|
||
}
|
||
}
|
||
}
|
||
return isClose;
|
||
}
|
||
|
||
public void ClearAllFloatText()
|
||
{
|
||
for(int index = 0; index < _AllShowingWishFloatTextList.Count; index++)
|
||
{
|
||
AddWishFloatTextToPool(_AllShowingWishFloatTextList[index]);
|
||
}
|
||
|
||
_AllShowingWishFloatTextList.Clear();
|
||
|
||
for (int index = 0; index < _AllWishFloatTexPool.Count; index++)
|
||
{
|
||
_AllWishFloatTexPool[index].transform.localPosition = Vector3.zero;
|
||
if (_AllWishFloatTexPool[index].activeInHierarchy)
|
||
{
|
||
_AllWishFloatTexPool[index].SetActive(false);
|
||
}
|
||
}
|
||
}
|
||
|
||
public void CloseAutoAdvanceBtn()
|
||
{
|
||
itemPanel.isOnAdvance = false;
|
||
itemPanel.SetAdvanceBtnState();
|
||
}
|
||
|
||
|
||
//获得新坐骑动画
|
||
public void ShowGainNewAnimation(int baseId)
|
||
{
|
||
UIManager.ShowUI(UIInfo.PopAdvanceTip, delegate(bool bSucess, object param) {
|
||
if(bSucess)
|
||
{
|
||
PopAdvanceTipCtr.Instance.InitAdvancePanel(baseId, _IsAutoAdvanceCauseAdvance);
|
||
}
|
||
});
|
||
}
|
||
|
||
IEnumerator ShowMountModel(int curBaseId, int nextBaseId)
|
||
{
|
||
curModelCameraTexture._CanDrag = AdvanceMountPanelCtr.Instance.m_AdvanceType == AdvanceBase.AdvanceType.Ride || AdvanceMountPanelCtr.Instance.m_AdvanceType == AdvanceBase.AdvanceType.Wing;
|
||
nextModelCameraTexture._CanDrag = AdvanceMountPanelCtr.Instance.m_AdvanceType == AdvanceBase.AdvanceType.Ride || AdvanceMountPanelCtr.Instance.m_AdvanceType == AdvanceBase.AdvanceType.Wing;
|
||
Tab_AdvanceBase curBase = TableManager.GetAdvanceBaseByID(curBaseId, 0);
|
||
Tab_AdvanceBase nextBase = TableManager.GetAdvanceBaseByID(nextBaseId, 0);
|
||
|
||
if(curBase == null || nextBase == null)
|
||
{
|
||
yield break;
|
||
}
|
||
|
||
_CurCombatVal.text = curBase.CombatValue + "";
|
||
_NextCombatVal.text = nextBase.CombatValue + "";
|
||
|
||
switch (curAdvanceType)
|
||
{
|
||
case (int)AdvanceBase.AdvanceType.Ride:
|
||
Tab_MountBase curMountBase = TableManager.GetMountBaseByID(curBase.ModelId, 0);
|
||
Tab_MountBase nextMountBase = TableManager.GetMountBaseByID(nextBase.ModelId, 0);
|
||
if (curMountBase == null || nextMountBase == null)
|
||
{
|
||
yield break;
|
||
}
|
||
|
||
Tab_CharMount curCharmount = TableManager.GetCharMountByID(curMountBase.ModelID, 0);
|
||
Tab_CharMount nextCharMount = TableManager.GetCharMountByID(nextMountBase.ModelID, 0);
|
||
if (curCharmount == null || nextCharMount == null)
|
||
{
|
||
yield break;
|
||
}
|
||
curModelCameraTexture.InitMountModelPath(curCharmount, delegate() {
|
||
curModelCameraTexture.gameObject.SetActive(true);
|
||
});
|
||
nextModelCameraTexture.InitMountModelPath(nextCharMount, delegate() {
|
||
nextModelCameraTexture.gameObject.SetActive(true);
|
||
});
|
||
|
||
|
||
curModelName.text = curMountBase.Name;
|
||
nextModelName.text = nextMountBase.Name;
|
||
break;
|
||
case (int)AdvanceBase.AdvanceType.Wing:
|
||
{
|
||
Tab_AdvanceBase curAdvanceBase = TableManager.GetAdvanceBaseByID(curBaseId, 0);
|
||
if (curAdvanceBase == null)
|
||
{
|
||
yield break;
|
||
}
|
||
|
||
Tab_AdvanceBase nextAdvanceBase = TableManager.GetAdvanceBaseByID(nextBaseId, 0);
|
||
if(nextAdvanceBase == null)
|
||
{
|
||
yield break;
|
||
}
|
||
|
||
curModelCameraTexture.InitWingModelPath(curAdvanceBase, null, delegate() {
|
||
curModelCameraTexture.gameObject.SetActive(true);
|
||
});
|
||
nextModelCameraTexture.InitWingModelPath(nextAdvanceBase, null, delegate() {
|
||
nextModelCameraTexture.gameObject.SetActive(true);
|
||
});
|
||
|
||
curModelName.text = curAdvanceBase.Name;
|
||
nextModelName.text = nextAdvanceBase.Name;
|
||
}
|
||
break;
|
||
default:
|
||
Tab_CharModel curCharModel = TableManager.GetCharModelByID(curBase.ModelId, 0);
|
||
Tab_CharModel nextCharModel = TableManager.GetCharModelByID(nextBase.ModelId, 0);
|
||
if(curCharModel == null || nextCharModel == null)
|
||
{
|
||
yield break;
|
||
}
|
||
curModelCameraTexture.InitModelPath(curCharModel.ResPath, curCharModel, LoadAssetBundle.BUNDLE_PATH_MODEL, true,
|
||
delegate() { curModelCameraTexture.gameObject.SetActive(true); });
|
||
nextModelCameraTexture.InitModelPath(nextCharModel.ResPath, nextCharModel, LoadAssetBundle.BUNDLE_PATH_MODEL, true,
|
||
delegate () { nextModelCameraTexture.gameObject.SetActive(true); });
|
||
|
||
curModelName.text = curCharModel.Name;
|
||
nextModelName.text = nextCharModel.Name;
|
||
break;
|
||
}
|
||
curModelGrade.text = GCGame.Utils.GetGradeString(curBase.Grade);
|
||
nextModelGrade.text = GCGame.Utils.GetGradeString(nextBase.Grade);
|
||
yield break;
|
||
}
|
||
|
||
IEnumerator ShowMountModel(int baseId)
|
||
{
|
||
Tab_AdvanceBase advanceBase = TableManager.GetAdvanceBaseByID(baseId, 0);
|
||
if(advanceBase == null)
|
||
{
|
||
yield break;
|
||
}
|
||
|
||
_MaxCombatVal.text = advanceBase.CombatValue + "";
|
||
switch (curAdvanceType)
|
||
{
|
||
case (int)AdvanceBase.AdvanceType.Ride:
|
||
Tab_MountBase mountBase = TableManager.GetMountBaseByID(advanceBase.ModelId, 0);
|
||
if (mountBase == null)
|
||
{
|
||
yield break;
|
||
}
|
||
|
||
Tab_CharMount charMount = TableManager.GetCharMountByID(mountBase.ModelID, 0);
|
||
if (charMount == null)
|
||
{
|
||
yield break;
|
||
}
|
||
maxModelCmaeraTexture.InitMountModelPath(charMount, delegate (){
|
||
maxModelCmaeraTexture.gameObject.SetActive(true);
|
||
});
|
||
maxModelName.text = mountBase.Name;
|
||
break;
|
||
case (int)AdvanceBase.AdvanceType.Wing:
|
||
{
|
||
maxModelCmaeraTexture.InitWingModelPath(advanceBase, null, delegate (){
|
||
maxModelCmaeraTexture.gameObject.SetActive(true);
|
||
});
|
||
maxModelName.text = advanceBase.Name;
|
||
}
|
||
break;
|
||
default:
|
||
Tab_CharModel charModel = TableManager.GetCharModelByID(advanceBase.ModelId, 0);
|
||
if(charModel == null)
|
||
{
|
||
break;
|
||
}
|
||
|
||
maxModelCmaeraTexture.InitModelPath(charModel.ResPath, charModel, LoadAssetBundle.BUNDLE_PATH_MODEL, true, delegate ()
|
||
{
|
||
maxModelCmaeraTexture.gameObject.SetActive(true);
|
||
});
|
||
maxModelName.text = charModel.Name;
|
||
break;
|
||
}
|
||
maxModelGrade.text = GCGame.Utils.GetGradeString(advanceBase.Grade);
|
||
yield break;
|
||
}
|
||
|
||
|
||
public void InitAttrItem(int curBaseId, int nextBaseId)
|
||
{
|
||
Tab_AdvanceBase curBase = TableManager.GetAdvanceBaseByID(curBaseId, 0);
|
||
Tab_AdvanceBase nextBase = TableManager.GetAdvanceBaseByID(nextBaseId, 0);
|
||
|
||
if(curBase != null)
|
||
{
|
||
for(int index = 0; index < curBase.getAttrIdCount(); index++)
|
||
{
|
||
if(curBase.GetAttrIdbyIndex(index) > 0)
|
||
{
|
||
if(nextBase != null)
|
||
{
|
||
isMaxLevel = false;
|
||
incAttrItemList[index].gameObject.SetActive(true);
|
||
incAttrItemList[index].InitIncAttrItem(curBase.GetAttrIdbyIndex(index) + 10000,
|
||
curBase.GetAttrValuebyIndex(index),
|
||
nextBase.GetAttrValuebyIndex(index) - curBase.GetAttrValuebyIndex(index));
|
||
}else //达到最高等级
|
||
{
|
||
isMaxLevel = true;
|
||
incAttrItemList[index].gameObject.SetActive(true);
|
||
incAttrItemList[index].InitIncAttrItem(curBase.GetAttrIdbyIndex(index) + 10000,
|
||
curBase.GetAttrValuebyIndex(index),
|
||
0);
|
||
}
|
||
}else
|
||
{
|
||
incAttrItemList[index].gameObject.SetActive(false);
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
public static int SortByLevel(int baseIdA, int baseIdB)
|
||
{
|
||
Tab_AdvanceBase baseA = TableManager.GetAdvanceBaseByID(baseIdA, 0);
|
||
Tab_AdvanceBase baseB = TableManager.GetAdvanceBaseByID(baseIdB, 0);
|
||
if(baseA != null && baseB != null)
|
||
{
|
||
if(baseA.Level < baseB.Level)
|
||
{
|
||
return -1;
|
||
}else
|
||
{
|
||
return 1;
|
||
}
|
||
}
|
||
return 0;
|
||
}
|
||
|
||
public void OnHelpBtnClick()
|
||
{
|
||
switch(AdvanceMountPanelCtr.Instance.m_AdvanceType)
|
||
{
|
||
case AdvanceBase.AdvanceType.Ride:
|
||
MessageHelpLogic.ShowHelpMessage(25);
|
||
break;
|
||
case AdvanceBase.AdvanceType.Piano:
|
||
MessageHelpLogic.ShowHelpMessage(26);
|
||
break;
|
||
case AdvanceBase.AdvanceType.Wing:
|
||
MessageHelpLogic.ShowHelpMessage(27);
|
||
break;
|
||
case AdvanceBase.AdvanceType.Qilinbi:
|
||
MessageHelpLogic.ShowHelpMessage(28);
|
||
break;
|
||
case AdvanceBase.AdvanceType.Soul:
|
||
MessageHelpLogic.ShowHelpMessage(29);
|
||
break;
|
||
case AdvanceBase.AdvanceType.Mask:
|
||
MessageHelpLogic.ShowHelpMessage(30);
|
||
break;
|
||
case AdvanceBase.AdvanceType.Huopao:
|
||
MessageHelpLogic.ShowHelpMessage(31);
|
||
break;
|
||
}
|
||
}
|
||
|
||
/// <summary>
|
||
/// 进阶界面内是否有显示的红点
|
||
/// </summary>
|
||
/// <returns></returns>
|
||
public bool hasRedPoint()
|
||
{
|
||
//if(AdvanceMountPanelCtr.Instance.advancePanel.gameObject.activeInHierarchy)
|
||
//{
|
||
// if (itemPanel.canAdvanceRedIcon != null)
|
||
// {
|
||
// return itemPanel.canAdvanceRedIcon.activeSelf;
|
||
// }
|
||
|
||
//}
|
||
//else
|
||
//{
|
||
// if(HasRedPoint(AdvanceMountPanelCtr.Instance.m_AdvanceType))
|
||
// {
|
||
// return true;
|
||
// }
|
||
//}
|
||
|
||
//同步物品的时候还没有刷新状态,实际不能显示红点的也会显示
|
||
if (HasRedPoint(AdvanceMountPanelCtr.Instance.m_AdvanceType))
|
||
{
|
||
return true;
|
||
}
|
||
|
||
return false;
|
||
}
|
||
|
||
/// <summary>
|
||
/// 检测并更新进阶界面红点信息(不包括菜单)
|
||
/// </summary>
|
||
/// <returns>
|
||
/// true:有红点信息
|
||
/// fasle: 无红点信息,或存在错误
|
||
/// </returns>
|
||
public static bool HasRedPoint(AdvanceBase.AdvanceType adType)
|
||
{
|
||
// 当进阶界面正在显示,直接使用结果
|
||
//if(AdvanceMountPanelCtr.Instance != null
|
||
// && AdvanceMountPanelCtr.Instance.advancePanel.gameObject.activeInHierarchy
|
||
// && AdvanceMountPanelCtr.Instance.m_AdvanceType == adType)
|
||
//{
|
||
// return Instance.hasRedPoint();
|
||
//}
|
||
|
||
// 页面不存在时,从头计算
|
||
AdvanceInfo adInfo;
|
||
GameManager.gameManager.PlayerDataPool.m_AdvanceData.AdvanceDataDic.TryGetValue((int)adType, out adInfo);
|
||
// 当前进阶数据不存在,或没开启该项时,退出
|
||
if (adInfo == null || adInfo.level <= 0)
|
||
{
|
||
return false;
|
||
}
|
||
|
||
Tab_AdvanceBase tab_abBase = TableManager.GetAdvanceBaseByID(adInfo.baseId, 0);
|
||
if(tab_abBase == null)
|
||
{
|
||
return false;
|
||
}
|
||
|
||
if(tab_abBase.DayDecWishValuePercent > 0)
|
||
{
|
||
return false;
|
||
}
|
||
|
||
// 寻找最大等级
|
||
Tab_AdvanceBase maxAdBase = null;
|
||
List<int> baseIdList = new List<int>();
|
||
var allBaseDic = TableManager.GetAdvanceBase().Values;
|
||
foreach (var baseInfo in allBaseDic)
|
||
{
|
||
if (baseInfo.Id / 1000 - 1 == (int)adType)
|
||
{
|
||
baseIdList.Add(baseInfo.Id);
|
||
}
|
||
}
|
||
|
||
baseIdList.Sort(SortByLevel);
|
||
|
||
if (baseIdList.Count > 0)
|
||
{
|
||
maxAdBase = TableManager.GetAdvanceBaseByID(baseIdList[baseIdList.Count - 1], 0);
|
||
}
|
||
|
||
if (maxAdBase == null)
|
||
{
|
||
return false;
|
||
}
|
||
|
||
if (tab_abBase.Level < maxAdBase.Level)
|
||
{
|
||
Tab_AdvanceBase nextAdvanceBase = TableManager.GetAdvanceBaseByID(adInfo.baseId + 1, 0); //本级升下级 读取下级的消耗
|
||
if (nextAdvanceBase == null || (nextAdvanceBase.Id - nextAdvanceBase.Level) / 1000 - 1 != adInfo.type)
|
||
{
|
||
return false;
|
||
}
|
||
|
||
var bagPack = GameManager.gameManager.PlayerDataPool.BackPack;
|
||
if (bagPack == null)
|
||
return false;
|
||
|
||
if (bagPack.GetItemCountByDataId(nextAdvanceBase.AdvanceCostItemId) >= nextAdvanceBase.AdvanceCostItemNum)
|
||
{
|
||
return true;
|
||
}
|
||
}
|
||
|
||
return false;
|
||
}
|
||
}
|