| | |
| | | //-------------------------------------------------------- |
| | | // [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 = ConfigManager.Instance.GetTemplate<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(); |
| | | DisplayGetSkill(); |
| | | DisplaySuccessRatio(); |
| | | m_UpgradeImage.gray = !TestPotentialLevelUp(); |
| | | } |
| | | 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; |
| | | } |
| | | } |
| | | } |
| | | |
| | | 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); |
| | | m_PotentialLine.Display(i, m_Treasure.potentials[i].level >= 1); |
| | | } |
| | | else |
| | | { |
| | | behaviour.gameObject.SetActive(false); |
| | | m_PotentialLine.Display(i, false); |
| | | } |
| | | } |
| | | |
| | | model.selectedPotentialBook = 0; |
| | | |
| | | var level = m_Treasure.potentials[_index].level; |
| | | var config = ConfigManager.Instance.GetTemplate<SkillConfig>(m_Treasure.potentials[_index].id); |
| | | var isMax = level >= config.SkillMaxLV; |
| | | if (!isMax) |
| | | { |
| | | DisplayPotentialBook(0); |
| | | } |
| | | |
| | | model.onPotentialLevelUpResultEvent -= OnPotentialLevelUp; |
| | | model.onPotentialLevelUpResultEvent += OnPotentialLevelUp; |
| | | |
| | | model.potentialLevelUpdate -= PotentialLevelUpdate; |
| | | model.potentialLevelUpdate += PotentialLevelUpdate; |
| | | |
| | | var _stageSkillCfg = ConfigManager.Instance.GetTemplate<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 = ConfigManager.Instance.GetTemplate<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; |
| | | |
| | | 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(); |
| | | } |
| | | |
| | | 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_SelectedPotential = 0; |
| | | } |
| | | |
| | | private void RedpointValueChangeEvent(int _id) |
| | | { |
| | | if (m_Treasure != null && _id == m_Treasure.skillLevelUpRedpoint.id) |
| | | { |
| | | DisplayAddBookRedpoint(); |
| | | } |
| | | } |
| | | |
| | | private void OnPotentialLevelUpComplete(int _index) |
| | | { |
| | | var potential = m_Treasure.potentials[_index]; |
| | | m_PotentialLine.Display(_index, true); |
| | | potentialBriefInfos[_index].DisplayStateSfx(); |
| | | potentialBriefInfos[_index].StartLevelTween(); |
| | | var _nextPotential = GetNextPotential(potential.id); |
| | | if (_nextPotential != 0) |
| | | { |
| | | var config = ConfigManager.Instance.GetTemplate<SkillConfig>(_nextPotential); |
| | | if (potential.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 OnUnlockPotentialComplete(int _index) |
| | | { |
| | | selectedPotential = m_Treasure.potentials[_index].id; |
| | | } |
| | | |
| | | 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); |
| | | } |
| | | 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); |
| | | } |
| | | break; |
| | | } |
| | | } |
| | | |
| | | 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 = ConfigManager.Instance.GetTemplate<SkillConfig>(potential.id); |
| | | if (level <= 0) |
| | | { |
| | | m_CurrentPotential.text = Language.Get("Hallows_NotLearn"); |
| | | } |
| | | else |
| | | { |
| | | var currentConfig = ConfigManager.Instance.GetTemplate<SkillConfig>(potential.id + level - 1); |
| | | m_CurrentPotential.text = currentConfig.Description; |
| | | } |
| | | |
| | | var isMax = level >= config.SkillMaxLV; |
| | | if (isMax) |
| | | { |
| | | m_NextPotential.text = ""; |
| | | } |
| | | else |
| | | { |
| | | var nextConfig = ConfigManager.Instance.GetTemplate<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 = ConfigManager.Instance.GetTemplate<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); |
| | | } |
| | | } |
| | | } |
| | | |
| | | 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 = ConfigManager.Instance.GetTemplate<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); |
| | | m_UpgradeImage.gray = spOwn < spNeed; |
| | | } |
| | | |
| | | private void DisplayGetSkill(bool _levelUp = false) |
| | | { |
| | | var potential = m_Treasure.GetPotential(selectedPotential); |
| | | var config = ConfigManager.Instance.GetTemplate<SkillConfig>(potential.id); |
| | | int[] _getSkillArray; |
| | | if (model.TryGetPotentialGetSkill(config.SkillTypeID, out _getSkillArray)) |
| | | { |
| | | m_ContainerGetSkill.gameObject.SetActive(true); |
| | | var _getSkillCfg = ConfigManager.Instance.GetTemplate<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); |
| | | m_SuccessRatio.color = UIHelper.GetUIColor(model.selectedPotentialBook != 0 ? TextColType.DarkGreen : TextColType.LightYellow); |
| | | } |
| | | |
| | | 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(); |
| | | m_PotentialCount.text = StringUtility.Contact(levelUpConfig.own, "/", levelUpConfig.need); |
| | | } |
| | | |
| | | DisplaySuccessRatio(); |
| | | DisplayAddBookRedpoint(); |
| | | } |
| | | |
| | | private void RefreshItemCountAct(PackType packType, int arg2, int _id) |
| | | { |
| | | var config = ConfigManager.Instance.GetTemplate<ItemConfig>(_id); |
| | | if (packType == PackType.rptItem && config != null && config.Type == 6) |
| | | { |
| | | var levelUpConfig = GetPotentialLevelUpConfig(); |
| | | 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 = ConfigManager.Instance.GetTemplate<SkillConfig>(selectedPotential); |
| | | switch (error) |
| | | { |
| | | case 1: |
| | | MessageWin.Inst.ShowFixedTip(Language.Get("Hallows_NeedLv", skillConfig.LearnLVReq)); |
| | | break; |
| | | case 2: |
| | | if (skillConfig.LearnSkillReq > 0) |
| | | { |
| | | var preSkillConfig = ConfigManager.Instance.GetTemplate<SkillConfig>(skillConfig.LearnSkillReq); |
| | | MessageWin.Inst.ShowFixedTip(Language.Get("Hallows_NeedSkillLV", preSkillConfig.SkillName, skillConfig.LearnSkillLV)); |
| | | } |
| | | break; |
| | | case 3: |
| | | MessageWin.Inst.ShowFixedTip(Language.Get("Hallows_SpUnEnough")); |
| | | break; |
| | | case 4: |
| | | SysNotifyMgr.Instance.ShowTip("TreasureUnsealed"); |
| | | 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 = ConfigManager.Instance.GetTemplate<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 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 = ConfigManager.Instance.GetTemplate<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) |
| | | { |
| | | PotentialLevelUpAnimation(_potentialId, potential.level); |
| | | } |
| | | var levelUpConfig = GetPotentialLevelUpConfig(); |
| | | if (levelUpConfig.own < levelUpConfig.need) |
| | | { |
| | | model.selectedPotentialBook = 0; |
| | | } |
| | | |
| | | var curconfig = ConfigManager.Instance.GetTemplate<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 = ConfigManager.Instance.GetTemplate<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) |
| | | { |
| | | if (level == 1) |
| | | { |
| | | m_PotentialLine.Display(i, false); |
| | | } |
| | | 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); |
| | | m_UpgradeImage.gray = !TestPotentialLevelUp(); |
| | | break; |
| | | } |
| | | } |
| | | |
| | | private bool TestPotentialLevelUp() |
| | | { |
| | | var error = 0; |
| | | return TestPotentialLevelUp(out error); |
| | | } |
| | | |
| | | private bool TestPotentialLevelUp(out int _error) |
| | | { |
| | | //1.人物等级要求不足;2.前置技能等级不足;3.sp不足;4.法宝未获得;5.已经最大等级 |
| | | if (m_Treasure.state != TreasureState.Collected) |
| | | { |
| | | _error = 4; |
| | | return false; |
| | | } |
| | | |
| | | var skillConfig = ConfigManager.Instance.GetTemplate<SkillConfig>(selectedPotential); |
| | | if (PlayerDatas.Instance.baseData.LV < skillConfig.LearnLVReq) |
| | | { |
| | | _error = 1; |
| | | return false; |
| | | } |
| | | |
| | | if (skillConfig.LearnSkillReq > 0) |
| | | { |
| | | var preSkillConfig = ConfigManager.Instance.GetTemplate<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 = 4; |
| | | 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 = ConfigManager.Instance.GetTemplate<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 = ConfigManager.Instance.GetTemplate<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 = ConfigManager.Instance.GetTemplate<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 = ConfigManager.Instance.GetTemplate<SkillConfig>(potential.id); |
| | | var requirement = string.Empty; |
| | | if (skillConfig.LearnSkillReq > 0 && skillConfig.LearnSkillLV > 0) |
| | | { |
| | | var preskillConfig = ConfigManager.Instance.GetTemplate<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 = ConfigManager.Instance.GetTemplate<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); |
| | | } |
| | | } |
| | | |
| | | } |
| | | |
| | | } |
| | | |
| | | |
| | | |
| | | //--------------------------------------------------------
|
| | | // [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));
|
| | | m_ContainerRequirement.gameObject.SetActive(!isMax);
|
| | |
|
| | | if (!isMax)
|
| | | {
|
| | | DisplayUpgradeCost();
|
| | | DisplayGetSkill();
|
| | | DisplaySuccessRatio();
|
| | | m_UpgradeImage.gray = !TestPotentialLevelUp();
|
| | | }
|
| | | 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);
|
| | | m_PotentialLine.Display(i, m_Treasure.potentials[i].level >= 1);
|
| | | }
|
| | | 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)
|
| | | {
|
| | | DisplayPotentialBook(0);
|
| | | }
|
| | |
|
| | | 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;
|
| | |
|
| | | 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();
|
| | | }
|
| | |
|
| | | 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_SelectedPotential = 0;
|
| | | }
|
| | |
|
| | | private void RedpointValueChangeEvent(int _id)
|
| | | {
|
| | | if (m_Treasure != null && _id == m_Treasure.skillLevelUpRedpoint.id)
|
| | | {
|
| | | DisplayAddBookRedpoint();
|
| | | }
|
| | | }
|
| | |
|
| | | private void OnPotentialLevelUpComplete(int _index)
|
| | | {
|
| | | var potential = m_Treasure.potentials[_index];
|
| | | m_PotentialLine.Display(_index, true);
|
| | | potentialBriefInfos[_index].DisplayStateSfx();
|
| | | potentialBriefInfos[_index].StartLevelTween();
|
| | | 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)
|
| | | {
|
| | | potentialBriefInfos[i].potentialTween.SetStartState();
|
| | | potentialBriefInfos[i].potentialTween.enabled = false;
|
| | | m_TreasureAnimation.UnlockTreasurePotential(i);
|
| | | }
|
| | | }
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | private void OnUnlockPotentialComplete(int _index)
|
| | | {
|
| | | selectedPotential = m_Treasure.potentials[_index].id;
|
| | | }
|
| | |
|
| | | 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);
|
| | | }
|
| | | 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);
|
| | | }
|
| | | break;
|
| | | }
|
| | | }
|
| | |
|
| | | 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);
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | 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);
|
| | | m_UpgradeImage.gray = spOwn < spNeed;
|
| | | }
|
| | |
|
| | | 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);
|
| | | m_SuccessRatio.color = UIHelper.GetUIColor(model.selectedPotentialBook != 0 ? TextColType.DarkGreen : TextColType.LightYellow);
|
| | | }
|
| | |
|
| | | 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();
|
| | | m_PotentialCount.text = StringUtility.Contact(levelUpConfig.own, "/", 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 (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:
|
| | | MessageWin.Inst.ShowFixedTip(Language.Get("Hallows_SpUnEnough"));
|
| | | break;
|
| | | case 4:
|
| | | SysNotifyMgr.Instance.ShowTip("TreasureUnsealed");
|
| | | 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 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)
|
| | | {
|
| | | PotentialLevelUpAnimation(_potentialId, potential.level);
|
| | | }
|
| | | var levelUpConfig = GetPotentialLevelUpConfig();
|
| | | if (levelUpConfig.own < levelUpConfig.need)
|
| | | {
|
| | | 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)
|
| | | {
|
| | | if (level == 1)
|
| | | {
|
| | | m_PotentialLine.Display(i, false);
|
| | | }
|
| | | 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);
|
| | | m_UpgradeImage.gray = !TestPotentialLevelUp();
|
| | | break;
|
| | | }
|
| | | }
|
| | |
|
| | | private bool TestPotentialLevelUp()
|
| | | {
|
| | | var error = 0;
|
| | | return TestPotentialLevelUp(out error);
|
| | | }
|
| | |
|
| | | private bool TestPotentialLevelUp(out int _error)
|
| | | {
|
| | | //1.人物等级要求不足;2.前置技能等级不足;3.sp不足;4.法宝未获得;5.已经最大等级
|
| | | 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 = 4;
|
| | | 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);
|
| | | }
|
| | | }
|
| | |
|
| | | }
|
| | |
|
| | | }
|
| | |
|
| | |
|
| | |
|