| | |
| | | [SerializeField] Button m_SelectBtn;
|
| | | [SerializeField] RedpointBehaviour m_Redpoint;
|
| | |
|
| | | int treasureId = 0;
|
| | | int treasureSoulId = 0;
|
| | |
|
| | | Treasure treasure;
|
| | | TreasureSpecialData special;
|
| | |
|
| | | TreasureModel model
|
| | | TreasureSoulModel model
|
| | | {
|
| | | get
|
| | | {
|
| | | return ModelCenter.Instance.GetModel<TreasureModel>();
|
| | | return ModelCenter.Instance.GetModel<TreasureSoulModel>();
|
| | | }
|
| | | }
|
| | |
|
| | | AchievementModel achievementModel { get { return ModelCenter.Instance.GetModel<AchievementModel>(); } }
|
| | |
|
| | | private void Awake()
|
| | | {
|
| | |
| | | private void OnEnable()
|
| | | {
|
| | | model.treasureSelectSoulChangeEvent += TreasureSelectSoulChangeEvent;
|
| | | PlayerDatas.Instance.PlayerDataRefreshInfoEvent += PlayerDataRefreshInfoEvent;
|
| | | model.treasureSoulEvent += TreasureSoulEvent;
|
| | | achievementModel.achievementCompletedEvent += AchievementCompletedEvent;
|
| | | }
|
| | |
|
| | | private void OnDisable()
|
| | | {
|
| | | model.treasureSelectSoulChangeEvent -= TreasureSelectSoulChangeEvent;
|
| | | PlayerDatas.Instance.PlayerDataRefreshInfoEvent -= PlayerDataRefreshInfoEvent;
|
| | | model.treasureSoulEvent -= TreasureSoulEvent;
|
| | | achievementModel.achievementCompletedEvent -= AchievementCompletedEvent;
|
| | | }
|
| | |
|
| | | private void AchievementCompletedEvent(int _id)
|
| | | {
|
| | | int achievementId = 0;
|
| | | if (model.TryGetRealmAchievement(treasureSoulId, out achievementId))
|
| | | {
|
| | | if (achievementId == _id)
|
| | | {
|
| | | DisplayState();
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | public void Display(int _id)
|
| | | {
|
| | | treasureId = _id;
|
| | | treasureSoulId = _id;
|
| | | m_Redpoint.redpointId = 0;
|
| | | if (model.TryGetTreasure(_id, out treasure))
|
| | | if (model.TryGetTreasureSoul(_id, out special))
|
| | | {
|
| | | var _privilege = treasure.unLockPrivilege;
|
| | | var config = ConfigManager.Instance.GetTemplate<TreasurePrivilegeConfig>(_privilege);
|
| | | var config = ConfigManager.Instance.GetTemplate<TreasurePrivilegeConfig>(_id);
|
| | | if (config == null)
|
| | | {
|
| | | return;
|
| | | }
|
| | | m_Redpoint.redpointId = treasure.specialData.privilegeRedpoint != null ? treasure.specialData.privilegeRedpoint.id : 0;
|
| | | m_Redpoint.redpointId = special.redpoint.id;
|
| | | m_SoulName.text = config.Name;
|
| | | m_SelectImg.SetSprite(model.selectSoul == treasureId ? "ListBtn_Select" : "ListBtn_UnSelect");
|
| | | m_SelectImg.SetSprite(model.selectSoul == treasureSoulId ? "ListBtn_Select" : "ListBtn_UnSelect");
|
| | | DisplayState();
|
| | | }
|
| | | }
|
| | |
|
| | | void DisplayState()
|
| | | {
|
| | | if (treasure != null)
|
| | | if (special != null)
|
| | | {
|
| | | var stage = treasure.treasureStages[treasure.StageCount - 1];
|
| | | m_Lock.gameObject.SetActive(PlayerDatas.Instance.baseData.LV < stage.limitLevel);
|
| | | if (PlayerDatas.Instance.baseData.LV < stage.limitLevel)
|
| | | if (special.active)
|
| | | {
|
| | | m_SoulState.text = Language.Get("TreasurePrivilege_Unlock", stage.limitLevel);
|
| | | }
|
| | | else if (treasure.IsMaxStage())
|
| | | {
|
| | | m_Lock.gameObject.SetActive(false);
|
| | | m_SoulState.text = Language.Get("TreasureSoul_Awoke");
|
| | | }
|
| | | else
|
| | | {
|
| | | int achievementId = 0;
|
| | | bool unlock = true;
|
| | | if (model.TryGetRealmAchievement(treasureSoulId, out achievementId))
|
| | | {
|
| | | Achievement achievement;
|
| | | if (achievementModel.TryGetAchievement(achievementId, out achievement))
|
| | | {
|
| | | unlock = achievement.completed;
|
| | | }
|
| | | }
|
| | | m_Lock.gameObject.SetActive(!unlock);
|
| | | if (unlock)
|
| | | {
|
| | | m_SoulState.text = Language.Get("TreasureSoul_Awaking");
|
| | | }
|
| | | else
|
| | | {
|
| | | var successConfig = ConfigManager.Instance.GetTemplate<SuccessConfig>(achievementId);
|
| | | var realmConfig = ConfigManager.Instance.GetTemplate<RealmConfig>(successConfig.Condition[0]);
|
| | | m_SoulState.text = string.Format("境界<Img img={0}/>解锁", realmConfig.Img);
|
| | | }
|
| | | }
|
| | |
|
| | | private void PlayerDataRefreshInfoEvent(PlayerDataRefresh refreshType)
|
| | | {
|
| | | if (refreshType == PlayerDataRefresh.LV)
|
| | | {
|
| | | DisplayState();
|
| | | }
|
| | | }
|
| | |
|
| | | private void TreasureSelectSoulChangeEvent(int _id)
|
| | | {
|
| | | if (treasure != null)
|
| | | if (special != null)
|
| | | {
|
| | | m_SelectImg.SetSprite(model.selectSoul == treasureId ? "ListBtn_Select" : "ListBtn_UnSelect");
|
| | | m_SelectImg.SetSprite(model.selectSoul == treasureSoulId ? "ListBtn_Select" : "ListBtn_UnSelect");
|
| | | }
|
| | | }
|
| | |
|
| | | private void TreasureSoulEvent(int _id)
|
| | | {
|
| | | if (_id == treasureSoulId)
|
| | | {
|
| | | DisplayState();
|
| | | }
|
| | | }
|
| | |
|
| | | private void OnSelect()
|
| | | {
|
| | | if(model.TryGetTreasure(treasureId,out treasure))
|
| | | {
|
| | | model.selectSoul = treasureId;
|
| | | }
|
| | | model.selectSoul = treasureSoulId;
|
| | | }
|
| | | }
|
| | | } |