//--------------------------------------------------------
|
// [Author]: 第二世界
|
// [ Date ]: Monday, October 09, 2017
|
//--------------------------------------------------------
|
using UnityEngine;
|
using System.Collections;
|
using UnityEngine.UI;
|
using System;
|
using TableConfig;
|
using Snxxz.UI;
|
|
namespace Snxxz.UI
|
{
|
public class TreasurePotentialPanel : MonoBehaviour
|
{
|
[SerializeField] TreasureAnimation m_TreasureAnimation;
|
[SerializeField] TreasurePotentialBriefInfo[] potentialBriefInfos = null;
|
[SerializeField] RectTransform m_ContainerPotentialEffect;
|
[SerializeField] Text m_CurrentPotential;
|
[SerializeField] Text m_NextPotential;
|
[SerializeField] Transform m_PotentialMaxLevelTip;
|
[SerializeField] Transform m_ContainerRequirement;
|
[SerializeField] Text m_SPOwn;
|
[SerializeField] Text m_SPNeed;
|
[SerializeField] Transform m_ContainerUpgrade;
|
|
[SerializeField] ItemBehaviour m_PotentialBook;
|
[SerializeField] Text m_PotentialCount;
|
[SerializeField] Text m_SuccessRatio;
|
[SerializeField] Image m_RatioUp;
|
[SerializeField] Button m_ItemBtn;
|
[SerializeField] Image m_AddBookSign;
|
[SerializeField] Image m_AddBookRedpoint;
|
[SerializeField] Button m_RemoveBook;
|
[SerializeField] ImageEx m_UpgradeImage;
|
[SerializeField] Button m_Upgrade;
|
|
[SerializeField] UIEffect m_FailureEffect;
|
|
[SerializeField] Text m_SkillTitle;
|
|
[SerializeField] RectTransform m_ContainerPotential;
|
[SerializeField] RectTransform m_ContainerGetSkill;
|
[SerializeField] Text m_GetSkillCondition;
|
[SerializeField] Image m_GetSkillIcon;
|
[SerializeField] Text m_GetSkillEffect;
|
[SerializeField] Text m_GetSkillName;
|
|
[SerializeField] RectTransform m_ContainerTotalEffect;
|
[SerializeField] Image m_SkillIcon;
|
[SerializeField] Text m_SkillName;
|
[SerializeField] Text m_SkillCd;
|
[SerializeField] Text m_SkillDescription;
|
[SerializeField] Image m_StageSkillIcon;
|
[SerializeField] Button m_StageSkillBtn;
|
[SerializeField] Image m_SkillSelect;
|
[SerializeField] PotentialInfo[] m_TotalPotentials;
|
|
[SerializeField] RectTransform m_ContainerLock;
|
[SerializeField] Text m_PotentialLimit;
|
|
[SerializeField] TreasurePotentialLines m_PotentialLine;
|
|
public event Action<int> potentialSelectEvent;
|
PlayerPackModel playerPack { get { return ModelCenter.Instance.GetModel<PlayerPackModel>(); } }
|
|
int m_SelectedPotential = 0;
|
public int selectedPotential {
|
get {
|
return m_SelectedPotential;
|
}
|
set {
|
if (m_SelectedPotential != value || selectTotalEffect)
|
{
|
m_SelectedPotential = value;
|
model.selectedPotential = value;
|
model.selectedPotentialBook = 0;
|
|
DisplayPotentialEffect();
|
|
var potential = m_Treasure.GetPotential(selectedPotential);
|
var config = Config.Instance.Get<SkillConfig>(potential.id);
|
|
var level = potential.level;
|
var isMax = level >= config.SkillMaxLV;
|
m_PotentialMaxLevelTip.gameObject.SetActive(isMax);
|
m_ContainerUpgrade.gameObject.SetActive(!isMax &&
|
FuncOpen.Instance.IsFuncOpen(82) && model.IsPotentialUnlock(m_Treasure.id, selectedPotential));
|
m_ContainerRequirement.gameObject.SetActive(!isMax);
|
|
if (!isMax)
|
{
|
AutoSelectPotentialBook();
|
DisplayUpgradeCost();
|
DisplayGetSkill();
|
DisplaySuccessRatio();
|
}
|
else
|
{
|
DisplayGetSkill();
|
}
|
|
if (potentialSelectEvent != null)
|
{
|
potentialSelectEvent(m_SelectedPotential);
|
}
|
}
|
}
|
}
|
|
bool m_SelectTotalEffect = false;
|
public bool selectTotalEffect {
|
get {
|
return m_SelectTotalEffect;
|
}
|
}
|
|
int spNeed = 0;
|
TreasureModel model { get { return ModelCenter.Instance.GetModel<TreasureModel>(); } }
|
|
Treasure m_Treasure;
|
|
public void Display(Treasure _treasure, int _state = 0)
|
{
|
m_Treasure = _treasure;
|
if (m_Treasure == null || m_Treasure.potentials == null)
|
{
|
return;
|
}
|
|
var _index = 0;
|
var _level = -1;
|
for (int i = 0; i < m_Treasure.potentials.Count; i++)
|
{
|
if (model.IsPotentialUnlock(_treasure.id, m_Treasure.potentials[i].id))
|
{
|
if (m_Treasure.potentials[i].level < _level || _level == -1)
|
{
|
_level = m_Treasure.potentials[i].level;
|
_index = i;
|
}
|
}
|
}
|
|
for (int i = 0; i < m_Treasure.potentials.Count; i++)
|
{
|
if (model.SatisyPotentialLevelUp(_treasure.id, m_Treasure.potentials[i].id))
|
{
|
_index = i;
|
break;
|
}
|
}
|
|
selectedPotential = m_Treasure.potentials[_index].id;
|
|
for (int i = 0; i < potentialBriefInfos.Length; i++)
|
{
|
var behaviour = potentialBriefInfos[i];
|
if (i < m_Treasure.potentials.Count)
|
{
|
behaviour.gameObject.SetActive(true);
|
behaviour.treasurePotential = this;
|
behaviour.DisplayBaseInfo(m_Treasure.potentials[i], _state);
|
if (_state != 2 && m_TreasureAnimation.step == TreasureAnimation.TreasureShowStep.UnLock)
|
{
|
m_PotentialLine.Display(i, model.IsPotentialUnlock(m_Treasure.id, m_Treasure.potentials[i].id));
|
}
|
}
|
else
|
{
|
behaviour.gameObject.SetActive(false);
|
m_PotentialLine.Display(i, false);
|
}
|
}
|
|
model.selectedPotentialBook = 0;
|
|
var level = m_Treasure.potentials[_index].level;
|
var config = Config.Instance.Get<SkillConfig>(m_Treasure.potentials[_index].id);
|
var isMax = level >= config.SkillMaxLV;
|
if (!isMax)
|
{
|
AutoSelectPotentialBook();
|
DisplayPotentialBook(model.selectedPotentialBook);
|
}
|
|
model.onPotentialLevelUpResultEvent -= OnPotentialLevelUp;
|
model.onPotentialLevelUpResultEvent += OnPotentialLevelUp;
|
|
model.potentialLevelUpdate -= PotentialLevelUpdate;
|
model.potentialLevelUpdate += PotentialLevelUpdate;
|
|
var _stageSkillCfg = Config.Instance.Get<SkillConfig>(m_Treasure.unLockSkill);
|
if (_stageSkillCfg != null)
|
{
|
m_StageSkillIcon.SetSprite(_stageSkillCfg.IconName);
|
m_StageSkillIcon.SetNativeSize();
|
}
|
|
m_ContainerLock.gameObject.SetActive(!FuncOpen.Instance.IsFuncOpen(82));
|
var funcOpenConfig = Config.Instance.Get<FuncOpenLVConfig>(82);
|
m_PotentialLimit.text = Language.Get("TreasureSkillLimit", funcOpenConfig.LimitLV);
|
|
if (!model.IsPotentialUnlock(model.selectedTreasure, selectedPotential)
|
|| model.GetPotentialUnlockShow(model.selectedTreasure) || _state == 2)
|
{
|
DisplayTotalPotentialEffect();
|
}
|
|
PlayerDatas.Instance.PlayerDataRefreshInfoEvent -= OnTreasurePotentialSPChange;
|
PlayerDatas.Instance.PlayerDataRefreshInfoEvent += OnTreasurePotentialSPChange;
|
|
FuncOpen.Instance.OnFuncStateChangeEvent -= OnFuncStateChangeEvent;
|
FuncOpen.Instance.OnFuncStateChangeEvent += OnFuncStateChangeEvent;
|
|
playerPack.RefreshItemCountAct -= RefreshItemCountAct;
|
playerPack.RefreshItemCountAct += RefreshItemCountAct;
|
|
m_TreasureAnimation.OnStepComplete -= OnStepComplete;
|
m_TreasureAnimation.OnStepComplete += OnStepComplete;
|
|
m_TreasureAnimation.OnUnlockPotentialComplete -= OnUnlockPotentialComplete;
|
m_TreasureAnimation.OnUnlockPotentialComplete += OnUnlockPotentialComplete;
|
|
m_TreasureAnimation.OnPotentialLevelUpComplete -= OnPotentialLevelUpComplete;
|
m_TreasureAnimation.OnPotentialLevelUpComplete += OnPotentialLevelUpComplete;
|
|
m_TreasureAnimation.OnPotentialLineAnimComplete -= OnPotentialLineAnimComplete;
|
m_TreasureAnimation.OnPotentialLineAnimComplete += OnPotentialLineAnimComplete;
|
|
model.potentialBookSelectEvent -= DisplayPotentialBook;
|
model.potentialBookSelectEvent += DisplayPotentialBook;
|
|
RedpointCenter.Instance.redpointValueChangeEvent -= RedpointValueChangeEvent;
|
RedpointCenter.Instance.redpointValueChangeEvent += RedpointValueChangeEvent;
|
|
if (m_TreasureAnimation.step == TreasureAnimation.TreasureShowStep.UnLock)
|
{
|
OnStepComplete(TreasureAnimation.TreasureShowStep.UnLock);
|
}
|
}
|
|
public void Dispose()
|
{
|
for (int i = 0; i < potentialBriefInfos.Length; i++)
|
{
|
var behaviour = potentialBriefInfos[i];
|
behaviour.Dispose();
|
}
|
|
m_PotentialLine.Dispose();
|
|
model.potentialBookSelectEvent -= DisplayPotentialBook;
|
model.onPotentialLevelUpResultEvent -= OnPotentialLevelUp;
|
model.potentialLevelUpdate -= PotentialLevelUpdate;
|
PlayerDatas.Instance.PlayerDataRefreshInfoEvent -= OnTreasurePotentialSPChange;
|
FuncOpen.Instance.OnFuncStateChangeEvent -= OnFuncStateChangeEvent;
|
playerPack.RefreshItemCountAct -= RefreshItemCountAct;
|
m_TreasureAnimation.OnStepComplete -= OnStepComplete;
|
m_TreasureAnimation.OnUnlockPotentialComplete -= OnUnlockPotentialComplete;
|
m_TreasureAnimation.OnPotentialLevelUpComplete -= OnPotentialLevelUpComplete;
|
RedpointCenter.Instance.redpointValueChangeEvent -= RedpointValueChangeEvent;
|
m_TreasureAnimation.OnPotentialLineAnimComplete -= OnPotentialLineAnimComplete;
|
|
m_SelectedPotential = 0;
|
|
model.inPotentialModifyPower = false;
|
}
|
|
private void RedpointValueChangeEvent(int _id)
|
{
|
if (m_Treasure != null && _id == m_Treasure.skillLevelUpRedpoint.id)
|
{
|
DisplayAddBookRedpoint();
|
}
|
}
|
|
private void OnPotentialLevelUpComplete(int _index, int level)
|
{
|
var potential = m_Treasure.potentials[_index];
|
potentialBriefInfos[_index].DisplayStateSfx();
|
potentialBriefInfos[_index].StartLevelTween();
|
var _nextPotential = GetNextPotential(potential.id);
|
if (_nextPotential != 0)
|
{
|
var config = Config.Instance.Get<SkillConfig>(_nextPotential);
|
if (level == config.LearnSkillLV && potentialBriefInfos != null)
|
{
|
for (int i = 0; i < potentialBriefInfos.Length; i++)
|
{
|
if (potentialBriefInfos[i].potential.id == _nextPotential)
|
{
|
potentialBriefInfos[i].potentialTween.SetStartState();
|
potentialBriefInfos[i].potentialTween.enabled = false;
|
m_TreasureAnimation.UnlockTreasurePotential(i);
|
}
|
}
|
}
|
}
|
}
|
|
private void ModifyPowerUp(int treasureId, int index, int fightPower)
|
{
|
var power = model.GetPotentialInitialPower(treasureId, index);
|
if (power != 0)
|
{
|
ModelCenter.Instance.GetModel<PlayerMainDate>().FabaoPowerAdd(fightPower);
|
model.inPotentialModifyPower = true;
|
}
|
}
|
|
private void OnUnlockPotentialComplete(int _index)
|
{
|
selectedPotential = m_Treasure.potentials[_index].id;
|
m_TreasureAnimation.DisplayPotentialLine(_index);
|
HandleAchievement();
|
|
if (model.inPotentialModifyPower)
|
{
|
var power = model.GetPotentialInitialPower(m_Treasure.id, _index);
|
model.inPotentialModifyPower = false;
|
ModelCenter.Instance.GetModel<PlayerMainDate>().FabaoPowerAdd(power);
|
}
|
}
|
|
private void OnPotentialLineAnimComplete(int _index)
|
{
|
if (_index < potentialBriefInfos.Length)
|
{
|
m_PotentialLine.Display(_index, true);
|
}
|
}
|
|
private void OnStepComplete(TreasureAnimation.TreasureShowStep _step)
|
{
|
switch (_step)
|
{
|
case TreasureAnimation.TreasureShowStep.UnLock:
|
if (model.GetPotentialUnlockShow(model.selectedTreasure))
|
{
|
potentialBriefInfos[0].potentialTween.SetStartState();
|
potentialBriefInfos[0].potentialTween.enabled = false;
|
m_TreasureAnimation.UnlockTreasurePotential(0);
|
model.SetPotentialUnlockShow(model.selectedTreasure);
|
}
|
else
|
{
|
HandleAchievement();
|
}
|
DisplayLines();
|
break;
|
case TreasureAnimation.TreasureShowStep.FirstPotential:
|
if (FuncOpen.Instance.IsFuncOpen(82))
|
{
|
potentialBriefInfos[0].potentialTween.SetStartState();
|
potentialBriefInfos[0].potentialTween.enabled = false;
|
m_TreasureAnimation.UnlockTreasurePotential(0);
|
model.SetPotentialUnlockShow(model.selectedTreasure);
|
}
|
else
|
{
|
HandleAchievement();
|
}
|
break;
|
}
|
}
|
|
void HandleAchievement()
|
{
|
if (AchievementGoto.guideAchievementId != 0 && m_Treasure != null)
|
{
|
var config = Config.Instance.Get<SuccessConfig>(AchievementGoto.guideAchievementId);
|
if (config != null && config.Type == 91)
|
{
|
var index = PlayerDatas.Instance.baseData.Job - 1;
|
var skillId = index < config.Condition.Length ? config.Condition[index] : config.Condition[0];
|
var potential = m_Treasure.GetPotential(skillId);
|
if (potential != null)
|
{
|
if (model.IsPotentialUnlock(m_Treasure.id, potential.id))
|
{
|
selectedPotential = potential.id;
|
}
|
else
|
{
|
var skillConfig = Config.Instance.Get<SkillConfig>(potential.id);
|
if (skillConfig.LearnSkillReq > 0 && skillConfig.LearnSkillLV > 0)
|
{
|
var preskillConfig = Config.Instance.Get<SkillConfig>(skillConfig.LearnSkillReq);
|
SysNotifyMgr.Instance.ShowTip("TreasurePotentialSelectError", preskillConfig.SkillName, skillConfig.LearnSkillLV, skillConfig.SkillName);
|
}
|
}
|
}
|
AchievementGoto.guideAchievementId = 0;
|
}
|
}
|
}
|
|
void DisplayLines()
|
{
|
if (m_Treasure == null)
|
{
|
return;
|
}
|
for (int i = 0; i < potentialBriefInfos.Length; i++)
|
{
|
if (i < m_Treasure.potentials.Count)
|
{
|
m_PotentialLine.Display(i, model.IsPotentialUnlock(m_Treasure.id, m_Treasure.potentials[i].id));
|
}
|
else
|
{
|
m_PotentialLine.Display(i, false);
|
}
|
}
|
}
|
|
private void OnFuncStateChangeEvent(int _id)
|
{
|
if (_id == 82)
|
{
|
m_ContainerLock.gameObject.SetActive(!FuncOpen.Instance.IsFuncOpen(82));
|
if (FuncOpen.Instance.IsFuncOpen(82))
|
{
|
potentialBriefInfos[0].potentialTween.SetStartState();
|
potentialBriefInfos[0].potentialTween.enabled = false;
|
m_TreasureAnimation.UnlockTreasurePotential(0);
|
model.SetPotentialUnlockShow(model.selectedTreasure);
|
}
|
}
|
}
|
|
private void DisplayPotentialEffect()
|
{
|
m_ContainerUpgrade.gameObject.SetActive(FuncOpen.Instance.IsFuncOpen(82));
|
m_ContainerPotential.gameObject.SetActive(true);
|
m_ContainerTotalEffect.gameObject.SetActive(false);
|
m_SelectTotalEffect = false;
|
m_SkillTitle.text = Language.Get("TreasurePotential");
|
|
m_SkillSelect.gameObject.SetActive(false);
|
|
var potential = m_Treasure.GetPotential(selectedPotential);
|
var level = potential.level;
|
var config = Config.Instance.Get<SkillConfig>(potential.id);
|
if (level <= 0)
|
{
|
m_CurrentPotential.text = Language.Get("Hallows_NotLearn");
|
}
|
else
|
{
|
var currentConfig = Config.Instance.Get<SkillConfig>(potential.id + level - 1);
|
m_CurrentPotential.text = currentConfig.Description;
|
}
|
|
var isMax = level >= config.SkillMaxLV;
|
if (isMax)
|
{
|
m_NextPotential.text = "";
|
}
|
else
|
{
|
var nextConfig = Config.Instance.Get<SkillConfig>(potential.id + level);
|
m_NextPotential.text = nextConfig.Description;
|
}
|
|
DisplayAddBookRedpoint();
|
}
|
|
private void DisplayTotalPotentialEffect()
|
{
|
m_SelectTotalEffect = true;
|
|
m_SkillSelect.gameObject.SetActive(true);
|
|
for (int i = 0; i < potentialBriefInfos.Length; i++)
|
{
|
if (potentialBriefInfos[i].potential.id == model.selectedPotential)
|
{
|
potentialBriefInfos[i].SelectTotal();
|
}
|
}
|
|
m_ContainerGetSkill.gameObject.SetActive(false);
|
m_ContainerUpgrade.gameObject.SetActive(false);
|
m_ContainerPotential.gameObject.SetActive(false);
|
m_ContainerTotalEffect.gameObject.SetActive(true);
|
m_SkillTitle.text = Language.Get("PotentialSkill");
|
|
var config = Config.Instance.Get<SkillConfig>(m_Treasure.unLockSkill);
|
if (config != null)
|
{
|
m_SkillIcon.SetSprite(config.IconName);
|
m_SkillName.text = config.SkillName;
|
m_SkillCd.text = config.CoolDownTime == 0 ? string.Empty : Language.Get("L1065", config.CoolDownTime / 1000);
|
m_SkillDescription.text = config.Description;
|
}
|
|
|
for (int i = 0; i < m_TotalPotentials.Length; i++)
|
{
|
if (i < m_Treasure.potentials.Count)
|
{
|
m_TotalPotentials[i].SetActive(true);
|
var potential = m_Treasure.potentials[i];
|
m_TotalPotentials[i].Display(potential, model.selectedTreasure);
|
}
|
else
|
{
|
m_TotalPotentials[i].SetActive(false);
|
}
|
}
|
}
|
|
void AutoSelectPotentialBook()
|
{
|
var potential = m_Treasure.GetPotential(model.selectedPotential);
|
if (potential == null)
|
{
|
return;
|
}
|
var levelUpType = model.GetSkillLevelUpType(potential.id);
|
var levelupId = TreasureModel.GetSkillLevelUpId(levelUpType, potential.level + 1);
|
var config = Config.Instance.Get<TreasureSkillConfig>(levelupId);
|
if (config == null)
|
{
|
return;
|
}
|
if (config.InitialRate >= 100)
|
{
|
model.selectedPotentialBook = 0;
|
return;
|
}
|
var itemId = config.Meterial2ID.Length > 0 ? config.Meterial2ID[0] : 0;
|
if (itemId != 0)
|
{
|
//var own = playerPack.GetItemCountByID(PackType.rptItem, itemId);
|
//var need = config.MeterialNum2[0];
|
var rate = config.Rate[0];
|
if (rate >= 60)
|
{
|
model.selectedPotentialBook = itemId;
|
}
|
}
|
}
|
|
private void DisplayUpgradeCost()
|
{
|
var potential = m_Treasure.GetPotential(selectedPotential);
|
var levelUpType = model.GetSkillLevelUpType(potential.id);
|
var levelupId = TreasureModel.GetSkillLevelUpId(levelUpType, potential.level + 1);
|
var config = Config.Instance.Get<TreasureSkillConfig>(levelupId);
|
var spOwn = PlayerDatas.Instance.baseData.treasurePotentialSp;
|
spNeed = config.MeterialNum1;
|
m_SPOwn.text = UIHelper.ReplaceLargeNum(spOwn);
|
m_SPNeed.text = StringUtility.Contact("/", UIHelper.ReplaceLargeNum(spNeed));
|
m_SPOwn.color = spOwn >= spNeed ? UIHelper.GetUIColor(TextColType.DarkGreen) : UIHelper.GetUIColor(TextColType.Red);
|
}
|
|
private void DisplayGetSkill(bool _levelUp = false)
|
{
|
var potential = m_Treasure.GetPotential(selectedPotential);
|
var config = Config.Instance.Get<SkillConfig>(potential.id);
|
int[] _getSkillArray;
|
if (model.TryGetPotentialGetSkill(config.SkillTypeID, out _getSkillArray))
|
{
|
m_ContainerGetSkill.gameObject.SetActive(true);
|
var _getSkillCfg = Config.Instance.Get<SkillConfig>(_getSkillArray[1]);
|
m_GetSkillIcon.SetSprite(_getSkillCfg.IconName);
|
m_GetSkillIcon.material = potential.level >= _getSkillArray[0] ?
|
MaterialUtility.GetUIDefaultGraphicMaterial() : MaterialUtility.GetInstantiatedSpriteGrayMaterial();
|
m_GetSkillEffect.text = _getSkillCfg.Description;
|
m_GetSkillName.text = _getSkillCfg.SkillName;
|
if (potential.level >= _getSkillArray[0])
|
{
|
m_GetSkillCondition.text = Language.Get("Role_TieTitle_2");
|
if (_levelUp && potential.level == _getSkillArray[0])
|
{
|
EffectMgr.Instance.PlayUIEffect(TreasureAnimation.SPIRALSFX, 2700, m_GetSkillIcon.transform, false);
|
}
|
}
|
else
|
{
|
m_GetSkillCondition.text = Language.Get("PotentialGetSkillLevel", _getSkillArray[0]);
|
}
|
m_GetSkillCondition.color = potential.level >= _getSkillArray[0] ? UIHelper.GetUIColor(TextColType.NavyYellow) : UIHelper.GetUIColor(TextColType.Red);
|
}
|
else
|
{
|
m_ContainerGetSkill.gameObject.SetActive(false);
|
}
|
}
|
|
private void DisplaySuccessRatio()
|
{
|
var levelUpConfig = GetPotentialLevelUpConfig();
|
m_SuccessRatio.text = StringUtility.Contact((levelUpConfig.rate * 0.01f).ToString("f0"), "%");
|
m_RatioUp.gameObject.SetActive(model.selectedPotentialBook != 0 && levelUpConfig.rate > 0);
|
m_SuccessRatio.color = UIHelper.GetUIColor(model.selectedPotentialBook != 0 && levelUpConfig.rate > 0
|
? TextColType.DarkGreen : TextColType.LightYellow);
|
m_UpgradeImage.gray = levelUpConfig.rate == 0 && model.selectedPotentialBook == 0;
|
}
|
|
private void DisplayAddBookRedpoint()
|
{
|
if (selectTotalEffect || model.selectedPotentialBook != 0)
|
{
|
m_AddBookRedpoint.gameObject.SetActive(false);
|
return;
|
}
|
var levelUpConfig = GetPotentialLevelUpConfig();
|
if (levelUpConfig.rate * 0.01f >= 60)
|
{
|
m_AddBookRedpoint.gameObject.SetActive(false);
|
return;
|
}
|
bool levelUpHighSuccess = model.SatisyPotentialLevelUp(model.selectedTreasure, model.selectedPotential);
|
m_AddBookRedpoint.gameObject.SetActive(levelUpHighSuccess);
|
}
|
|
private void OnSpNeedItem()
|
{
|
var levelUpConfig = GetPotentialLevelUpConfig();
|
if (levelUpConfig.rate < 10000 || model.selectedPotentialBook != 0)
|
{
|
WindowCenter.Instance.Open<PotentialItemUseWin>();
|
}
|
else
|
{
|
SysNotifyMgr.Instance.ShowTip("SPSuccessHint");
|
//DesignDebug.Log("成功率已经够高了,不需要再增加概率了!");
|
}
|
}
|
|
private void RemovePotentialBook()
|
{
|
model.selectedPotentialBook = 0;
|
}
|
|
private void DisplayPotentialBook(int _potentialBookId)
|
{
|
m_PotentialBook.gameObject.SetActive(_potentialBookId != 0);
|
m_PotentialCount.gameObject.SetActive(_potentialBookId != 0);
|
m_RemoveBook.gameObject.SetActive(_potentialBookId != 0);
|
m_AddBookSign.gameObject.SetActive(_potentialBookId == 0);
|
if (_potentialBookId != 0)
|
{
|
m_PotentialBook.showCount = false;
|
m_PotentialBook.SetItem(_potentialBookId, 1);
|
|
var levelUpConfig = GetPotentialLevelUpConfig();
|
bool satisfy = levelUpConfig.own >= levelUpConfig.need;
|
m_PotentialCount.text = StringUtility.Contact(UIHelper.GetTextColorByItemColor(satisfy ?
|
TextColType.LightYellow : TextColType.Red, levelUpConfig.own.ToString()), "/", levelUpConfig.need);
|
}
|
|
DisplaySuccessRatio();
|
DisplayAddBookRedpoint();
|
}
|
|
private void RefreshItemCountAct(PackType packType, int arg2, int _id)
|
{
|
var config = Config.Instance.Get<ItemConfig>(_id);
|
if (packType == PackType.rptItem && config != null && config.Type == 6)
|
{
|
var levelUpConfig = GetPotentialLevelUpConfig();
|
if (_id == model.selectedPotentialBook)
|
{
|
DisplayPotentialBook(model.selectedPotentialBook);
|
}
|
//if (levelUpConfig.own < levelUpConfig.need)
|
//{
|
// model.selectedPotentialBook = 0;
|
//}
|
}
|
}
|
|
private void UpgradeLevel()
|
{
|
if (!m_TreasureAnimation.stepComplete)
|
{
|
return;
|
}
|
var error = 0;
|
if (!TestPotentialLevelUp(out error))
|
{
|
var skillConfig = Config.Instance.Get<SkillConfig>(selectedPotential);
|
switch (error)
|
{
|
case 1:
|
MessageWin.Inst.ShowFixedTip(Language.Get("Hallows_NeedLv", skillConfig.LearnLVReq));
|
break;
|
case 2:
|
if (skillConfig.LearnSkillReq > 0)
|
{
|
var preSkillConfig = Config.Instance.Get<SkillConfig>(skillConfig.LearnSkillReq);
|
MessageWin.Inst.ShowFixedTip(Language.Get("Hallows_NeedSkillLV", preSkillConfig.SkillName, skillConfig.LearnSkillLV));
|
}
|
break;
|
case 3:
|
ModelCenter.Instance.GetModel<GetItemPathModel>().SetChinItemModel(148);
|
//MessageWin.Inst.ShowFixedTip(Language.Get("Hallows_SpUnEnough"));
|
break;
|
case 4:
|
SysNotifyMgr.Instance.ShowTip("TreasureUnsealed");
|
break;
|
case 6:
|
if (model.selectedPotentialBook != 0)
|
{
|
ModelCenter.Instance.GetModel<GetItemPathModel>().SetChinItemModel(model.selectedPotentialBook);
|
}
|
else
|
{
|
SysNotifyMgr.Instance.ShowTip("LevelUpZeroRate");
|
}
|
break;
|
}
|
|
return;
|
}
|
|
var successRequirement = GeneralConfig.Instance.potentialUpSuccessRecommend;
|
var levelUpConfig = GetPotentialLevelUpConfig();
|
|
DisplaySuccessRatio();
|
if (levelUpConfig.rate * 0.0001f >= successRequirement)
|
{
|
model.RequestPotentialUpgrade(m_Treasure.id, selectedPotential, levelUpConfig.materilaIndex);
|
}
|
else
|
{
|
if (DayRemind.Instance.GetDayRemind(DayRemind.POTENTIAL_NO_NOTIFY))
|
{
|
model.RequestPotentialUpgrade(m_Treasure.id, selectedPotential, levelUpConfig.materilaIndex);
|
return;
|
}
|
ConfirmCancel.ToggleConfirmCancel(
|
Language.Get("Mail101"),
|
Language.Get("Hallows_SuccessTooLow"),
|
Language.Get("TodayNoNotify"),
|
(bool _ok, bool _toggle) =>
|
{
|
if (_ok)
|
{
|
model.RequestPotentialUpgrade(m_Treasure.id, selectedPotential, levelUpConfig.materilaIndex);
|
}
|
if (_toggle)
|
{
|
DayRemind.Instance.SetDayRemind(DayRemind.POTENTIAL_NO_NOTIFY, true);
|
}
|
});
|
}
|
|
}
|
|
private PotentialLevelUpConfig GetPotentialLevelUpConfig()
|
{
|
var potential = m_Treasure.GetPotential(selectedPotential);
|
var levelUpType = model.GetSkillLevelUpType(potential.id);
|
var levelupId = TreasureModel.GetSkillLevelUpId(levelUpType, potential.level + 1);
|
var config = Config.Instance.Get<TreasureSkillConfig>(levelupId);
|
if (config == null)
|
{
|
return new PotentialLevelUpConfig(0, 0, 0, 0);
|
}
|
if (model.selectedPotentialBook == 0)
|
{
|
return new PotentialLevelUpConfig(config.InitialRate, 0, 0, 0);
|
}
|
else
|
{
|
var index = 0;
|
for (int i = 0; i < config.Meterial2ID.Length; i++)
|
{
|
if (config.Meterial2ID[i] == model.selectedPotentialBook)
|
{
|
index = i;
|
break;
|
}
|
}
|
|
var own = playerPack.GetItemCountByID(PackType.rptItem, model.selectedPotentialBook);
|
var need = config.MeterialNum2[index];
|
var ratio = own >= need ? config.Rate[index] : config.InitialRate;
|
|
return new PotentialLevelUpConfig(ratio, index + 1, own, need);
|
}
|
}
|
|
private bool ContainsPotentialBook(int potentialBook)
|
{
|
if (potentialBook == 0)
|
{
|
return false;
|
}
|
var potential = m_Treasure.GetPotential(selectedPotential);
|
var levelUpType = model.GetSkillLevelUpType(potential.id);
|
var levelupId = TreasureModel.GetSkillLevelUpId(levelUpType, potential.level + 1);
|
var config = Config.Instance.Get<TreasureSkillConfig>(levelupId);
|
if (config == null)
|
{
|
return false;
|
}
|
for (int i = 0; i < config.Meterial2ID.Length; i++)
|
{
|
if (config.Meterial2ID[i] == potentialBook)
|
{
|
return true;
|
}
|
}
|
return false;
|
}
|
|
private int GetNextPotential(int _potentialId)
|
{
|
for (int i = 0; i < m_Treasure.potentials.Count; i++)
|
{
|
var potential = m_Treasure.potentials[i];
|
if (potential.id == _potentialId)
|
{
|
continue;
|
}
|
var skillConfig = Config.Instance.Get<SkillConfig>(potential.id);
|
if (skillConfig.LearnSkillReq == _potentialId)
|
{
|
return potential.id;
|
}
|
}
|
return 0;
|
}
|
|
private void PotentialLevelUpdate(int _potentialId, int arg2)
|
{
|
if (_potentialId == model.selectedPotential)
|
{
|
DisplayPotentialEffect();
|
}
|
var potential = m_Treasure.GetPotential(_potentialId);
|
if (potential != null && model.serverInited)
|
{
|
PotentialLevelUpAnimation(_potentialId, potential.level);
|
var nextPotential = GetNextPotential(potential.id);
|
if (nextPotential != 0)
|
{
|
var config = Config.Instance.Get<SkillConfig>(nextPotential);
|
if (potential.level == config.LearnSkillLV && potentialBriefInfos != null)
|
{
|
for (int i = 0; i < potentialBriefInfos.Length; i++)
|
{
|
if (potentialBriefInfos[i].potential.id == nextPotential)
|
{
|
var current = Config.Instance.Get<SkillConfig>(potential.id + potential.level - 1);
|
var before = Config.Instance.Get<SkillConfig>(potential.id + potential.level - 2);
|
ModifyPowerUp(m_Treasure.id, i, current.FightPower - before.FightPower);
|
}
|
}
|
}
|
}
|
}
|
|
var levelUpConfig = GetPotentialLevelUpConfig();
|
if (!ContainsPotentialBook(model.selectedPotentialBook))
|
{
|
AutoSelectPotentialBook();
|
//model.selectedPotentialBook = 0;
|
}
|
|
var curconfig = Config.Instance.Get<SkillConfig>(potential.id);
|
|
var level = potential.level;
|
var isMax = level >= curconfig.SkillMaxLV;
|
m_ContainerUpgrade.gameObject.SetActive(!isMax && FuncOpen.Instance.IsFuncOpen(82));
|
|
}
|
|
private void OnPotentialLevelUp(int _treasureId, int _potential, bool _ok)
|
{
|
if (m_Treasure.id != _treasureId)
|
{
|
return;
|
}
|
|
if (selectedPotential != _potential)
|
{
|
return;
|
}
|
|
if (!_ok)
|
{
|
m_FailureEffect.Play();
|
}
|
|
if (_ok)
|
{
|
DisplayPotentialEffect();
|
var potential = m_Treasure.GetPotential(selectedPotential);
|
var config = Config.Instance.Get<SkillConfig>(potential.id);
|
|
var level = potential.level;
|
var isMax = level >= config.SkillMaxLV;
|
m_PotentialMaxLevelTip.gameObject.SetActive(isMax);
|
m_ContainerUpgrade.gameObject.SetActive(!isMax && FuncOpen.Instance.IsFuncOpen(82));
|
m_ContainerRequirement.gameObject.SetActive(!isMax);
|
|
if (!isMax)
|
{
|
DisplayUpgradeCost();
|
DisplaySuccessRatio();
|
DisplayGetSkill(true);
|
DisplayPotentialBook(model.selectedPotentialBook);
|
}
|
}
|
else
|
{
|
DisplayPotentialBook(model.selectedPotentialBook);
|
var levelUpConfig = GetPotentialLevelUpConfig();
|
m_PotentialCount.text = StringUtility.Contact(levelUpConfig.own, "/", levelUpConfig.need);
|
}
|
}
|
|
private void PotentialLevelUpAnimation(int id, int level)
|
{
|
for (int i = 0; i < potentialBriefInfos.Length; i++)
|
{
|
if (potentialBriefInfos[i].potential == null)
|
{
|
continue;
|
}
|
if (potentialBriefInfos[i].potential.id == id)
|
{
|
m_TreasureAnimation.DisplayPotentialLevelUp(i, level);
|
break;
|
}
|
}
|
}
|
|
private void OnTreasurePotentialSPChange(PlayerDataRefresh refreshType)
|
{
|
switch (refreshType)
|
{
|
case PlayerDataRefresh.ExAttr7:
|
case PlayerDataRefresh.ExAttr8:
|
var spOwn = PlayerDatas.Instance.baseData.treasurePotentialSp;
|
m_SPOwn.text = UIHelper.ReplaceLargeNum(spOwn);
|
m_SPNeed.text = StringUtility.Contact("/", UIHelper.ReplaceLargeNum(spNeed));
|
m_SPOwn.color = spOwn >= spNeed ? UIHelper.GetUIColor(TextColType.DarkGreen) : UIHelper.GetUIColor(TextColType.Red);
|
break;
|
}
|
}
|
|
private bool TestPotentialLevelUp()
|
{
|
var error = 0;
|
return TestPotentialLevelUp(out error);
|
}
|
|
private bool TestPotentialLevelUp(out int _error)
|
{
|
//1.人物等级要求不足;2.前置技能等级不足;3.sp不足;4.法宝未获得;5.已经最大等级;6.概率为0
|
_error = 0;
|
if (m_Treasure.state != TreasureState.Collected)
|
{
|
_error = 4;
|
return false;
|
}
|
|
var skillConfig = Config.Instance.Get<SkillConfig>(selectedPotential);
|
if (PlayerDatas.Instance.baseData.LV < skillConfig.LearnLVReq)
|
{
|
_error = 1;
|
return false;
|
}
|
|
if (skillConfig.LearnSkillReq > 0)
|
{
|
var preSkillConfig = Config.Instance.Get<SkillConfig>(selectedPotential);
|
var preSkillLevelRequirement = skillConfig.LearnSkillLV;
|
var preSkill = PlayerDatas.Instance.skill.GetSkillBySkillTypeID(skillConfig.LearnSkillReq);
|
var preSkillLevel = preSkill == null ? 0 : preSkill.level;
|
|
if (preSkillLevel < preSkillLevelRequirement)
|
{
|
_error = 2;
|
return false;
|
}
|
}
|
|
if (PlayerDatas.Instance.baseData.treasurePotentialSp < spNeed)
|
{
|
_error = 3;
|
return false;
|
}
|
|
if (m_Treasure.GetPotential(selectedPotential).level >= skillConfig.SkillMaxLV)
|
{
|
_error = 5;
|
return false;
|
}
|
|
var levelUpConfig = GetPotentialLevelUpConfig();
|
if (levelUpConfig.rate == 0)
|
{
|
_error = 6;
|
return false;
|
}
|
|
_error = 0;
|
return true;
|
}
|
|
private void OnStageSkillBtn()
|
{
|
DisplayTotalPotentialEffect();
|
}
|
|
private void Awake()
|
{
|
m_ItemBtn.AddListener(OnSpNeedItem);
|
m_Upgrade.AddListener(UpgradeLevel);
|
m_RemoveBook.AddListener(RemovePotentialBook);
|
m_StageSkillBtn.AddListener(OnStageSkillBtn);
|
}
|
|
private void CheckAchievementGuide()
|
{
|
if (AchievementGoto.guideAchievementId != 0)
|
{
|
var config = Config.Instance.Get<SuccessConfig>(AchievementGoto.guideAchievementId);
|
var condition = config.Type == 91 && config.Condition[0] == model.selectedPotential;
|
|
if (condition)
|
{
|
var guideEffect = AchievementGuideEffectPool.Require(1);
|
guideEffect.transform.SetParentEx(m_Upgrade.transform, Vector3.zero, Vector3.zero, Vector3.one);
|
}
|
}
|
}
|
|
#if UNITY_EDITOR
|
[ContextMenu("连线")]
|
public void PreviewSfx()
|
{
|
}
|
#endif
|
|
struct PotentialLevelUpConfig
|
{
|
public int materilaIndex;
|
public int rate;
|
public int need;
|
public int own;
|
|
public PotentialLevelUpConfig(int _rate, int _materilaIndex, int _own, int _need)
|
{
|
this.rate = _rate;
|
this.materilaIndex = _materilaIndex;
|
this.need = _need;
|
this.own = _own;
|
}
|
}
|
[Serializable]
|
public class PotentialInfo
|
{
|
[SerializeField] Transform m_Container;
|
[SerializeField] Text m_Name;
|
[SerializeField] Text m_Effect;
|
[SerializeField] Text m_Level;
|
[SerializeField] Text m_GetSkillName;
|
[SerializeField] Text m_GetSkillEffect;
|
[SerializeField] Text m_GetSkillCondition;
|
|
public void Display(TreasurePotential potential, int treasureId)
|
{
|
var model = ModelCenter.Instance.GetModel<TreasureModel>();
|
|
var level = potential.level;
|
var potentialConifg = Config.Instance.Get<SkillConfig>(potential.id);
|
|
int[] _getskillArray;
|
m_GetSkillName.gameObject.SetActive(false);
|
m_GetSkillEffect.gameObject.SetActive(false);
|
m_GetSkillCondition.gameObject.SetActive(false);
|
if (model.TryGetPotentialGetSkill(potentialConifg.SkillTypeID, out _getskillArray))
|
{
|
var _getSkillCfg = Config.Instance.Get<SkillConfig>(_getskillArray[1]);
|
m_GetSkillName.text = _getSkillCfg.SkillName;
|
m_GetSkillEffect.text = _getSkillCfg.Description;
|
m_GetSkillName.gameObject.SetActive(true);
|
if (potential.level < _getskillArray[0])
|
{
|
m_GetSkillCondition.gameObject.SetActive(true);
|
m_GetSkillCondition.text = Language.Get("Hallows_NeedSkillLV", potentialConifg.SkillName, _getskillArray[0]);
|
m_GetSkillCondition.color = UIHelper.GetUIColor(TextColType.Red);
|
}
|
else
|
{
|
m_GetSkillEffect.gameObject.SetActive(true);
|
}
|
}
|
|
m_Name.text = potentialConifg.SkillName;
|
if (!model.IsPotentialUnlock(treasureId, potential.id))
|
{
|
var skillConfig = Config.Instance.Get<SkillConfig>(potential.id);
|
var requirement = string.Empty;
|
if (skillConfig.LearnSkillReq > 0 && skillConfig.LearnSkillLV > 0)
|
{
|
var preskillConfig = Config.Instance.Get<SkillConfig>(skillConfig.LearnSkillReq);
|
requirement = Language.Get("Hallows_NeedSkillLV", preskillConfig.SkillName, skillConfig.LearnSkillLV);
|
}
|
else
|
{
|
requirement = Language.Get("Hallows_NeedLv", potentialConifg.LearnLVReq);
|
}
|
|
m_Level.text = requirement;
|
m_Level.color = UIHelper.GetUIColor(TextColType.Red);
|
m_Effect.gameObject.SetActive(false);
|
}
|
else
|
{
|
m_Level.text = StringUtility.Contact(level, Language.Get("Z1041"));
|
m_Level.color = UIHelper.s_LightYellow;
|
var currentConfig = Config.Instance.Get<SkillConfig>(potential.id + level - 1);
|
if (currentConfig == null)
|
{
|
m_Effect.gameObject.SetActive(false);
|
m_Effect.text = string.Empty;
|
}
|
else
|
{
|
m_Effect.gameObject.SetActive(true);
|
m_Effect.text = currentConfig.Description;
|
}
|
}
|
}
|
|
public void SetActive(bool _active)
|
{
|
m_Container.gameObject.SetActive(_active);
|
}
|
}
|
|
}
|
|
}
|
|
|
|