| | |
| | | /// </summary> |
| | | public class HorseSkinWin : UIBase |
| | | { |
| | | [SerializeField] Button bagBtn; |
| | | [SerializeField] Button seeAttrBtn; |
| | | [SerializeField] HorseController horseModel; |
| | | [SerializeField] Text horseName; |
| | | [SerializeField] Text getWayText; |
| | | [SerializeField] Text attrText; |
| | | [SerializeField] ScrollerController scroller; |
| | | [SerializeField] Transform changeOPObj; |
| | | [SerializeField] Button lvUpBtn; |
| | | [SerializeField] Text lvUpText; |
| | | [SerializeField] Text lvUpCostText; |
| | | [SerializeField] Image lvUpItemImg; |
| | | [SerializeField] Button changeSkinBtn; |
| | | [SerializeField] Text timeText; |
| | | [SerializeField] Transform inSkinMarkObj; //幻化中 |
| | | |
| | | [SerializeField] Button unlockBtn; |
| | | [SerializeField] Text unlockCostText; |
| | | [SerializeField] Image unlockItemImg; |
| | | |
| | | protected override void InitComponent() |
| | | { |
| | | |
| | | seeAttrBtn.AddListener(OnSeeAttrBtnClick); |
| | | lvUpBtn.AddListener(OnLvUpBtnClick); |
| | | changeSkinBtn.AddListener(OnChangeSkinBtnClick); |
| | | unlockBtn.AddListener(OnUnlockBtnClick); |
| | | } |
| | | |
| | | protected override void OnPreOpen() |
| | | { |
| | | HorseManager.Instance.selectSkinID = HorseManager.Instance.GetUsingHorseSkinID(); |
| | | HorseManager.Instance.SortHorseSkinList(); |
| | | HorseManager.Instance.OnSkinUpdateEvent += OnSkinUpdateEvent; |
| | | HorseManager.Instance.OnSelectEvent += OnSelectEvent; |
| | | scroller.OnRefreshCell += OnRefreshCell; |
| | | GlobalTimeEvent.Instance.secondEvent += OnSecondEvent; |
| | | PlayerDatas.Instance.playerDataRefreshEvent += OnRefreshPlayerData; |
| | | |
| | | CreateScroller(); |
| | | Display(); |
| | | } |
| | | |
| | | protected override void OnPreClose() |
| | | { |
| | | |
| | | HorseManager.Instance.lastClassLV = HorseManager.Instance.classLV; |
| | | HorseManager.Instance.UpdateSkinRedpoint(); |
| | | HorseManager.Instance.OnSkinUpdateEvent -= OnSkinUpdateEvent; |
| | | HorseManager.Instance.OnSelectEvent -= OnSelectEvent; |
| | | scroller.OnRefreshCell -= OnRefreshCell; |
| | | GlobalTimeEvent.Instance.secondEvent -= OnSecondEvent; |
| | | PlayerDatas.Instance.playerDataRefreshEvent -= OnRefreshPlayerData; |
| | | } |
| | | |
| | | void OnSkinUpdateEvent() |
| | | { |
| | | HorseManager.Instance.SortHorseSkinList(); |
| | | Display(); |
| | | } |
| | | |
| | | void OnRefreshPlayerData(PlayerDataType type) |
| | | { |
| | | if (type == PlayerDataType.EquipShowSwitch) |
| | | { |
| | | Display(); |
| | | } |
| | | } |
| | | void OnSelectEvent() |
| | | { |
| | | Display(); |
| | | } |
| | | |
| | | void Display() |
| | | { |
| | | var skinConfig = HorseSkinConfig.Get(HorseManager.Instance.selectSkinID); |
| | | horseModel.Create(HorseManager.Instance.selectSkinID, PhantasmPavilionManager.Instance.GetMyModelSkinID()); |
| | | if (string.IsNullOrEmpty(skinConfig.getWay)) |
| | | { |
| | | getWayText.text = ""; |
| | | } |
| | | else |
| | | { |
| | | getWayText.text = Language.Get("PhantasmPavilion06", skinConfig.getWay); |
| | | } |
| | | if (skinConfig.AttrIDList.Length == 0) |
| | | { |
| | | attrText.text = ""; |
| | | } |
| | | else |
| | | { |
| | | attrText.text = GetSkinAttrSring(skinConfig); |
| | | } |
| | | |
| | | scroller.m_Scorller.RefreshActiveCellViews(); |
| | | |
| | | bool isActive = HorseManager.Instance.IsSkinActive(HorseManager.Instance.selectSkinID); |
| | | var skinData = HorseManager.Instance.GetSkinData(HorseManager.Instance.selectSkinID); |
| | | if (skinConfig.StarMax > 0 && skinData.Star > 0) |
| | | { |
| | | horseName.text = skinConfig.Name + "+" + skinData.Star; |
| | | } |
| | | else |
| | | { |
| | | horseName.text = skinConfig.Name; |
| | | } |
| | | if (isActive) |
| | | { |
| | | changeOPObj.SetActive(true); |
| | | unlockBtn.SetActive(false); |
| | | if (skinConfig.StarMax > 0) |
| | | { |
| | | lvUpBtn.SetActive(true); |
| | | if (skinData.Star >= skinConfig.StarMax) |
| | | { |
| | | lvUpCostText.SetActive(false); |
| | | lvUpText.text = Language.Get("L1055"); |
| | | lvUpBtn.SetInteractable(false); |
| | | } |
| | | else |
| | | { |
| | | lvUpBtn.SetInteractable(true); |
| | | lvUpText.text = Language.Get("L1109"); |
| | | lvUpCostText.SetActive(true); |
| | | lvUpCostText.text = UIHelper.ShowUseItem(PackType.Item, skinConfig.UnlockValue, skinConfig.UpNeedCnt); |
| | | lvUpItemImg.SetItemSprite(skinConfig.UnlockValue); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | lvUpBtn.SetActive(false); |
| | | } |
| | | |
| | | if (HorseManager.Instance.selectSkinID == HorseManager.Instance.GetUsingHorseSkinID()) |
| | | { |
| | | changeSkinBtn.SetActive(false); |
| | | inSkinMarkObj.SetActive(true); |
| | | } |
| | | else |
| | | { |
| | | changeSkinBtn.SetActive(true); |
| | | inSkinMarkObj.SetActive(false); |
| | | } |
| | | |
| | | ShowTime(); |
| | | } |
| | | else |
| | | { |
| | | changeOPObj.SetActive(false); |
| | | if (skinConfig.UnlockWay == 1) |
| | | { |
| | | unlockBtn.SetActive(false); |
| | | } |
| | | else |
| | | { |
| | | unlockBtn.SetActive(true); |
| | | unlockCostText.SetActive(true); |
| | | unlockCostText.text = UIHelper.ShowUseItem(PackType.Item, skinConfig.UnlockValue, skinConfig.UnlockNeedCnt); |
| | | unlockItemImg.SetItemSprite(skinConfig.UnlockValue); |
| | | } |
| | | } |
| | | } |
| | | |
| | | void ShowTime() |
| | | { |
| | | bool isActive = HorseManager.Instance.IsSkinActive(HorseManager.Instance.selectSkinID); |
| | | var skinData = HorseManager.Instance.GetSkinData(HorseManager.Instance.selectSkinID); |
| | | var skinConfig = HorseSkinConfig.Get(HorseManager.Instance.selectSkinID); |
| | | if (isActive) |
| | | { |
| | | if (skinConfig.ExpireMinutes > 0) |
| | | { |
| | | timeText.SetActive(true); |
| | | timeText.text = Language.Get("PhantasmPavilion10", TimeUtility.SecondsToShortDHMS(skinData.EndTime - TimeUtility.AllSeconds)); |
| | | } |
| | | else |
| | | { |
| | | timeText.SetActive(false); |
| | | } |
| | | } |
| | | } |
| | | |
| | | void OnSecondEvent() |
| | | { |
| | | ShowTime(); |
| | | } |
| | | |
| | | |
| | | void CreateScroller() |
| | | { |
| | | scroller.Refresh(); |
| | | for (int i = 0; i < HorseManager.Instance.sortSkinList.Count; i++) |
| | | { |
| | | if (i % 3 == 0) |
| | | { |
| | | scroller.AddCell(ScrollerDataType.Header, i); |
| | | } |
| | | } |
| | | scroller.Restart(); |
| | | } |
| | | |
| | | void OnRefreshCell(ScrollerDataType type, CellView cell) |
| | | { |
| | | var _cell = cell as HorseSkinLineCell; |
| | | _cell.Display(cell.index); |
| | | } |
| | | |
| | | |
| | | void OnSeeAttrBtnClick() |
| | | { |
| | | AttributeManager.Instance.OpenTotalAttributeWin(HorseManager.Instance.skinAttrDic); |
| | | } |
| | | |
| | | |
| | | string GetSkinAttrSring(HorseSkinConfig config) |
| | | { |
| | | var dict = HorseManager.Instance.GetAttrBySkinID(config); |
| | | var attrList = new List<string>(); |
| | | var skinData = HorseManager.Instance.GetSkinData(config.SkinID); |
| | | if (skinData != null) |
| | | { |
| | | //升星 |
| | | if (skinData.Star == 0 || skinData.Star >= config.StarMax) |
| | | { |
| | | foreach (var kv in dict) |
| | | { |
| | | attrList.Add(UIHelper.AppendColor(TextColType.itemchuanqi, PlayerPropertyConfig.GetFullDescription(kv.Key, kv.Value))); |
| | | } |
| | | return Language.Get("PhantasmPavilion07") + string.Join(Language.Get("L1112"), attrList); |
| | | } |
| | | else |
| | | { |
| | | int i = 0; |
| | | foreach (var kv in dict) |
| | | { |
| | | attrList.Add(UIHelper.AppendColor(TextColType.itemchuanqi, PlayerPropertyConfig.GetFullDescription(kv.Key, kv.Value)) + |
| | | Language.Get("PhantasmPavilion12", UIHelper.AppendColor(TextColType.Green, "+" + PlayerPropertyConfig.GetValueDescription(kv.Key, config.AttrPerStarAddList[i])))); |
| | | i++; |
| | | } |
| | | return Language.Get("PhantasmPavilion07") + string.Join(Language.Get("L1112"), attrList); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | foreach (var kv in dict) |
| | | { |
| | | attrList.Add(UIHelper.AppendColor(TextColType.itemchuanqi, PlayerPropertyConfig.GetFullDescription(kv.Key, kv.Value))); |
| | | } |
| | | return Language.Get("PhantasmPavilion07") + string.Join(Language.Get("L1112"), attrList); |
| | | } |
| | | } |
| | | |
| | | void OnLvUpBtnClick() |
| | | { |
| | | var skinConfig = HorseSkinConfig.Get(HorseManager.Instance.selectSkinID); |
| | | if (ItemLogicUtility.CheckItemCount(PackType.Item, skinConfig.UnlockValue, skinConfig.UpNeedCnt, 2)) |
| | | { |
| | | HorseManager.Instance.SendSkinOP(3, HorseManager.Instance.selectSkinID); |
| | | } |
| | | } |
| | | void OnChangeSkinBtnClick() |
| | | { |
| | | HorseManager.Instance.SendSkinOP(2, HorseManager.Instance.selectSkinID); |
| | | } |
| | | |
| | | void OnUnlockBtnClick() |
| | | { |
| | | var skinConfig = HorseSkinConfig.Get(HorseManager.Instance.selectSkinID); |
| | | if (ItemLogicUtility.CheckItemCount(PackType.Item, skinConfig.UnlockValue, skinConfig.UnlockNeedCnt, 2)) |
| | | { |
| | | HorseManager.Instance.SendSkinOP(1, HorseManager.Instance.selectSkinID); |
| | | } |
| | | } |
| | | |
| | | } |