| | |
| | | //-------------------------------------------------------- |
| | | // [Author]: 第二世界 |
| | | // [ Date ]: Thursday, December 07, 2017 |
| | | //-------------------------------------------------------- |
| | | using UnityEngine; |
| | | using System.Collections; |
| | | using UnityEngine.UI; |
| | | using TableConfig; |
| | | using System; |
| | | using System.Collections.Generic; |
| | | |
| | | namespace Snxxz.UI |
| | | { |
| | | |
| | | public class TreasureCollectBriefInfoBehaviour : MonoBehaviour |
| | | { |
| | | [SerializeField] RectTransform m_NormalContainer; |
| | | [SerializeField] Image m_Icon; |
| | | [SerializeField] Image m_TreasureName; |
| | | [SerializeField] Text m_Description; |
| | | [SerializeField] Button m_Goto; |
| | | [SerializeField] UIEffect m_ChallengeEffect; |
| | | [SerializeField] UIEffect m_CastSoulEffect; |
| | | [SerializeField] UIEffect m_CollectSoulEffect; |
| | | |
| | | [SerializeField] RectTransform m_AllCompletedContainer; |
| | | |
| | | bool dirty = false; |
| | | |
| | | int m_DisplayTreasureId = 0; |
| | | int displayTreasureId { |
| | | get { return m_DisplayTreasureId; } |
| | | set { |
| | | if (m_DisplayTreasureId != value) |
| | | { |
| | | m_DisplayTreasureId = value; |
| | | dirty = true; |
| | | } |
| | | } |
| | | } |
| | | |
| | | DisplayState m_DisplayState = DisplayState.None; |
| | | DisplayState displayState { |
| | | get { return m_DisplayState; } |
| | | set { |
| | | if (m_DisplayState != value) |
| | | { |
| | | m_DisplayState = value; |
| | | dirty = true; |
| | | } |
| | | } |
| | | } |
| | | |
| | | int m_EffectState = 0; |
| | | int effectState { |
| | | get { return m_EffectState; } |
| | | set { |
| | | if (m_EffectState != value) |
| | | { |
| | | m_EffectState = value; |
| | | dirty = true; |
| | | } |
| | | } |
| | | } |
| | | |
| | | TreasureModel model { get { return ModelCenter.Instance.GetModel<TreasureModel>(); } } |
| | | AchievementModel achievementModel { get { return ModelCenter.Instance.GetModel<AchievementModel>(); } } |
| | | |
| | | List<int> m_HumanTreasures; |
| | | List<int> humanTreasures { get { return m_HumanTreasures ?? (m_HumanTreasures = model.GetTreasureCategory(TreasureCategory.Human)); } } |
| | | |
| | | public void Display() |
| | | { |
| | | displayTreasureId = 0; |
| | | displayState = DisplayState.None; |
| | | effectState = 0; |
| | | dirty = true; |
| | | UpdateDisplayState(); |
| | | DisplayTreasureInfo(); |
| | | |
| | | m_Goto.RemoveAllListeners(); |
| | | m_Goto.AddListener(ViewTreasure); |
| | | |
| | | achievementModel.achievementAwardableEvent -= OnAchievementAwardable; |
| | | achievementModel.achievementCompletedEvent -= OnAchievementCompleted; |
| | | model.treasureStageUpEvent -= OnCastSoul; |
| | | model.humanTreasureStateChangeEvent -= OnHumanTreasureStateChange; |
| | | model.potentialLevelChangeEvent -= OnPotentialLevelChange; |
| | | RedpointCenter.Instance.redpointValueChangeEvent -= OnRedpointUpdate; |
| | | |
| | | achievementModel.achievementAwardableEvent += OnAchievementAwardable; |
| | | achievementModel.achievementCompletedEvent += OnAchievementCompleted; |
| | | model.treasureStageUpEvent += OnCastSoul; |
| | | model.humanTreasureStateChangeEvent += OnHumanTreasureStateChange; |
| | | model.potentialLevelChangeEvent += OnPotentialLevelChange; |
| | | RedpointCenter.Instance.redpointValueChangeEvent += OnRedpointUpdate; |
| | | } |
| | | |
| | | public void Dispose() |
| | | { |
| | | m_Goto.RemoveAllListeners(); |
| | | |
| | | achievementModel.achievementAwardableEvent -= OnAchievementAwardable; |
| | | achievementModel.achievementCompletedEvent -= OnAchievementCompleted; |
| | | model.treasureStageUpEvent -= OnCastSoul; |
| | | model.humanTreasureStateChangeEvent -= OnHumanTreasureStateChange; |
| | | model.potentialLevelChangeEvent -= OnPotentialLevelChange; |
| | | |
| | | RedpointCenter.Instance.redpointValueChangeEvent += OnRedpointUpdate; |
| | | } |
| | | |
| | | private void OnHumanTreasureStateChange(int _treasureId) |
| | | { |
| | | UpdateDisplayState(); |
| | | DisplayTreasureInfo(); |
| | | } |
| | | |
| | | private void OnAchievementAwardable(int _achievementId) |
| | | { |
| | | UpdateDisplayState(); |
| | | DisplayTreasureInfo(); |
| | | } |
| | | |
| | | private void OnAchievementCompleted(int _achievementId) |
| | | { |
| | | UpdateDisplayState(); |
| | | DisplayTreasureInfo(); |
| | | } |
| | | |
| | | private void OnCastSoul(int _treasureId) |
| | | { |
| | | UpdateDisplayState(); |
| | | DisplayTreasureInfo(); |
| | | } |
| | | |
| | | private void OnPotentialLevelChange(int _treasureId, int _potentialId) |
| | | { |
| | | UpdateDisplayState(); |
| | | DisplayTreasureInfo(); |
| | | } |
| | | |
| | | private void OnRedpointUpdate(int _redpointId) |
| | | { |
| | | if (_redpointId == 7001) |
| | | { |
| | | UpdateDisplayState(); |
| | | DisplayTreasureInfo(); |
| | | } |
| | | } |
| | | |
| | | private void UpdateDisplayState() |
| | | { |
| | | var treasureId = 0; |
| | | if (displayState != DisplayState.PotentialUp && displayState != DisplayState.PotentialUpAble && displayState != DisplayState.AllCompleted) |
| | | { |
| | | treasureId = GetAwakenAbleTreasure(); |
| | | if (treasureId != 0) |
| | | { |
| | | this.displayTreasureId = treasureId; |
| | | displayState = DisplayState.AwakenAble; |
| | | effectState = 2; |
| | | return; |
| | | } |
| | | |
| | | treasureId = GetCanCollectSoulTreasure(); |
| | | if (treasureId != 0) |
| | | { |
| | | this.displayTreasureId = treasureId; |
| | | displayState = DisplayState.CollectSoul; |
| | | effectState = 3; |
| | | return; |
| | | } |
| | | |
| | | treasureId = GetCanChallengeTreasure(); |
| | | if (treasureId != 0) |
| | | { |
| | | this.displayTreasureId = treasureId; |
| | | displayState = DisplayState.Challenge; |
| | | effectState = 0; |
| | | return; |
| | | } |
| | | |
| | | treasureId = GetAwakenUnderwayTreasure1(); |
| | | if (treasureId != 0) |
| | | { |
| | | this.displayTreasureId = treasureId; |
| | | displayState = DisplayState.AwakenUnderway; |
| | | effectState = 0; |
| | | return; |
| | | } |
| | | |
| | | if (FuncOpen.Instance.IsFuncOpen(126)) |
| | | { |
| | | treasureId = GetTreasureSoulTreasure(); |
| | | if (treasureId != 0) |
| | | { |
| | | this.displayTreasureId = treasureId; |
| | | displayState = DisplayState.TreasureSoul; |
| | | effectState = 0; |
| | | return; |
| | | } |
| | | |
| | | treasureId = GetNextChallengeTreasure(); |
| | | if (treasureId != 0) |
| | | { |
| | | this.displayTreasureId = treasureId; |
| | | displayState = DisplayState.WaitUnLock; |
| | | effectState = 0; |
| | | return; |
| | | } |
| | | } |
| | | else |
| | | { |
| | | treasureId = GetNextChallengeTreasure(); |
| | | if (treasureId != 0) |
| | | { |
| | | this.displayTreasureId = treasureId; |
| | | displayState = DisplayState.WaitUnLock; |
| | | effectState = 0; |
| | | return; |
| | | } |
| | | |
| | | treasureId = GetTreasureSoulTreasure(); |
| | | if (treasureId != 0) |
| | | { |
| | | this.displayTreasureId = treasureId; |
| | | displayState = DisplayState.TreasureSoul; |
| | | effectState = 0; |
| | | return; |
| | | } |
| | | } |
| | | } |
| | | |
| | | if (displayState == DisplayState.None || displayState == DisplayState.PotentialUp || displayState == DisplayState.PotentialUpAble) |
| | | { |
| | | treasureId = GetPotentialUpAbleTreasure(); |
| | | if (treasureId != 0) |
| | | { |
| | | this.displayTreasureId = treasureId; |
| | | displayState = DisplayState.PotentialUpAble; |
| | | effectState = 0; |
| | | return; |
| | | } |
| | | |
| | | treasureId = GetPotentialUpTreasure(15); |
| | | if (treasureId != 0) |
| | | { |
| | | this.displayTreasureId = treasureId; |
| | | displayState = DisplayState.PotentialUp; |
| | | effectState = 0; |
| | | return; |
| | | } |
| | | } |
| | | |
| | | this.displayTreasureId = 0; |
| | | displayState = DisplayState.AllCompleted; |
| | | effectState = 0; |
| | | } |
| | | |
| | | private void DisplayTreasureInfo() |
| | | { |
| | | if (dirty) |
| | | { |
| | | if (displayState == DisplayState.AllCompleted || displayTreasureId == 0) |
| | | { |
| | | m_NormalContainer.gameObject.SetActive(false); |
| | | m_AllCompletedContainer.gameObject.SetActive(true); |
| | | return; |
| | | } |
| | | |
| | | if (!m_NormalContainer.gameObject.activeSelf) |
| | | { |
| | | m_NormalContainer.gameObject.SetActive(true); |
| | | } |
| | | |
| | | if (m_AllCompletedContainer.gameObject.activeSelf) |
| | | { |
| | | m_AllCompletedContainer.gameObject.SetActive(false); |
| | | } |
| | | |
| | | var config = ConfigManager.Instance.GetTemplate<TreasureConfig>(displayTreasureId); |
| | | m_Icon.SetSprite(config.Icon); |
| | | m_TreasureName.SetSprite(config.NameIcon); |
| | | m_TreasureName.SetNativeSize(); |
| | | |
| | | if (effectState == 1) |
| | | { |
| | | m_ChallengeEffect.Play(); |
| | | } |
| | | else |
| | | { |
| | | m_ChallengeEffect.Stop(); |
| | | } |
| | | |
| | | if (effectState == 2) |
| | | { |
| | | m_CastSoulEffect.Play(); |
| | | } |
| | | else |
| | | { |
| | | m_CastSoulEffect.Stop(); |
| | | } |
| | | |
| | | if (effectState == 3) |
| | | { |
| | | m_CollectSoulEffect.Play(); |
| | | } |
| | | else |
| | | { |
| | | m_CollectSoulEffect.Stop(); |
| | | } |
| | | |
| | | Treasure treasure; |
| | | model.TryGetTreasure(displayTreasureId, out treasure); |
| | | |
| | | switch (displayState) |
| | | { |
| | | case DisplayState.Challenge: |
| | | m_Description.text = Language.Get("FabaoState_Text_1"); |
| | | break; |
| | | case DisplayState.AwakenAble: |
| | | m_Description.text = Language.Get("FabaoState_Text_2"); |
| | | break; |
| | | case DisplayState.CollectSoul: |
| | | m_Description.text = Language.Get("FabaoState_Text_3"); |
| | | break; |
| | | case DisplayState.AwakenUnderway: |
| | | var progress = 1f; |
| | | if (treasure != null && config.PreferredStage != 0) |
| | | { |
| | | progress = (float)treasure.stage / config.PreferredStage; |
| | | } |
| | | |
| | | m_Description.text = Language.Get("FabaoState_Text_4", Mathf.RoundToInt(progress * 100f)); |
| | | break; |
| | | case DisplayState.TreasureSoul: |
| | | if (treasure != null) |
| | | { |
| | | var privilege = treasure.unLockPrivilege; |
| | | if (privilege != 0) |
| | | { |
| | | var privilegeConfig = ConfigManager.Instance.GetTemplate<TreasurePrivilegeConfig>(privilege); |
| | | m_Description.text = Language.Get("FabaoState_Text_8", privilegeConfig.Name); |
| | | } |
| | | else |
| | | { |
| | | m_Description.text = Language.Get("FabaoState_Text_8", config.Name); |
| | | } |
| | | } |
| | | break; |
| | | case DisplayState.WaitUnLock: |
| | | Achievement achievement = null; |
| | | var achievementId = 0; |
| | | if (model.TryGetTreasureUnlockAchievement(displayTreasureId, out achievementId)) |
| | | { |
| | | if (achievementModel.TryGetAchievement(achievementId, out achievement)) |
| | | { |
| | | var achievementConfig = ConfigManager.Instance.GetTemplate<SuccessConfig>(achievementId); |
| | | var missionId = achievementConfig.Condition[0]; |
| | | var taskConfig = ConfigManager.Instance.GetTemplate<PyTaskConfig>(missionId); |
| | | |
| | | m_Description.text = Language.Get("FabaoState_Text_5", taskConfig.lv); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | m_Description.text = Language.Get("FabaoState_Text_5"); |
| | | } |
| | | break; |
| | | case DisplayState.PotentialUpAble: |
| | | m_Description.text = Language.Get("FabaoState_Text_9"); |
| | | break; |
| | | case DisplayState.PotentialUp: |
| | | m_Description.text = Language.Get("FabaoState_Text_6"); |
| | | break; |
| | | case DisplayState.AllCompleted: |
| | | m_NormalContainer.gameObject.SetActive(false); |
| | | m_AllCompletedContainer.gameObject.SetActive(true); |
| | | break; |
| | | } |
| | | } |
| | | } |
| | | |
| | | private void ViewTreasure() |
| | | { |
| | | if (displayState == DisplayState.Challenge) |
| | | { |
| | | Treasure treasure; |
| | | if (model.TryGetTreasure(displayTreasureId, out treasure)) |
| | | { |
| | | if (!treasure.hasClickChallenge) |
| | | { |
| | | var sendInfo = new CA516_tagCMMagicWeaponState(); |
| | | sendInfo.MWID = (uint)displayTreasureId; |
| | | GameNetSystem.Instance.SendInfo(sendInfo); |
| | | } |
| | | |
| | | treasure.hasClickChallenge = true; |
| | | } |
| | | } |
| | | |
| | | WindowCenter.Instance.Close<MainInterfaceWin>(); |
| | | if (model.GetTreasureUnlockShow(TreasureCategory.Human) == displayTreasureId) |
| | | { |
| | | model.treasureGotoId = displayTreasureId; |
| | | model.currentCategory = TreasureCategory.Human; |
| | | WindowCenter.Instance.Open<TreasureSelectWin>(); |
| | | } |
| | | else |
| | | { |
| | | var config = ConfigManager.Instance.GetTemplate<TreasureConfig>(displayTreasureId); |
| | | model.selectedTreasure = displayTreasureId; |
| | | model.currentCategory = (TreasureCategory)config.Category; |
| | | model.openFromTreasureCollect = true; |
| | | WindowCenter.Instance.Open<TreasureLevelUpWin>(); |
| | | } |
| | | } |
| | | |
| | | private int GetCanChallengeTreasure() |
| | | { |
| | | for (int i = 0; i < humanTreasures.Count; i++) |
| | | { |
| | | Treasure treasure; |
| | | if (model.TryGetTreasure(humanTreasures[i], out treasure)) |
| | | { |
| | | var humanTreasure = treasure as HumanTreasure; |
| | | if (humanTreasure != null && humanTreasure.humanState == HumanTreasureState.Challenge) |
| | | { |
| | | return humanTreasures[i]; |
| | | } |
| | | } |
| | | } |
| | | |
| | | return 0; |
| | | } |
| | | |
| | | private int GetAwakenAbleTreasure() |
| | | { |
| | | for (int i = 0; i < humanTreasures.Count; i++) |
| | | { |
| | | Treasure treasure; |
| | | if (model.TryGetTreasure(humanTreasures[i], out treasure)) |
| | | { |
| | | var humanTreasure = treasure as HumanTreasure; |
| | | if (humanTreasure != null && humanTreasure.castSoulRedpoint != null && humanTreasure.castSoulRedpoint.state == RedPointState.Simple) |
| | | { |
| | | return humanTreasures[i]; |
| | | } |
| | | } |
| | | } |
| | | |
| | | return 0; |
| | | } |
| | | |
| | | private int GetCanCollectSoulTreasure() |
| | | { |
| | | for (int i = 0; i < humanTreasures.Count; i++) |
| | | { |
| | | if (IsTreasureCollectSoul(humanTreasures[i])) |
| | | { |
| | | return humanTreasures[i]; |
| | | } |
| | | } |
| | | |
| | | return 0; |
| | | } |
| | | |
| | | private int GetAwakenUnderwayTreasure1() |
| | | { |
| | | return humanTreasures.Find((x) => |
| | | { |
| | | Treasure treasure; |
| | | if (model.TryGetTreasure(x, out treasure)) |
| | | { |
| | | var humanTreasure = treasure as HumanTreasure; |
| | | var config = ConfigManager.Instance.GetTemplate<TreasureConfig>(humanTreasure.id); |
| | | return humanTreasure != null && humanTreasure.humanState == HumanTreasureState.CastSoul && humanTreasure.stage < config.PreferredStage; |
| | | } |
| | | else |
| | | { |
| | | return false; |
| | | } |
| | | } |
| | | ); |
| | | } |
| | | |
| | | private int GetTreasureSoulTreasure() |
| | | { |
| | | return humanTreasures.Find((x) => |
| | | { |
| | | Treasure treasure; |
| | | if (model.TryGetTreasure(x, out treasure)) |
| | | { |
| | | var humanTreasure = treasure as HumanTreasure; |
| | | return humanTreasure != null && humanTreasure.humanState == HumanTreasureState.CastSoul; |
| | | } |
| | | else |
| | | { |
| | | return false; |
| | | } |
| | | } |
| | | ); |
| | | } |
| | | |
| | | private int GetNextChallengeTreasure() |
| | | { |
| | | for (int i = 0; i < humanTreasures.Count; i++) |
| | | { |
| | | Treasure treasure; |
| | | if (model.TryGetTreasure(humanTreasures[i], out treasure)) |
| | | { |
| | | var humanTreasure = treasure as HumanTreasure; |
| | | if (humanTreasure != null && humanTreasure.humanState == HumanTreasureState.Locked) |
| | | { |
| | | return humanTreasures[i]; |
| | | } |
| | | } |
| | | } |
| | | |
| | | return 0; |
| | | } |
| | | |
| | | private int GetPotentialUpAbleTreasure() |
| | | { |
| | | for (int i = 0; i < humanTreasures.Count; i++) |
| | | { |
| | | Treasure treasure; |
| | | if (model.TryGetTreasure(humanTreasures[i], out treasure)) |
| | | { |
| | | var humanTreasure = treasure as HumanTreasure; |
| | | if (humanTreasure != null && humanTreasure.skillLevelUpRedpoint.state == RedPointState.Simple) |
| | | { |
| | | return humanTreasures[i]; |
| | | } |
| | | } |
| | | } |
| | | |
| | | return 0; |
| | | } |
| | | |
| | | private int GetPotentialUpTreasure(int _lastPotentialLevel) |
| | | { |
| | | for (int i = 0; i < humanTreasures.Count; i++) |
| | | { |
| | | Treasure treasure; |
| | | if (model.TryGetTreasure(humanTreasures[i], out treasure)) |
| | | { |
| | | var humanTreasure = treasure as HumanTreasure; |
| | | if (humanTreasure != null && humanTreasure.humanState == HumanTreasureState.Potential) |
| | | { |
| | | var lastPotential = humanTreasure.potentials[humanTreasure.potentials.Count - 1]; |
| | | if (lastPotential.level < _lastPotentialLevel) |
| | | { |
| | | return humanTreasures[i]; |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | for (int i = 0; i < humanTreasures.Count; i++) |
| | | { |
| | | Treasure treasure; |
| | | if (model.TryGetTreasure(humanTreasures[i], out treasure)) |
| | | { |
| | | var humanTreasure = treasure as HumanTreasure; |
| | | if (humanTreasure != null && humanTreasure.humanState == HumanTreasureState.Potential) |
| | | { |
| | | return humanTreasures[i]; |
| | | } |
| | | } |
| | | } |
| | | |
| | | return 0; |
| | | } |
| | | |
| | | private bool IsTreasureCollectSoul(int _treasureId) |
| | | { |
| | | Treasure treasure; |
| | | |
| | | if (model.TryGetTreasure(_treasureId, out treasure)) |
| | | { |
| | | var humanTreasure = treasure as HumanTreasure; |
| | | if (humanTreasure.humanState == HumanTreasureState.CastSoul) |
| | | { |
| | | foreach (var achievementGroup in treasure.achievementGroups.Values) |
| | | { |
| | | if (achievementGroup.IsAwardable()) |
| | | { |
| | | return true; |
| | | } |
| | | } |
| | | } |
| | | |
| | | return false; |
| | | } |
| | | else |
| | | { |
| | | return false; |
| | | } |
| | | } |
| | | |
| | | enum DisplayState |
| | | { |
| | | None, |
| | | Challenge, |
| | | AwakenAble,//可觉醒 |
| | | CollectSoul,//可集魂 |
| | | AwakenUnderway,//觉醒进行中 |
| | | TreasureSoul,//法宝魂觉醒中 |
| | | WaitUnLock,//等待解封 |
| | | PotentialUp,//潜力提升进行中 |
| | | PotentialUpAble,//潜力可提升 |
| | | AllCompleted, |
| | | } |
| | | |
| | | } |
| | | |
| | | } |
| | | |
| | | |
| | | |
| | | //--------------------------------------------------------
|
| | | // [Author]: 第二世界
|
| | | // [ Date ]: Thursday, December 07, 2017
|
| | | //--------------------------------------------------------
|
| | | using UnityEngine;
|
| | | using System.Collections;
|
| | | using UnityEngine.UI;
|
| | | using TableConfig;
|
| | | using System;
|
| | | using System.Collections.Generic;
|
| | |
|
| | | namespace Snxxz.UI
|
| | | {
|
| | |
|
| | | public class TreasureCollectBriefInfoBehaviour : MonoBehaviour
|
| | | {
|
| | | [SerializeField] RectTransform m_NormalContainer;
|
| | | [SerializeField] Image m_Icon;
|
| | | [SerializeField] Image m_TreasureName;
|
| | | [SerializeField] Text m_Description;
|
| | | [SerializeField] Button m_Goto;
|
| | | [SerializeField] UIEffect m_ChallengeEffect;
|
| | | [SerializeField] UIEffect m_CastSoulEffect;
|
| | | [SerializeField] UIEffect m_CollectSoulEffect;
|
| | |
|
| | | [SerializeField] RectTransform m_AllCompletedContainer;
|
| | |
|
| | | bool dirty = false;
|
| | |
|
| | | int m_DisplayTreasureId = 0;
|
| | | int displayTreasureId {
|
| | | get { return m_DisplayTreasureId; }
|
| | | set {
|
| | | if (m_DisplayTreasureId != value)
|
| | | {
|
| | | m_DisplayTreasureId = value;
|
| | | dirty = true;
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | DisplayState m_DisplayState = DisplayState.None;
|
| | | DisplayState displayState {
|
| | | get { return m_DisplayState; }
|
| | | set {
|
| | | if (m_DisplayState != value)
|
| | | {
|
| | | m_DisplayState = value;
|
| | | dirty = true;
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | int m_EffectState = 0;
|
| | | int effectState {
|
| | | get { return m_EffectState; }
|
| | | set {
|
| | | if (m_EffectState != value)
|
| | | {
|
| | | m_EffectState = value;
|
| | | dirty = true;
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | TreasureModel model { get { return ModelCenter.Instance.GetModel<TreasureModel>(); } }
|
| | | AchievementModel achievementModel { get { return ModelCenter.Instance.GetModel<AchievementModel>(); } }
|
| | |
|
| | | List<int> m_HumanTreasures;
|
| | | List<int> humanTreasures { get { return m_HumanTreasures ?? (m_HumanTreasures = model.GetTreasureCategory(TreasureCategory.Human)); } }
|
| | |
|
| | | public void Display()
|
| | | {
|
| | | displayTreasureId = 0;
|
| | | displayState = DisplayState.None;
|
| | | effectState = 0;
|
| | | dirty = true;
|
| | | UpdateDisplayState();
|
| | | DisplayTreasureInfo();
|
| | |
|
| | | m_Goto.RemoveAllListeners();
|
| | | m_Goto.AddListener(ViewTreasure);
|
| | |
|
| | | achievementModel.achievementAwardableEvent -= OnAchievementAwardable;
|
| | | achievementModel.achievementCompletedEvent -= OnAchievementCompleted;
|
| | | model.treasureStageUpEvent -= OnCastSoul;
|
| | | model.humanTreasureStateChangeEvent -= OnHumanTreasureStateChange;
|
| | | model.potentialLevelChangeEvent -= OnPotentialLevelChange;
|
| | | RedpointCenter.Instance.redpointValueChangeEvent -= OnRedpointUpdate;
|
| | |
|
| | | achievementModel.achievementAwardableEvent += OnAchievementAwardable;
|
| | | achievementModel.achievementCompletedEvent += OnAchievementCompleted;
|
| | | model.treasureStageUpEvent += OnCastSoul;
|
| | | model.humanTreasureStateChangeEvent += OnHumanTreasureStateChange;
|
| | | model.potentialLevelChangeEvent += OnPotentialLevelChange;
|
| | | RedpointCenter.Instance.redpointValueChangeEvent += OnRedpointUpdate;
|
| | | }
|
| | |
|
| | | public void Dispose()
|
| | | {
|
| | | m_Goto.RemoveAllListeners();
|
| | |
|
| | | achievementModel.achievementAwardableEvent -= OnAchievementAwardable;
|
| | | achievementModel.achievementCompletedEvent -= OnAchievementCompleted;
|
| | | model.treasureStageUpEvent -= OnCastSoul;
|
| | | model.humanTreasureStateChangeEvent -= OnHumanTreasureStateChange;
|
| | | model.potentialLevelChangeEvent -= OnPotentialLevelChange;
|
| | |
|
| | | RedpointCenter.Instance.redpointValueChangeEvent -= OnRedpointUpdate;
|
| | | }
|
| | |
|
| | | private void OnHumanTreasureStateChange(int _treasureId)
|
| | | {
|
| | | UpdateDisplayState();
|
| | | DisplayTreasureInfo();
|
| | | }
|
| | |
|
| | | private void OnAchievementAwardable(int _achievementId)
|
| | | {
|
| | | UpdateDisplayState();
|
| | | DisplayTreasureInfo();
|
| | | }
|
| | |
|
| | | private void OnAchievementCompleted(int _achievementId)
|
| | | {
|
| | | UpdateDisplayState();
|
| | | DisplayTreasureInfo();
|
| | | }
|
| | |
|
| | | private void OnCastSoul(int _treasureId)
|
| | | {
|
| | | UpdateDisplayState();
|
| | | DisplayTreasureInfo();
|
| | | }
|
| | |
|
| | | private void OnPotentialLevelChange(int _treasureId, int _potentialId)
|
| | | {
|
| | | UpdateDisplayState();
|
| | | DisplayTreasureInfo();
|
| | | }
|
| | |
|
| | | private void OnRedpointUpdate(int _redpointId)
|
| | | {
|
| | | if (_redpointId == 7001)
|
| | | {
|
| | | UpdateDisplayState();
|
| | | DisplayTreasureInfo();
|
| | | }
|
| | | }
|
| | |
|
| | | private void UpdateDisplayState()
|
| | | {
|
| | | var treasureId = 0;
|
| | | if (displayState != DisplayState.PotentialUp && displayState != DisplayState.PotentialUpAble && displayState != DisplayState.AllCompleted)
|
| | | {
|
| | | treasureId = GetAwakenAbleTreasure();
|
| | | if (treasureId != 0)
|
| | | {
|
| | | this.displayTreasureId = treasureId;
|
| | | displayState = DisplayState.AwakenAble;
|
| | | effectState = 2;
|
| | | return;
|
| | | }
|
| | |
|
| | | treasureId = GetCanCollectSoulTreasure();
|
| | | if (treasureId != 0)
|
| | | {
|
| | | this.displayTreasureId = treasureId;
|
| | | displayState = DisplayState.CollectSoul;
|
| | | effectState = 3;
|
| | | return;
|
| | | }
|
| | |
|
| | | treasureId = GetCanChallengeTreasure();
|
| | | if (treasureId != 0)
|
| | | {
|
| | | this.displayTreasureId = treasureId;
|
| | | displayState = DisplayState.Challenge;
|
| | | effectState = 0;
|
| | | return;
|
| | | }
|
| | |
|
| | | treasureId = GetAwakenUnderwayTreasure1();
|
| | | if (treasureId != 0)
|
| | | {
|
| | | this.displayTreasureId = treasureId;
|
| | | displayState = DisplayState.AwakenUnderway;
|
| | | effectState = 0;
|
| | | return;
|
| | | }
|
| | |
|
| | | treasureId = GetNextChallengeTreasure();
|
| | | if (treasureId != 0)
|
| | | {
|
| | | this.displayTreasureId = treasureId;
|
| | | displayState = DisplayState.WaitUnLock;
|
| | | effectState = 0;
|
| | | return;
|
| | | }
|
| | | }
|
| | |
|
| | | if (displayState == DisplayState.None || displayState == DisplayState.PotentialUp || displayState == DisplayState.PotentialUpAble)
|
| | | {
|
| | | treasureId = GetPotentialUpAbleTreasure();
|
| | | if (treasureId != 0)
|
| | | {
|
| | | this.displayTreasureId = treasureId;
|
| | | displayState = DisplayState.PotentialUpAble;
|
| | | effectState = 0;
|
| | | return;
|
| | | }
|
| | |
|
| | | treasureId = GetPotentialUpTreasure(15);
|
| | | if (treasureId != 0)
|
| | | {
|
| | | this.displayTreasureId = treasureId;
|
| | | displayState = DisplayState.PotentialUp;
|
| | | effectState = 0;
|
| | | return;
|
| | | }
|
| | | }
|
| | |
|
| | | this.displayTreasureId = 0;
|
| | | displayState = DisplayState.AllCompleted;
|
| | | effectState = 0;
|
| | | }
|
| | |
|
| | | private void DisplayTreasureInfo()
|
| | | {
|
| | | if (dirty)
|
| | | {
|
| | | if (displayState == DisplayState.AllCompleted || displayTreasureId == 0)
|
| | | {
|
| | | m_NormalContainer.gameObject.SetActive(false);
|
| | | m_AllCompletedContainer.gameObject.SetActive(true);
|
| | | return;
|
| | | }
|
| | |
|
| | | if (!m_NormalContainer.gameObject.activeSelf)
|
| | | {
|
| | | m_NormalContainer.gameObject.SetActive(true);
|
| | | }
|
| | |
|
| | | if (m_AllCompletedContainer.gameObject.activeSelf)
|
| | | {
|
| | | m_AllCompletedContainer.gameObject.SetActive(false);
|
| | | }
|
| | |
|
| | | var config = Config.Instance.Get<TreasureConfig>(displayTreasureId);
|
| | | m_Icon.SetSprite(config.Icon);
|
| | | m_TreasureName.SetSprite(config.NameIcon);
|
| | | m_TreasureName.SetNativeSize();
|
| | |
|
| | | if (effectState == 1)
|
| | | {
|
| | | m_ChallengeEffect.Play();
|
| | | }
|
| | | else
|
| | | {
|
| | | m_ChallengeEffect.Stop();
|
| | | }
|
| | |
|
| | | if (effectState == 2)
|
| | | {
|
| | | m_CastSoulEffect.Play();
|
| | | }
|
| | | else
|
| | | {
|
| | | m_CastSoulEffect.Stop();
|
| | | }
|
| | |
|
| | | if (effectState == 3)
|
| | | {
|
| | | m_CollectSoulEffect.Play();
|
| | | }
|
| | | else
|
| | | {
|
| | | m_CollectSoulEffect.Stop();
|
| | | }
|
| | |
|
| | | Treasure treasure;
|
| | | model.TryGetTreasure(displayTreasureId, out treasure);
|
| | |
|
| | | switch (displayState)
|
| | | {
|
| | | case DisplayState.Challenge:
|
| | | m_Description.text = Language.Get("FabaoState_Text_1");
|
| | | break;
|
| | | case DisplayState.AwakenAble:
|
| | | m_Description.text = Language.Get("FabaoState_Text_2");
|
| | | break;
|
| | | case DisplayState.CollectSoul:
|
| | | m_Description.text = Language.Get("FabaoState_Text_3");
|
| | | break;
|
| | | case DisplayState.AwakenUnderway:
|
| | | var progress = 1f;
|
| | | if (treasure != null && config.PreferredStage != 0)
|
| | | {
|
| | | progress = (float)treasure.stage / config.PreferredStage;
|
| | | }
|
| | |
|
| | | m_Description.text = Language.Get("FabaoState_Text_4", Mathf.RoundToInt(progress * 100f));
|
| | | break;
|
| | | case DisplayState.WaitUnLock:
|
| | | Achievement achievement = null;
|
| | | var achievementId = 0;
|
| | | if (model.TryGetTreasureUnlockAchievement(displayTreasureId, out achievementId))
|
| | | {
|
| | | if (achievementModel.TryGetAchievement(achievementId, out achievement))
|
| | | {
|
| | | var achievementConfig = Config.Instance.Get<SuccessConfig>(achievementId);
|
| | | var missionId = achievementConfig.Condition[0];
|
| | | var taskConfig = Config.Instance.Get<PyTaskConfig>(missionId);
|
| | |
|
| | | m_Description.text = Language.Get("FabaoState_Text_5", taskConfig.lv);
|
| | | }
|
| | | }
|
| | | else
|
| | | {
|
| | | m_Description.text = Language.Get("FabaoState_Text_5");
|
| | | }
|
| | | break;
|
| | | case DisplayState.PotentialUpAble:
|
| | | m_Description.text = Language.Get("FabaoState_Text_9");
|
| | | break;
|
| | | case DisplayState.PotentialUp:
|
| | | m_Description.text = Language.Get("FabaoState_Text_6");
|
| | | break;
|
| | | case DisplayState.AllCompleted:
|
| | | m_NormalContainer.gameObject.SetActive(false);
|
| | | m_AllCompletedContainer.gameObject.SetActive(true);
|
| | | break;
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | private void ViewTreasure()
|
| | | {
|
| | | if (displayState == DisplayState.Challenge)
|
| | | {
|
| | | Treasure treasure;
|
| | | if (model.TryGetTreasure(displayTreasureId, out treasure))
|
| | | {
|
| | | if (!treasure.hasClickChallenge)
|
| | | {
|
| | | var sendInfo = new CA516_tagCMMagicWeaponState();
|
| | | sendInfo.MWID = (uint)displayTreasureId;
|
| | | GameNetSystem.Instance.SendInfo(sendInfo);
|
| | | }
|
| | |
|
| | | treasure.hasClickChallenge = true;
|
| | | }
|
| | | }
|
| | |
|
| | | WindowCenter.Instance.Close<MainInterfaceWin>();
|
| | | if (model.GetTreasureUnlockShow(TreasureCategory.Human) == displayTreasureId)
|
| | | {
|
| | | model.treasureGotoId = displayTreasureId;
|
| | | model.currentCategory = TreasureCategory.Human;
|
| | | WindowCenter.Instance.Open<TreasureSelectWin>();
|
| | | }
|
| | | else
|
| | | {
|
| | | var config = Config.Instance.Get<TreasureConfig>(displayTreasureId);
|
| | | model.selectedTreasure = displayTreasureId;
|
| | | model.currentCategory = (TreasureCategory)config.Category;
|
| | | model.openFromTreasureCollect = true;
|
| | | WindowCenter.Instance.Open<TreasureLevelUpWin>();
|
| | | }
|
| | | }
|
| | |
|
| | | private int GetCanChallengeTreasure()
|
| | | {
|
| | | for (int i = 0; i < humanTreasures.Count; i++)
|
| | | {
|
| | | Treasure treasure;
|
| | | if (model.TryGetTreasure(humanTreasures[i], out treasure))
|
| | | {
|
| | | var humanTreasure = treasure as HumanTreasure;
|
| | | if (humanTreasure != null && humanTreasure.humanState == HumanTreasureState.Challenge)
|
| | | {
|
| | | return humanTreasures[i];
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | return 0;
|
| | | }
|
| | |
|
| | | private int GetAwakenAbleTreasure()
|
| | | {
|
| | | for (int i = 0; i < humanTreasures.Count; i++)
|
| | | {
|
| | | Treasure treasure;
|
| | | if (model.TryGetTreasure(humanTreasures[i], out treasure))
|
| | | {
|
| | | var humanTreasure = treasure as HumanTreasure;
|
| | | if (humanTreasure != null && humanTreasure.castSoulRedpoint != null && humanTreasure.castSoulRedpoint.state == RedPointState.Simple)
|
| | | {
|
| | | return humanTreasures[i];
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | return 0;
|
| | | }
|
| | |
|
| | | private int GetCanCollectSoulTreasure()
|
| | | {
|
| | | for (int i = 0; i < humanTreasures.Count; i++)
|
| | | {
|
| | | if (IsTreasureCollectSoul(humanTreasures[i]))
|
| | | {
|
| | | return humanTreasures[i];
|
| | | }
|
| | | }
|
| | |
|
| | | return 0;
|
| | | }
|
| | |
|
| | | private int GetAwakenUnderwayTreasure1()
|
| | | {
|
| | | return humanTreasures.Find((x) =>
|
| | | {
|
| | | Treasure treasure;
|
| | | if (model.TryGetTreasure(x, out treasure))
|
| | | {
|
| | | var humanTreasure = treasure as HumanTreasure;
|
| | | var config = Config.Instance.Get<TreasureConfig>(humanTreasure.id);
|
| | | return humanTreasure != null && humanTreasure.humanState == HumanTreasureState.CastSoul && humanTreasure.stage < config.PreferredStage;
|
| | | }
|
| | | else
|
| | | {
|
| | | return false;
|
| | | }
|
| | | }
|
| | | );
|
| | | }
|
| | |
|
| | | private int GetNextChallengeTreasure()
|
| | | {
|
| | | for (int i = 0; i < humanTreasures.Count; i++)
|
| | | {
|
| | | Treasure treasure;
|
| | | if (model.TryGetTreasure(humanTreasures[i], out treasure))
|
| | | {
|
| | | var humanTreasure = treasure as HumanTreasure;
|
| | | if (humanTreasure != null && humanTreasure.humanState == HumanTreasureState.Locked)
|
| | | {
|
| | | return humanTreasures[i];
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | return 0;
|
| | | }
|
| | |
|
| | | private int GetPotentialUpAbleTreasure()
|
| | | {
|
| | | for (int i = 0; i < humanTreasures.Count; i++)
|
| | | {
|
| | | Treasure treasure;
|
| | | if (model.TryGetTreasure(humanTreasures[i], out treasure))
|
| | | {
|
| | | var humanTreasure = treasure as HumanTreasure;
|
| | | if (humanTreasure != null && humanTreasure.skillLevelUpRedpoint.state == RedPointState.Simple)
|
| | | {
|
| | | return humanTreasures[i];
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | return 0;
|
| | | }
|
| | |
|
| | | private int GetPotentialUpTreasure(int _lastPotentialLevel)
|
| | | {
|
| | | for (int i = 0; i < humanTreasures.Count; i++)
|
| | | {
|
| | | Treasure treasure;
|
| | | if (model.TryGetTreasure(humanTreasures[i], out treasure))
|
| | | {
|
| | | var humanTreasure = treasure as HumanTreasure;
|
| | | if (humanTreasure != null && humanTreasure.humanState == HumanTreasureState.Potential)
|
| | | {
|
| | | var lastPotential = humanTreasure.potentials[humanTreasure.potentials.Count - 1];
|
| | | if (lastPotential.level < _lastPotentialLevel)
|
| | | {
|
| | | return humanTreasures[i];
|
| | | }
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | for (int i = 0; i < humanTreasures.Count; i++)
|
| | | {
|
| | | Treasure treasure;
|
| | | if (model.TryGetTreasure(humanTreasures[i], out treasure))
|
| | | {
|
| | | var humanTreasure = treasure as HumanTreasure;
|
| | | if (humanTreasure != null && humanTreasure.humanState == HumanTreasureState.Potential)
|
| | | {
|
| | | return humanTreasures[i];
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | return 0;
|
| | | }
|
| | |
|
| | | private bool IsTreasureCollectSoul(int _treasureId)
|
| | | {
|
| | | Treasure treasure;
|
| | |
|
| | | if (model.TryGetTreasure(_treasureId, out treasure))
|
| | | {
|
| | | var humanTreasure = treasure as HumanTreasure;
|
| | | if (humanTreasure.humanState == HumanTreasureState.CastSoul)
|
| | | {
|
| | | foreach (var achievementGroup in treasure.achievementGroups.Values)
|
| | | {
|
| | | if (achievementGroup.IsAwardable())
|
| | | {
|
| | | return true;
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | return false;
|
| | | }
|
| | | else
|
| | | {
|
| | | return false;
|
| | | }
|
| | | }
|
| | |
|
| | | enum DisplayState
|
| | | {
|
| | | None,
|
| | | Challenge,
|
| | | AwakenAble,//可觉醒
|
| | | CollectSoul,//可集魂
|
| | | AwakenUnderway,//觉醒进行中
|
| | | WaitUnLock,//等待解封
|
| | | PotentialUp,//潜力提升进行中
|
| | | PotentialUpAble,//潜力可提升
|
| | | AllCompleted,
|
| | | }
|
| | |
|
| | | }
|
| | |
|
| | | }
|
| | |
|
| | |
|
| | |
|