using System;
|
using System.Collections;
|
using System.Collections.Generic;
|
using UnityEngine;
|
using UnityEngine.UI;
|
|
namespace vnxbqy.UI
|
{
|
public class RealmLevelUpBehaviour : MonoBehaviour
|
{
|
[SerializeField] Transform m_ContainerCondition;
|
[SerializeField] RealmUpCondition m_LevelCondition;
|
[SerializeField] RealmUpCondition m_BossCondition;
|
[SerializeField] RealmEquipCondition m_EquipCondition;
|
[SerializeField] Transform m_ContainerCost;
|
[SerializeField] ItemBehaviour m_Item;
|
[SerializeField] Text m_RequireRealmLevel;
|
[SerializeField] Button m_LevelUp;
|
|
int realmLevel = 0;
|
|
RealmModel model { get { return ModelCenter.Instance.GetModel<RealmModel>(); } }
|
PackModel packModel { get { return ModelCenter.Instance.GetModel<PackModel>(); } }
|
|
private void Awake()
|
{
|
m_LevelUp.AddListener(OnLevelUp);
|
}
|
|
public void Display(int realmLevel)
|
{
|
this.realmLevel = realmLevel;
|
var currentRealmLevel = model.displayRealmLevel;
|
var isNext = realmLevel == currentRealmLevel + 1;
|
m_ContainerCondition.SetActive(isNext);
|
m_ContainerCost.SetActive(isNext);
|
m_LevelUp.SetActive(isNext);
|
m_RequireRealmLevel.SetActive(!isNext);
|
|
if (isNext)
|
{
|
DisplayCondition();
|
DisplayCost();
|
}
|
else
|
{
|
var config = RealmConfig.Get(realmLevel - 1);
|
m_RequireRealmLevel.text = Language.Get("RealmLevelUpRequire", config.Img);
|
}
|
}
|
|
public void DisplayCondition()
|
{
|
var config = RealmConfig.Get(realmLevel - 1);
|
m_LevelCondition.DisplayLevel(realmLevel - 1);
|
m_BossCondition.SetActive(config.BossID != 0);
|
m_EquipCondition.SetActive(model.HasEquipCondition(realmLevel - 1));
|
if (config.BossID != 0)
|
{
|
m_BossCondition.DisplayBoss(realmLevel - 1);
|
}
|
if (model.HasEquipCondition(realmLevel - 1))
|
{
|
m_EquipCondition.DisplayLevel(realmLevel - 1);
|
}
|
}
|
|
public void DisplayCost()
|
{
|
var config = RealmConfig.Get(realmLevel - 1);
|
m_ContainerCost.SetActive(config.NeedGood != 0 && config.NeedNum != 0);
|
m_Item.SetItem(config.NeedGood, config.NeedNum);
|
}
|
|
private void OnLevelUp()
|
{
|
var error = 0;
|
if (model.TryLevelUp(out error))
|
{
|
var config = RealmConfig.Get(PlayerDatas.Instance.baseData.realmLevel);
|
LimitedTimeLuxuryGiftModel.Instance.IsItemIdShow(23, config.NeedGood, config.NeedNum, 1, 0);
|
CA523_tagCMRealmLVUp pak = new CA523_tagCMRealmLVUp();
|
GameNetSystem.Instance.SendInfo(pak);
|
}
|
else
|
{
|
DisplayErrorTip(error);
|
}
|
|
}
|
|
void DisplayErrorTip(int error)
|
{
|
switch (error)
|
{
|
case 1:
|
SysNotifyMgr.Instance.ShowTip("RealmLevelUpError_1");
|
break;
|
case 2:
|
SysNotifyMgr.Instance.ShowTip("RealmLevelUpError_2");
|
break;
|
case 3:
|
var config = RealmConfig.Get(PlayerDatas.Instance.baseData.realmLevel);
|
ItemTipUtility.Show(config.NeedGood);
|
break;
|
case 4:
|
model.realmUpgrateNoEnoughReason = 1;
|
WindowCenter.Instance.Open<RealmRecommandEquipWin>();
|
break;
|
case 5:
|
model.realmUpgrateNoEnoughReason = 2;
|
WindowCenter.Instance.Open<RealmRecommandEquipWin>();
|
break;
|
}
|
}
|
}
|
|
[Serializable]
|
public class RealmUpCondition
|
{
|
[SerializeField] Transform m_Container;
|
[SerializeField] Text m_Condition;
|
[SerializeField] Text m_Progress;
|
|
RealmModel model { get { return ModelCenter.Instance.GetModel<RealmModel>(); } }
|
|
public void DisplayLevel(int realmLevel)
|
{
|
var config = RealmConfig.Get(realmLevel);
|
m_Condition.text = Language.Get("RealmConditionLevel", config.NeedLV);
|
var level = PlayerDatas.Instance.baseData.LV;
|
var satisfy = level >= config.NeedLV;
|
m_Progress.text = StringUtility.Contact(level, "/", config.NeedLV);
|
m_Progress.color = satisfy ? UIHelper.s_LightGreen : UIHelper.s_DarkRedColor;
|
}
|
|
public void DisplayBoss(int realmLevel)
|
{
|
var config = RealmConfig.Get(realmLevel + 1);
|
var label = UIHelper.GetRealmColorByLv(realmLevel + 1, StringUtility.Contact("[", config.Name, "]"));
|
m_Condition.text = Language.Get("RealmConditionBoss", label);
|
var progress = model.isBossPass ? 1 : 0;
|
m_Progress.text = StringUtility.Contact(progress, "/", 1);
|
m_Progress.color = model.isBossPass ? UIHelper.s_LightGreen : UIHelper.s_DarkRedColor;
|
}
|
|
public void SetActive(bool active)
|
{
|
m_Container.SetActive(active);
|
}
|
}
|
|
[Serializable]
|
public class RealmEquipCondition
|
{
|
[SerializeField] Transform m_Container;
|
[SerializeField] Text m_Condition;
|
[SerializeField] Text m_Progress;
|
[SerializeField] Text[] m_EquipPlaceNames;
|
|
readonly Color s_Gray = new Color32(189, 189, 189, 255);
|
|
RealmModel model { get { return ModelCenter.Instance.GetModel<RealmModel>(); } }
|
EquipModel equipModel { get { return ModelCenter.Instance.GetModel<EquipModel>(); } }
|
PackModel packModel { get { return ModelCenter.Instance.GetModel<PackModel>(); } }
|
|
public void DisplayLevel(int realmLevel)
|
{
|
RealmLevelUpEquipCondition equipCondition;
|
if (model.TryGetRealmEquipCondition(realmLevel, out equipCondition))
|
{
|
var equipSet = equipModel.GetEquipSet(equipCondition.level);
|
var realmConfig = RealmConfig.Get(equipSet.realm);
|
if (!equipCondition.isSuit)
|
{
|
var colorName = UIHelper.GetColorNameByItemColor(equipCondition.itemColor);
|
m_Condition.text = Language.Get("RealmNeedEquipCondition_1", realmConfig.Name, colorName, equipCondition.starLevel, 8);
|
}
|
else
|
{
|
m_Condition.text = Language.Get("RealmNeedEquipCondition_2", realmConfig.Name, equipCondition.starLevel, 8);
|
}
|
|
List<int> notSatisfyPlaces;
|
model.SatisfyEquipCondition(realmLevel, out notSatisfyPlaces);
|
|
var progress = 8 - notSatisfyPlaces.Count;
|
for (int i = 0; i < m_EquipPlaceNames.Length; i++)
|
{
|
var place = i + 1;
|
m_EquipPlaceNames[i].text = UIHelper.GetEquipPlaceName(place);
|
bool satisfy = !notSatisfyPlaces.Contains(place);
|
m_EquipPlaceNames[i].color = satisfy ? UIHelper.s_LightGreen : s_Gray;
|
}
|
|
m_Progress.text = StringUtility.Contact(progress, "/", 8);
|
m_Progress.color = progress >= 8 ? UIHelper.s_LightGreen : UIHelper.s_DarkRedColor;
|
}
|
}
|
|
public void SetActive(bool active)
|
{
|
m_Container.SetActive(active);
|
}
|
}
|
}
|
|