| | |
| | | //-------------------------------------------------------- |
| | | // [Author]: 第二世界 |
| | | // [ Date ]: Tuesday, January 02, 2018 |
| | | //-------------------------------------------------------- |
| | | using UnityEngine; |
| | | using System.Collections; |
| | | using UnityEngine.UI; |
| | | using System; |
| | | |
| | | namespace Snxxz.UI |
| | | { |
| | | |
| | | public class FindPreciousBossBriefInfoBehaviour : ScrollItem |
| | | { |
| | | |
| | | [SerializeField] protected float m_SelectedShifting = 6f; |
| | | [SerializeField] protected CanvasGroup m_CanvasGroup; |
| | | [SerializeField] protected AutoSelectCyclicScroll m_Scroll; |
| | | [SerializeField] protected Transform m_CenterSign; |
| | | [SerializeField] protected Button m_Select; |
| | | [SerializeField] protected RectTransform m_Content; |
| | | [SerializeField] protected Image m_BackGround; |
| | | [SerializeField] protected Transform m_Selected; |
| | | [SerializeField] protected ImageEx m_Portrait; |
| | | [SerializeField] protected TextEx m_BossName; |
| | | [SerializeField] protected TextEx m_BossLevel; |
| | | [SerializeField] protected TimerBehaviour m_CoolDown; |
| | | [SerializeField] protected Transform m_RefreshAtOnce; |
| | | [SerializeField] protected Material m_NormalMaterial; |
| | | [SerializeField] protected Material m_GrayMaterial; |
| | | [SerializeField] protected FontColorSizeConfig m_BossNameFontConfig; |
| | | [SerializeField] protected FontColorSizeConfig m_BossLevelFontConfig; |
| | | |
| | | protected int bossId = 0; |
| | | protected virtual int selectedBossId { |
| | | get; |
| | | set; |
| | | } |
| | | |
| | | InteractorableState m_InteractorableState; |
| | | protected virtual InteractorableState interactorableState { |
| | | get { return m_InteractorableState; } |
| | | set { m_InteractorableState = value; } |
| | | } |
| | | |
| | | protected virtual bool isRebornRightNow { |
| | | get { |
| | | FindPreciousModel.BossInfo bossInfo = null; |
| | | if (findPreciousModel.TryGetBossInfo(bossId, out bossInfo)) |
| | | { |
| | | return !findPreciousModel.IsBossAlive(bossId) && DateTime.Now > bossInfo.refreshTime; |
| | | } |
| | | else |
| | | { |
| | | return false; |
| | | } |
| | | } |
| | | } |
| | | |
| | | protected virtual bool isUnLocked { |
| | | get { return true; } |
| | | } |
| | | |
| | | protected FindPreciousModel findPreciousModel { get { return ModelCenter.Instance.GetModel<FindPreciousModel>(); } } |
| | | |
| | | public override void Display(object _data) |
| | | { |
| | | base.Display(_data); |
| | | bossId = (int)_data; |
| | | |
| | | findPreciousModel.bossSubscribeChangeEvent -= OnSubscribe; |
| | | findPreciousModel.bossSubscribeChangeEvent += OnSubscribe; |
| | | findPreciousModel.bossInfoUpdateEvent -= OnBossInfoUpdate; |
| | | findPreciousModel.bossInfoUpdateEvent += OnBossInfoUpdate; |
| | | } |
| | | |
| | | public override void Dispose() |
| | | { |
| | | base.Dispose(); |
| | | findPreciousModel.bossSubscribeChangeEvent -= OnSubscribe; |
| | | findPreciousModel.bossInfoUpdateEvent -= OnBossInfoUpdate; |
| | | } |
| | | |
| | | protected void DrawBossBaseInfo(string _icon, string _name, int _level) |
| | | { |
| | | m_Portrait.SetSprite(_icon); |
| | | m_Portrait.SetNativeSize(); |
| | | m_BossName.text = _name; |
| | | m_BossLevel.text = Language.Get("Z1024", _level); |
| | | } |
| | | |
| | | private void Awake() |
| | | { |
| | | m_Select.AddListener(SelectBoss); |
| | | } |
| | | |
| | | private void SelectBoss() |
| | | { |
| | | m_Scroll.TrySelectData(bossId); |
| | | } |
| | | |
| | | protected virtual void OnSubscribe(int _bossId) |
| | | { |
| | | if (bossId != _bossId) |
| | | { |
| | | return; |
| | | } |
| | | |
| | | } |
| | | |
| | | protected virtual void UpdateBossPortrait(InteractorableState _state) |
| | | { |
| | | var isGray = _state == InteractorableState.DieOrLockedSelected || _state == InteractorableState.DieOrLockedUnSelected; |
| | | m_BackGround.material = isGray ? m_GrayMaterial : m_NormalMaterial; |
| | | m_Portrait.material = isGray ? m_GrayMaterial : m_NormalMaterial; |
| | | } |
| | | |
| | | protected void UpdateBossRebornCoolDown(bool _isUnLocked) |
| | | { |
| | | if (_isUnLocked) |
| | | { |
| | | FindPreciousModel.BossInfo bossInfo; |
| | | if (findPreciousModel.TryGetBossInfo(bossId, out bossInfo) && !bossInfo.IsBossAlive()) |
| | | { |
| | | if (DateTime.Now > bossInfo.refreshTime) |
| | | { |
| | | m_CoolDown.gameObject.SetActive(false); |
| | | } |
| | | else |
| | | { |
| | | m_CoolDown.Begin(bossInfo.refreshTime, OnBossCoolDownCompleted); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | m_CoolDown.gameObject.SetActive(false); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | m_CoolDown.gameObject.SetActive(false); |
| | | } |
| | | } |
| | | |
| | | protected void UpdateBossNameLevelFont(InteractorableState _state) |
| | | { |
| | | var selected = _state == InteractorableState.DieOrLockedSelected || _state == InteractorableState.NormalSelected; |
| | | m_Content.anchoredPosition = selected ? new Vector2(m_SelectedShifting, 0) : Vector2.zero; |
| | | if (m_CanvasGroup != null) |
| | | { |
| | | m_CanvasGroup.alpha = selected ? 1 : 0.8f; |
| | | } |
| | | |
| | | m_Selected.gameObject.SetActive(selected); |
| | | m_BackGround.SetSprite(selected ? "DemonJarSelectFrame" : "DemonJarNormalFrame"); |
| | | |
| | | var fontPattern = string.Empty; |
| | | switch (_state) |
| | | { |
| | | case InteractorableState.NormalUnSelected: |
| | | fontPattern = "NormalUnSelected"; |
| | | break; |
| | | case InteractorableState.NormalSelected: |
| | | fontPattern = "NormalSelected"; |
| | | break; |
| | | case InteractorableState.DieOrLockedSelected: |
| | | fontPattern = "DieOrLockedSelected"; |
| | | break; |
| | | case InteractorableState.DieOrLockedUnSelected: |
| | | fontPattern = "DieOrLockedUnSelected"; |
| | | break; |
| | | } |
| | | |
| | | var nameFontColorSize = m_BossNameFontConfig.GetColorSize(fontPattern); |
| | | var levelFontColorSize = m_BossLevelFontConfig.GetColorSize(fontPattern); |
| | | m_BossName.color = nameFontColorSize.color; |
| | | m_BossName.fontSize = nameFontColorSize.fontSize; |
| | | m_BossLevel.color = levelFontColorSize.color; |
| | | m_BossLevel.fontSize = levelFontColorSize.fontSize; |
| | | } |
| | | |
| | | protected virtual void OnBossInfoUpdate(int _bossId) |
| | | { |
| | | if (bossId != _bossId) |
| | | { |
| | | return; |
| | | } |
| | | |
| | | UpdateBossRebornCoolDown(isUnLocked); |
| | | UpdateBossPortrait(interactorableState); |
| | | } |
| | | |
| | | protected virtual void OnBossCoolDownCompleted() |
| | | { |
| | | UpdateBossPortrait(interactorableState); |
| | | } |
| | | |
| | | protected virtual void LateUpdate() |
| | | { |
| | | if (m_Scroll.autoSelectable && selectedBossId != bossId && bossId > 0) |
| | | { |
| | | if (Mathf.Abs(m_CenterSign.position.y - rectTransform.position.y) * 100f < rectTransform.rect.height * 0.45f) |
| | | { |
| | | selectedBossId = bossId; |
| | | } |
| | | } |
| | | |
| | | if (isRebornRightNow && !m_RefreshAtOnce.gameObject.activeInHierarchy) |
| | | { |
| | | m_RefreshAtOnce.gameObject.SetActive(true); |
| | | } |
| | | else if (!isRebornRightNow && m_RefreshAtOnce.gameObject.activeInHierarchy) |
| | | { |
| | | m_RefreshAtOnce.gameObject.SetActive(false); |
| | | } |
| | | } |
| | | |
| | | public enum InteractorableState |
| | | { |
| | | NormalSelected, |
| | | NormalUnSelected, |
| | | DieOrLockedSelected, |
| | | DieOrLockedUnSelected, |
| | | } |
| | | |
| | | } |
| | | |
| | | } |
| | | |
| | | |
| | | |
| | | //--------------------------------------------------------
|
| | | // [Author]: 第二世界
|
| | | // [ Date ]: Tuesday, January 02, 2018
|
| | | //--------------------------------------------------------
|
| | | using UnityEngine;
|
| | | using System.Collections;
|
| | | using UnityEngine.UI;
|
| | | using System;
|
| | | using TableConfig;
|
| | |
|
| | | namespace Snxxz.UI
|
| | | {
|
| | |
|
| | | public class FindPreciousBossBriefInfoBehaviour : ScrollItem
|
| | | {
|
| | |
|
| | | [SerializeField] protected float m_SelectedShifting = 6f;
|
| | | [SerializeField] protected CanvasGroup m_CanvasGroup;
|
| | | [SerializeField] protected AutoSelectCyclicScroll m_Scroll;
|
| | | [SerializeField] protected Transform m_CenterSign;
|
| | | [SerializeField] protected Button m_Select;
|
| | | [SerializeField] protected RectTransform m_Content;
|
| | | [SerializeField] protected Image m_BackGround;
|
| | | [SerializeField] protected Transform m_Selected;
|
| | | [SerializeField] protected ImageEx m_Portrait;
|
| | | [SerializeField] protected TextEx m_BossName;
|
| | | [SerializeField] protected TextEx m_BossLevel;
|
| | | [SerializeField] protected Image m_Realm;
|
| | | [SerializeField] protected TimerBehaviour m_CoolDown;
|
| | | [SerializeField] protected Transform m_RefreshAtOnce;
|
| | | [SerializeField] protected Material m_NormalMaterial;
|
| | | [SerializeField] protected Material m_GrayMaterial;
|
| | | [SerializeField] protected FontColorSizeConfig m_BossNameFontConfig;
|
| | | [SerializeField] protected FontColorSizeConfig m_BossLevelFontConfig;
|
| | |
|
| | | protected int bossId = 0;
|
| | | protected virtual int selectedBossId {
|
| | | get;
|
| | | set;
|
| | | }
|
| | |
|
| | | InteractorableState m_InteractorableState;
|
| | | protected virtual InteractorableState interactorableState {
|
| | | get { return m_InteractorableState; }
|
| | | set { m_InteractorableState = value; }
|
| | | }
|
| | |
|
| | | protected virtual bool isRebornRightNow {
|
| | | get {
|
| | | FindPreciousModel.BossInfo bossInfo = null;
|
| | | if (findPreciousModel.TryGetBossInfo(bossId, out bossInfo))
|
| | | {
|
| | | return !findPreciousModel.IsBossAlive(bossId) && DateTime.Now > bossInfo.refreshTime;
|
| | | }
|
| | | else
|
| | | {
|
| | | return false;
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | protected virtual bool isUnLocked {
|
| | | get { return true; }
|
| | | }
|
| | |
|
| | | protected FindPreciousModel findPreciousModel { get { return ModelCenter.Instance.GetModel<FindPreciousModel>(); } }
|
| | |
|
| | | public override void Display(object _data)
|
| | | {
|
| | | base.Display(_data);
|
| | | bossId = (int)_data;
|
| | |
|
| | | findPreciousModel.bossSubscribeChangeEvent -= OnSubscribe;
|
| | | findPreciousModel.bossSubscribeChangeEvent += OnSubscribe;
|
| | | findPreciousModel.bossInfoUpdateEvent -= OnBossInfoUpdate;
|
| | | findPreciousModel.bossInfoUpdateEvent += OnBossInfoUpdate;
|
| | | }
|
| | |
|
| | | public override void Dispose()
|
| | | {
|
| | | base.Dispose();
|
| | | findPreciousModel.bossSubscribeChangeEvent -= OnSubscribe;
|
| | | findPreciousModel.bossInfoUpdateEvent -= OnBossInfoUpdate;
|
| | | }
|
| | |
|
| | | protected virtual void DrawBossBaseInfo(string _icon, string _name, int _level, int _realm)
|
| | | {
|
| | | m_Portrait.SetSprite(_icon);
|
| | | m_Portrait.SetNativeSize();
|
| | | m_BossName.text = _name;
|
| | | m_BossLevel.text = Language.Get("Z1024", _level);
|
| | |
|
| | | if (m_Realm != null)
|
| | | {
|
| | | if (Config.Instance.ContainKey<RealmConfig>(_realm))
|
| | | {
|
| | | m_Realm.gameObject.SetActive(true);
|
| | | var realmConfig = Config.Instance.Get<RealmConfig>(_realm);
|
| | | if (realmConfig != null)
|
| | | {
|
| | | m_Realm.SetSprite(realmConfig.Img);
|
| | | }
|
| | | }
|
| | | else
|
| | | {
|
| | | m_Realm.gameObject.SetActive(false);
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | private void Awake()
|
| | | {
|
| | | m_Select.AddListener(SelectBoss);
|
| | | }
|
| | |
|
| | | private void SelectBoss()
|
| | | {
|
| | | m_Scroll.TrySelectData(bossId);
|
| | | }
|
| | |
|
| | | protected virtual void OnSubscribe(int _bossId)
|
| | | {
|
| | | if (bossId != _bossId)
|
| | | {
|
| | | return;
|
| | | }
|
| | |
|
| | | }
|
| | |
|
| | | protected virtual void UpdateBossPortrait(InteractorableState _state)
|
| | | {
|
| | | var isGray = _state == InteractorableState.DieOrLockedSelected || _state == InteractorableState.DieOrLockedUnSelected;
|
| | | m_BackGround.material = isGray ? m_GrayMaterial : m_NormalMaterial;
|
| | | m_Portrait.material = isGray ? m_GrayMaterial : m_NormalMaterial;
|
| | | }
|
| | |
|
| | | protected virtual void UpdateBossRebornCoolDown(bool _isUnLocked)
|
| | | {
|
| | | if (_isUnLocked)
|
| | | {
|
| | | FindPreciousModel.BossInfo bossInfo;
|
| | | if (findPreciousModel.TryGetBossInfo(bossId, out bossInfo) && !bossInfo.IsBossAlive())
|
| | | {
|
| | | if (DateTime.Now > bossInfo.refreshTime)
|
| | | {
|
| | | m_CoolDown.gameObject.SetActive(false);
|
| | | }
|
| | | else
|
| | | {
|
| | | m_CoolDown.Begin(bossInfo.refreshTime, OnBossCoolDownCompleted);
|
| | | }
|
| | | }
|
| | | else
|
| | | {
|
| | | m_CoolDown.gameObject.SetActive(false);
|
| | | }
|
| | | }
|
| | | else
|
| | | {
|
| | | m_CoolDown.gameObject.SetActive(false);
|
| | | }
|
| | | }
|
| | |
|
| | | protected void UpdateBossNameLevelFont(InteractorableState _state)
|
| | | {
|
| | | var selected = _state == InteractorableState.DieOrLockedSelected || _state == InteractorableState.NormalSelected;
|
| | | m_Content.anchoredPosition = selected ? new Vector2(m_SelectedShifting, 0) : Vector2.zero;
|
| | | if (m_CanvasGroup != null)
|
| | | {
|
| | | m_CanvasGroup.alpha = selected ? 1 : 0.8f;
|
| | | }
|
| | |
|
| | | m_Selected.gameObject.SetActive(selected);
|
| | | //m_BackGround.SetSprite(selected ? "DemonJarSelectFrame" : "DemonJarNormalFrame");
|
| | |
|
| | | var fontPattern = string.Empty;
|
| | | switch (_state)
|
| | | {
|
| | | case InteractorableState.NormalUnSelected:
|
| | | fontPattern = "NormalUnSelected";
|
| | | break;
|
| | | case InteractorableState.NormalSelected:
|
| | | fontPattern = "NormalSelected";
|
| | | break;
|
| | | case InteractorableState.DieOrLockedSelected:
|
| | | fontPattern = "DieOrLockedSelected";
|
| | | break;
|
| | | case InteractorableState.DieOrLockedUnSelected:
|
| | | fontPattern = "DieOrLockedUnSelected";
|
| | | break;
|
| | | }
|
| | |
|
| | | var nameFontColorSize = m_BossNameFontConfig.GetColorSize(fontPattern);
|
| | | var levelFontColorSize = m_BossLevelFontConfig.GetColorSize(fontPattern);
|
| | | m_BossName.color = nameFontColorSize.color;
|
| | | m_BossName.fontSize = nameFontColorSize.fontSize;
|
| | | m_BossLevel.color = levelFontColorSize.color;
|
| | | m_BossLevel.fontSize = levelFontColorSize.fontSize;
|
| | | }
|
| | |
|
| | | protected virtual void OnBossInfoUpdate(int _bossId)
|
| | | {
|
| | | if (bossId != _bossId)
|
| | | {
|
| | | return;
|
| | | }
|
| | |
|
| | | UpdateBossRebornCoolDown(isUnLocked);
|
| | | UpdateBossPortrait(interactorableState);
|
| | | }
|
| | |
|
| | | protected virtual void OnBossCoolDownCompleted()
|
| | | {
|
| | | UpdateBossPortrait(interactorableState);
|
| | | }
|
| | |
|
| | | protected virtual void LateUpdate()
|
| | | {
|
| | | if (m_Scroll.autoSelectable && selectedBossId != bossId && bossId > 0)
|
| | | {
|
| | | if (Mathf.Abs(m_CenterSign.position.y - rectTransform.position.y) * 100f < rectTransform.rect.height * 0.45f)
|
| | | {
|
| | | selectedBossId = bossId;
|
| | | }
|
| | | }
|
| | |
|
| | | if (m_RefreshAtOnce != null)
|
| | | {
|
| | | if (isRebornRightNow && !m_RefreshAtOnce.gameObject.activeInHierarchy)
|
| | | {
|
| | | m_RefreshAtOnce.gameObject.SetActive(true);
|
| | | }
|
| | | else if (!isRebornRightNow && m_RefreshAtOnce.gameObject.activeInHierarchy)
|
| | | {
|
| | | m_RefreshAtOnce.gameObject.SetActive(false);
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | public enum InteractorableState
|
| | | {
|
| | | NormalSelected,
|
| | | NormalUnSelected,
|
| | | DieOrLockedSelected,
|
| | | DieOrLockedUnSelected,
|
| | | }
|
| | |
|
| | | }
|
| | |
|
| | | }
|
| | |
|
| | |
|
| | |
|