| | |
| | | using UnityEngine.UI; |
| | | using UnityEngine; |
| | | using TableConfig; |
| | | using System; |
| | | using System.Collections.Generic; |
| | | using DG.Tweening; |
| | | using Snxxz.UI; |
| | | using System.Collections; |
| | | using System.Linq; |
| | | |
| | | namespace Snxxz.UI |
| | | { |
| | | public class GetEquipPathTips : MonoBehaviour |
| | | { |
| | | #region 成员变量 |
| | | [SerializeField] |
| | | protected ItemCell _itemCell; |
| | | |
| | | [SerializeField] |
| | | protected Text _nameText; |
| | | |
| | | [SerializeField] |
| | | Text equipScoreDes; |
| | | [SerializeField] |
| | | Text equipScoreValue; |
| | | [SerializeField] |
| | | Text needLvDes; |
| | | [SerializeField] |
| | | Text needLvValue; |
| | | [SerializeField] |
| | | List<Text> needPointTextlist = new List<Text>(); |
| | | [SerializeField] |
| | | List<Text> needPointNumlist = new List<Text>(); |
| | | |
| | | [SerializeField] |
| | | protected Button _closeBtn; |
| | | |
| | | [SerializeField] |
| | | protected GameObject _bottomPart; |
| | | |
| | | [SerializeField] |
| | | private Button _getItemBtn; |
| | | |
| | | [SerializeField] |
| | | protected RectTransform _itemInfoTips; |
| | | |
| | | [SerializeField] RectTransform getWaysTips; |
| | | |
| | | [SerializeField] |
| | | protected CanvasGroup _getWaysTipsAlpha; |
| | | |
| | | [SerializeField] |
| | | private ScrollerController _waysCtrl; |
| | | |
| | | [SerializeField] |
| | | private Transform waysLineCell; |
| | | |
| | | [SerializeField] |
| | | private Button _closeWaysBtn; |
| | | |
| | | [SerializeField] |
| | | [Header("移动时间")] |
| | | protected float _moveTime = 0.3f; |
| | | |
| | | [SerializeField] |
| | | protected CanvasGroup tipAlpha; |
| | | |
| | | [SerializeField] GameObject equipTipsObj; |
| | | |
| | | #region MidUI |
| | | [Header("装备属性部分")] |
| | | [SerializeField] |
| | | RectTransform attrContent; |
| | | [SerializeField] |
| | | ScrollRect scrollRect; |
| | | [SerializeField] |
| | | LayoutElement scrollLayout; |
| | | |
| | | [SerializeField] |
| | | GameObject basicAttr; |
| | | [SerializeField] |
| | | Text basicTitleText; |
| | | [SerializeField] |
| | | Text basicAttrDes; |
| | | |
| | | [SerializeField] |
| | | GameObject exhaustedAttr; |
| | | [SerializeField] |
| | | Text exhaustedTitleText; |
| | | [SerializeField] |
| | | Text exhaustedAttrDes; |
| | | |
| | | [SerializeField] |
| | | GameObject legendAttr; |
| | | [SerializeField] |
| | | Text legendTitleText; |
| | | [SerializeField] |
| | | Text legendCntPreview; |
| | | [SerializeField] |
| | | Text legendAttrDes; |
| | | |
| | | [SerializeField] |
| | | GameObject gemAttr; |
| | | [SerializeField] |
| | | Text gemTitleText; |
| | | [SerializeField] |
| | | List<GemElementObj> gemObjlist = new List<GemElementObj>(); |
| | | |
| | | [SerializeField] List<GameObject> attrCutLinelist = new List<GameObject>(); |
| | | #endregion |
| | | |
| | | #endregion |
| | | |
| | | DailyQuestModel _questModel; |
| | | protected DailyQuestModel QuestModel |
| | | { |
| | | get { return _questModel ?? (_questModel = ModelCenter.Instance.GetModel<DailyQuestModel>()); } |
| | | } |
| | | |
| | | ItemTipsModel _itemTipsModel; |
| | | ItemTipsModel itemTipsModel |
| | | { |
| | | get |
| | | { |
| | | return _itemTipsModel ?? (_itemTipsModel = ModelCenter.Instance.GetModel<ItemTipsModel>()); |
| | | } |
| | | } |
| | | |
| | | PackModelInterface _modelInterface; |
| | | PackModelInterface modelInterface |
| | | { |
| | | get { return _modelInterface ?? (_modelInterface = ModelCenter.Instance.GetModel<PackModelInterface>()); } |
| | | } |
| | | |
| | | Dictionary<AttrEnum, int> needPointDict = new Dictionary<AttrEnum, int>(); |
| | | |
| | | Color32 conditionColor = new Color32(255, 244, 205, 255); |
| | | Color32 conditionRedColor = new Color32(255, 1, 1, 255); |
| | | ItemAttrData itemAttrData; |
| | | private int curAttrTypeNum = 0; |
| | | public void InitModel(ItemAttrData attrData) |
| | | { |
| | | curAttrTypeNum = 0; |
| | | itemAttrData = attrData; |
| | | _waysCtrl.OnRefreshCell += RefreshWayCell; |
| | | _closeBtn.onClick.AddListener(CloseWin); |
| | | _getItemBtn.onClick.AddListener(OnClickGetItemBtn); |
| | | _closeWaysBtn.onClick.AddListener(CloseWin); |
| | | _bottomPart.gameObject.SetActive(false); |
| | | InitUI(); |
| | | } |
| | | private void OnEnable() |
| | | { |
| | | transform.SetAsLastSibling(); |
| | | StartCoroutine(SetScrollSize()); |
| | | } |
| | | |
| | | private void OnDisable() |
| | | { |
| | | _waysCtrl.OnRefreshCell -= RefreshWayCell; |
| | | _closeBtn.RemoveAllListeners(); |
| | | _getItemBtn.RemoveAllListeners(); |
| | | _closeWaysBtn.RemoveAllListeners(); |
| | | } |
| | | |
| | | #region iteminfoTips逻辑 |
| | | |
| | | protected virtual IEnumerator SetScrollSize() |
| | | { |
| | | yield return null; |
| | | yield return null; |
| | | attrContent.anchoredPosition3D = new Vector3(attrContent.anchoredPosition3D.x, 0, 0); |
| | | SetMidUIHeight(attrContent.rect.height); |
| | | StartCoroutine(ShowBottomPart()); |
| | | } |
| | | |
| | | IEnumerator ShowBottomPart() |
| | | { |
| | | yield return null; |
| | | _bottomPart.SetActive(true); |
| | | StartCoroutine(SetPanelScale()); |
| | | } |
| | | |
| | | IEnumerator SetPanelScale() |
| | | { |
| | | yield return null; |
| | | itemTipsModel.SetCurTips(this.GetComponent<RectTransform>()); |
| | | SetGetWaysPos(); |
| | | //_itemInfoTips.localPosition = Vector3.zero; |
| | | tipAlpha.alpha = 1; |
| | | } |
| | | |
| | | #region 设置坐标 |
| | | public void SetGetWaysPos() |
| | | { |
| | | if(itemTipsModel.compareAttrData != null) |
| | | { |
| | | getWaysTips.anchoredPosition3D = Vector3.zero; |
| | | } |
| | | else |
| | | { |
| | | getWaysTips.anchoredPosition3D = new Vector3(this.GetComponent<RectTransform>().sizeDelta.x / 2, 0, 0); |
| | | } |
| | | } |
| | | #endregion |
| | | |
| | | private void InitUI() |
| | | { |
| | | if (itemAttrData == null) |
| | | return; |
| | | |
| | | _closeBtn.gameObject.SetActive(true); |
| | | _getWaysTipsAlpha.alpha = 0; |
| | | tipAlpha.alpha = 0; |
| | | SetTopUI(); |
| | | SetMidUI(); |
| | | } |
| | | |
| | | private void SetTopUI() |
| | | { |
| | | |
| | | ItemCellModel cellModel = new ItemCellModel(itemAttrData.itemId,false,0,itemAttrData.isBind); |
| | | _itemCell.Init(cellModel); |
| | | _nameText.text = itemAttrData.itemConfig.ItemName; |
| | | _nameText.color = UIHelper.GetUIColor(itemAttrData.itemConfig.ItemColor); |
| | | equipScoreDes.text = Language.Get("EquipWin_EquipPointText_1"); |
| | | equipScoreValue.text = itemAttrData.score.ToString(); |
| | | RefreshNeedPointUI(); |
| | | needLvDes.text = Language.Get("KnapS110"); |
| | | if (itemAttrData.itemConfig.UseLV > 1) |
| | | { |
| | | needLvDes.gameObject.SetActive(true); |
| | | needLvValue.gameObject.SetActive(true); |
| | | } |
| | | else |
| | | { |
| | | needLvDes.gameObject.SetActive(false); |
| | | needLvValue.gameObject.SetActive(false); |
| | | } |
| | | |
| | | if (itemAttrData.isHavePutLimit) |
| | | { |
| | | needLvValue.text = itemAttrData.itemConfig.UseLV.ToString(); |
| | | if (PlayerDatas.Instance.baseData.LV >= itemAttrData.itemConfig.UseLV) |
| | | { |
| | | needLvDes.color = conditionColor; |
| | | needLvValue.color = conditionColor; |
| | | } |
| | | else |
| | | { |
| | | needLvDes.color = UIHelper.GetUIColor(TextColType.Red); |
| | | needLvValue.color = UIHelper.GetUIColor(TextColType.Red); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | needLvValue.text = 1.ToString(); |
| | | needLvDes.color = conditionColor; |
| | | needLvValue.color = conditionColor; |
| | | } |
| | | } |
| | | |
| | | private void RefreshNeedPointUI() |
| | | { |
| | | needPointDict.Clear(); |
| | | if (itemAttrData.itemConfig.LimitSTR > 0) |
| | | { |
| | | needPointDict.Add(AttrEnum.POWER, itemAttrData.itemConfig.LimitSTR); |
| | | } |
| | | |
| | | if (itemAttrData.itemConfig.LimitPHY > 0) |
| | | { |
| | | needPointDict.Add(AttrEnum.AGILITY, itemAttrData.itemConfig.LimitPHY); |
| | | } |
| | | |
| | | if (itemAttrData.itemConfig.LimitPNE > 0) |
| | | { |
| | | needPointDict.Add(AttrEnum.MENTALITY, itemAttrData.itemConfig.LimitPNE); |
| | | } |
| | | |
| | | List<AttrEnum> needlist = needPointDict.Keys.ToList(); |
| | | |
| | | int i = 0; |
| | | for (i = 0; i < needPointTextlist.Count; i++) |
| | | { |
| | | if (i < needlist.Count) |
| | | { |
| | | needPointTextlist[i].gameObject.SetActive(true); |
| | | needPointNumlist[i].gameObject.SetActive(true); |
| | | switch (needlist[i]) |
| | | { |
| | | case AttrEnum.POWER: |
| | | if (itemAttrData.isHavePutLimit) |
| | | { |
| | | SetNeedPointUI(needPointDict[needlist[i]],needPointTextlist[i], needPointNumlist[i], Language.Get("KnapS113")); |
| | | } |
| | | else |
| | | { |
| | | SetNeedPointUI(1,needPointTextlist[i], needPointNumlist[i], Language.Get("KnapS113")); |
| | | } |
| | | break; |
| | | case AttrEnum.AGILITY: |
| | | if (itemAttrData.isHavePutLimit) |
| | | { |
| | | SetNeedPointUI(needPointDict[needlist[i]],needPointTextlist[i], needPointNumlist[i], Language.Get("KnapS112")); |
| | | } |
| | | else |
| | | { |
| | | SetNeedPointUI(1,needPointTextlist[i], needPointNumlist[i], Language.Get("KnapS112")); |
| | | } |
| | | |
| | | break; |
| | | case AttrEnum.MENTALITY: |
| | | if (itemAttrData.isHavePutLimit) |
| | | { |
| | | SetNeedPointUI(needPointDict[needlist[i]],needPointTextlist[i], needPointNumlist[i], Language.Get("KnapS111")); |
| | | } |
| | | else |
| | | { |
| | | SetNeedPointUI(1,needPointTextlist[i], needPointNumlist[i], Language.Get("KnapS111")); |
| | | } |
| | | break; |
| | | } |
| | | |
| | | } |
| | | else |
| | | { |
| | | needPointTextlist[i].gameObject.SetActive(false); |
| | | needPointNumlist[i].gameObject.SetActive(false); |
| | | } |
| | | } |
| | | |
| | | } |
| | | |
| | | |
| | | private void SetNeedPointUI(float needPoint,Text needPoinText, Text needPoinNum, string msg) |
| | | { |
| | | needPoinNum.color = conditionColor; |
| | | needPoinText.color = conditionColor; |
| | | needPoinNum.text = needPoint.ToString(); |
| | | needPoinText.text = msg; |
| | | } |
| | | |
| | | private void SetMidUI() |
| | | { |
| | | SetBasicAttrUI(); |
| | | SetExhaustedAttrUI(); |
| | | SetLegendAttrUI(); |
| | | SetGemAttrUI(); |
| | | for (int i = 0; i < curAttrTypeNum; i++) |
| | | { |
| | | if (i == curAttrTypeNum - 1) |
| | | { |
| | | attrCutLinelist[curAttrTypeNum - 1].SetActive(false); |
| | | } |
| | | else |
| | | { |
| | | attrCutLinelist[i].SetActive(true); |
| | | } |
| | | } |
| | | } |
| | | |
| | | #region 设置属性UI |
| | | private void SetBasicAttrUI() |
| | | { |
| | | curAttrTypeNum += 1; |
| | | basicAttr.SetActive(true); |
| | | basicTitleText.text = Language.Get("RolePanel_BaseAttrText_1"); |
| | | basicAttrDes.text = itemTipsModel.GetBasicAttr(itemAttrData); |
| | | } |
| | | |
| | | private void SetExhaustedAttrUI() |
| | | { |
| | | if (itemAttrData.exhaustedMaxDataDict == null) |
| | | { |
| | | exhaustedAttr.SetActive(false); |
| | | return; |
| | | } |
| | | curAttrTypeNum += 1; |
| | | exhaustedAttr.SetActive(true); |
| | | exhaustedTitleText.text = Language.Get("EquipWin_ExtinctPropObj_Text_1"); |
| | | exhaustedAttrDes.text = itemTipsModel.GetExhaustedAtrr(itemAttrData); |
| | | } |
| | | |
| | | private void SetLegendAttrUI() |
| | | { |
| | | if (itemAttrData.legendDataDict == null) |
| | | { |
| | | legendAttr.SetActive(false); |
| | | return; |
| | | } |
| | | curAttrTypeNum += 1; |
| | | legendAttr.SetActive(true); |
| | | legendTitleText.text = Language.Get("EquipWin_LegendPropObj_Text_1"); |
| | | legendAttrDes.text = itemTipsModel.GetLegendAttr(itemAttrData); |
| | | |
| | | if (itemAttrData.isPreview) |
| | | { |
| | | legendCntPreview.gameObject.SetActive(true); |
| | | legendCntPreview.text = itemTipsModel.GetEquipLegendAttrCntPreview(itemAttrData); |
| | | } |
| | | else |
| | | { |
| | | legendCntPreview.gameObject.SetActive(false); |
| | | } |
| | | } |
| | | |
| | | |
| | | private void SetGemAttrUI() |
| | | { |
| | | if (itemAttrData.itemConfig.LV < itemTipsModel.gemOpenLvs[0]) |
| | | { |
| | | gemAttr.SetActive(false); |
| | | return; |
| | | } |
| | | curAttrTypeNum += 1; |
| | | gemAttr.SetActive(true); |
| | | gemTitleText.text = Language.Get("EquipWin_GemPropObj_Text_1"); |
| | | int cnt = 0; |
| | | int vipCnt = 0; |
| | | if (itemAttrData.itemConfig.LV >= itemTipsModel.gemOpenLvs[0]) |
| | | { |
| | | cnt++; |
| | | } |
| | | |
| | | if (itemAttrData.itemConfig.LV >= itemTipsModel.gemOpenLvs[1]) |
| | | { |
| | | cnt++; |
| | | } |
| | | |
| | | if (itemAttrData.itemConfig.LV >= itemTipsModel.gemOpenLvs[2]) |
| | | { |
| | | cnt++; |
| | | } |
| | | |
| | | if (PlayerDatas.Instance.baseData.VIPLv >= itemTipsModel.gemOpenVipLv) |
| | | { |
| | | vipCnt++; |
| | | } |
| | | |
| | | int i = 0; |
| | | for (i = 0; i < gemObjlist.Count; i++) |
| | | { |
| | | int stoneId = 0; |
| | | if (itemAttrData.stones != null) |
| | | { |
| | | if (i < itemAttrData.stones.Length) |
| | | { |
| | | stoneId = (int)itemAttrData.stones[i]; |
| | | } |
| | | } |
| | | |
| | | if (i < gemObjlist.Count - 1) |
| | | { |
| | | if (i < cnt) |
| | | { |
| | | |
| | | gemObjlist[i].gameObject.SetActive(true); |
| | | gemObjlist[i].InitModel(stoneId, i, itemAttrData.itemConfig.EquipPlace, false); |
| | | } |
| | | else |
| | | { |
| | | gemObjlist[i].InitModel(stoneId, i, itemAttrData.itemConfig.EquipPlace, true); |
| | | gemObjlist[i].gameObject.SetActive(false); |
| | | } |
| | | |
| | | } |
| | | else |
| | | { |
| | | if (vipCnt != 0) |
| | | { |
| | | gemObjlist[i].InitModel(stoneId, i, itemAttrData.itemConfig.EquipPlace, false); |
| | | } |
| | | else |
| | | { |
| | | gemObjlist[i].InitModel(stoneId, i, itemAttrData.itemConfig.EquipPlace, true); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | |
| | | private void SetMidUIHeight(float midHeight) |
| | | { |
| | | scrollRect.enabled = false; |
| | | |
| | | if (midHeight < itemTipsModel.equipMidHeights[0]) |
| | | { |
| | | scrollLayout.preferredHeight = itemTipsModel.equipMidHeights[0]; |
| | | } |
| | | else if (midHeight > itemTipsModel.equipMidHeights[1]) |
| | | { |
| | | scrollRect.enabled = true; |
| | | scrollLayout.preferredHeight = itemTipsModel.equipMidHeights[1]; |
| | | } |
| | | else |
| | | { |
| | | scrollLayout.preferredHeight = midHeight; |
| | | } |
| | | } |
| | | #endregion |
| | | |
| | | #region 点击事件 |
| | | private void OnClickGetItemBtn() |
| | | { |
| | | if (_getWaysTipsAlpha.alpha <= 0) |
| | | { |
| | | Vector3 pos = Vector3.zero; |
| | | if(itemTipsModel.compareAttrData != null) |
| | | { |
| | | equipTipsObj.SetActive(false); |
| | | pos = new Vector3(0,0, 0); |
| | | } |
| | | else |
| | | { |
| | | pos = new Vector3(this.GetComponent<RectTransform>().sizeDelta.x, 0, 0); |
| | | } |
| | | _itemInfoTips.DOAnchorPos3D(pos, _moveTime); |
| | | _getWaysTipsAlpha.DOFade(1, _moveTime); |
| | | _closeBtn.gameObject.SetActive(false); |
| | | |
| | | CreateWayCell(); |
| | | } |
| | | else |
| | | { |
| | | _itemInfoTips.DOAnchorPos3D(new Vector3(this.GetComponent<RectTransform>().sizeDelta.x, 0, 0), _moveTime); |
| | | _getWaysTipsAlpha.DOFade(0, _moveTime); |
| | | _closeBtn.gameObject.SetActive(true); |
| | | if (itemTipsModel.compareAttrData != null) |
| | | { |
| | | equipTipsObj.SetActive(true); |
| | | } |
| | | } |
| | | |
| | | } |
| | | |
| | | private void CloseWin() |
| | | { |
| | | KnapSackEventMgr.Instance.HideItemPopWin(); |
| | | } |
| | | #endregion |
| | | |
| | | #endregion |
| | | |
| | | #region getWaysTips逻辑 |
| | | private List<GetItemWaysConfig> getWayslist; |
| | | protected virtual void CreateWayCell() |
| | | { |
| | | getWayslist = itemTipsModel.GetWaysList(itemAttrData); |
| | | _waysCtrl.Refresh(); |
| | | int i = 0; |
| | | int remain = getWayslist.Count % waysLineCell.childCount; |
| | | int line = (int)getWayslist.Count / waysLineCell.childCount; |
| | | if (remain > 0) |
| | | { |
| | | line += 1; |
| | | } |
| | | |
| | | for (i = 0; i < line; i++) |
| | | { |
| | | _waysCtrl.AddCell(ScrollerDataType.Header,i); |
| | | } |
| | | _waysCtrl.Restart(); |
| | | } |
| | | |
| | | private void RefreshWayCell(ScrollerDataType type, CellView cell) |
| | | { |
| | | int i = 0; |
| | | for(i = 0; i < cell.transform.childCount; i++) |
| | | { |
| | | WayCell wayCell = cell.transform.GetChild(i).GetComponent<WayCell>(); |
| | | if (wayCell == null) |
| | | wayCell = cell.transform.GetChild(i).gameObject.AddComponent<WayCell>(); |
| | | |
| | | int index = (cell.transform.childCount) * cell.index + i; |
| | | if(index <= getWayslist.Count - 1) |
| | | { |
| | | cell.transform.GetChild(i).gameObject.SetActive(true); |
| | | GetItemWaysConfig itemWaysModel = getWayslist[index]; |
| | | wayCell.icon.SetSprite(itemWaysModel.Icon); |
| | | wayCell.wayName.text = itemWaysModel.Text; |
| | | wayCell.funcName.text = itemWaysModel.name; |
| | | wayCell.wayButton.RemoveAllListeners(); |
| | | wayCell.wayButton.AddListener(()=> { |
| | | ClickWayCell(itemWaysModel); |
| | | }); |
| | | } |
| | | else |
| | | { |
| | | cell.transform.GetChild(i).gameObject.SetActive(false); |
| | | } |
| | | } |
| | | } |
| | | |
| | | public void ClickWayCell(GetItemWaysConfig itemWaysModel) |
| | | { |
| | | if(!string.IsNullOrEmpty(itemWaysModel.SelectActive) && itemWaysModel.SelectActive != "") |
| | | { |
| | | QuestModel.currentDailyQuest = int.Parse(itemWaysModel.SelectActive); |
| | | } |
| | | CloseWin(); |
| | | WindowJumpMgr.Instance.WindowJumpTo((JumpUIType)itemWaysModel.OpenpanelId); |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | |
| | | |
| | | } |
| | | } |
| | | using UnityEngine.UI;
|
| | | using UnityEngine;
|
| | | using TableConfig;
|
| | | using System;
|
| | | using System.Collections.Generic;
|
| | | using DG.Tweening;
|
| | | using Snxxz.UI;
|
| | | using System.Collections;
|
| | | using System.Linq;
|
| | |
|
| | | namespace Snxxz.UI
|
| | | {
|
| | | public class GetEquipPathTips : MonoBehaviour
|
| | | {
|
| | | #region 成员变量
|
| | | [SerializeField]
|
| | | protected ItemCell _itemCell;
|
| | |
|
| | | [SerializeField]
|
| | | protected Text _nameText;
|
| | |
|
| | | [SerializeField]
|
| | | Text equipScoreDes;
|
| | | [SerializeField]
|
| | | Text equipScoreValue;
|
| | | [SerializeField]
|
| | | Text needLvDes;
|
| | | [SerializeField]
|
| | | Text needLvValue;
|
| | | [SerializeField]
|
| | | List<Text> needPointTextlist = new List<Text>();
|
| | | [SerializeField]
|
| | | List<Text> needPointNumlist = new List<Text>();
|
| | |
|
| | | [SerializeField]
|
| | | Text realmTitleText;
|
| | | [SerializeField] Image realmImg;
|
| | |
|
| | | [SerializeField]
|
| | | protected Button _closeBtn;
|
| | |
|
| | | [SerializeField]
|
| | | protected GameObject _bottomPart;
|
| | |
|
| | | [SerializeField]
|
| | | private Button _getItemBtn;
|
| | |
|
| | | [SerializeField]
|
| | | protected RectTransform _itemInfoTips;
|
| | |
|
| | | [SerializeField] RectTransform getWaysTips;
|
| | |
|
| | | [SerializeField]
|
| | | protected CanvasGroup _getWaysTipsAlpha;
|
| | |
|
| | | [SerializeField]
|
| | | private ScrollerController _waysCtrl;
|
| | |
|
| | | [SerializeField]
|
| | | private Transform waysLineCell;
|
| | |
|
| | | [SerializeField]
|
| | | private Button _closeWaysBtn;
|
| | |
|
| | | [SerializeField]
|
| | | [Header("移动时间")]
|
| | | protected float _moveTime = 0.3f;
|
| | |
|
| | | [SerializeField]
|
| | | protected CanvasGroup tipAlpha;
|
| | |
|
| | | [SerializeField] GameObject equipTipsObj;
|
| | |
|
| | | #region MidUI
|
| | | [Header("装备属性部分")]
|
| | | [SerializeField]
|
| | | RectTransform attrContent;
|
| | | [SerializeField]
|
| | | ScrollRect scrollRect;
|
| | | [SerializeField]
|
| | | LayoutElement scrollLayout;
|
| | |
|
| | | [SerializeField]
|
| | | GameObject basicAttr;
|
| | | [SerializeField]
|
| | | Text basicTitleText;
|
| | | [SerializeField]
|
| | | Text basicAttrDes;
|
| | |
|
| | | [SerializeField]
|
| | | GameObject exhaustedAttr;
|
| | | [SerializeField]
|
| | | Text exhaustedTitleText;
|
| | | [SerializeField]
|
| | | Text exhaustedAttrDes;
|
| | |
|
| | | [SerializeField]
|
| | | GameObject legendAttr;
|
| | | [SerializeField]
|
| | | Text legendTitleText;
|
| | | [SerializeField]
|
| | | Text legendCntPreview;
|
| | | [SerializeField]
|
| | | Text legendAttrDes;
|
| | |
|
| | | [SerializeField]
|
| | | GameObject gemAttr;
|
| | | [SerializeField]
|
| | | Text gemTitleText;
|
| | | [SerializeField]
|
| | | List<GemElementObj> gemObjlist = new List<GemElementObj>();
|
| | |
|
| | | [SerializeField] List<GameObject> attrCutLinelist = new List<GameObject>();
|
| | | #endregion
|
| | |
|
| | | #endregion
|
| | |
|
| | | DailyQuestModel _questModel;
|
| | | protected DailyQuestModel QuestModel
|
| | | {
|
| | | get { return _questModel ?? (_questModel = ModelCenter.Instance.GetModel<DailyQuestModel>()); }
|
| | | }
|
| | |
|
| | | ItemTipsModel _itemTipsModel;
|
| | | ItemTipsModel itemTipsModel
|
| | | {
|
| | | get
|
| | | {
|
| | | return _itemTipsModel ?? (_itemTipsModel = ModelCenter.Instance.GetModel<ItemTipsModel>());
|
| | | }
|
| | | }
|
| | |
|
| | | PackModelInterface _modelInterface;
|
| | | PackModelInterface modelInterface
|
| | | {
|
| | | get { return _modelInterface ?? (_modelInterface = ModelCenter.Instance.GetModel<PackModelInterface>()); }
|
| | | }
|
| | |
|
| | | Dictionary<AttrEnum, int> needPointDict = new Dictionary<AttrEnum, int>();
|
| | |
|
| | | Color32 conditionColor = new Color32(255, 244, 205, 255);
|
| | | Color32 conditionRedColor = new Color32(255, 1, 1, 255);
|
| | | ItemAttrData itemAttrData;
|
| | | private int curAttrTypeNum = 0;
|
| | | public void InitModel(ItemAttrData attrData)
|
| | | {
|
| | | curAttrTypeNum = 0;
|
| | | itemAttrData = attrData;
|
| | | _waysCtrl.OnRefreshCell += RefreshWayCell;
|
| | | _closeBtn.onClick.AddListener(CloseWin);
|
| | | _getItemBtn.onClick.AddListener(OnClickGetItemBtn);
|
| | | _closeWaysBtn.onClick.AddListener(CloseWin);
|
| | | _bottomPart.gameObject.SetActive(false);
|
| | | InitUI();
|
| | | }
|
| | | private void OnEnable()
|
| | | {
|
| | | transform.SetAsLastSibling();
|
| | | StartCoroutine(SetScrollSize());
|
| | | }
|
| | |
|
| | | private void OnDisable()
|
| | | {
|
| | | _waysCtrl.OnRefreshCell -= RefreshWayCell;
|
| | | _closeBtn.RemoveAllListeners();
|
| | | _getItemBtn.RemoveAllListeners();
|
| | | _closeWaysBtn.RemoveAllListeners();
|
| | | }
|
| | |
|
| | | #region iteminfoTips逻辑
|
| | |
|
| | | protected virtual IEnumerator SetScrollSize()
|
| | | {
|
| | | yield return null;
|
| | | yield return null;
|
| | | attrContent.anchoredPosition3D = new Vector3(attrContent.anchoredPosition3D.x, 0, 0);
|
| | | SetMidUIHeight(attrContent.rect.height);
|
| | | StartCoroutine(ShowBottomPart());
|
| | | }
|
| | |
|
| | | IEnumerator ShowBottomPart()
|
| | | {
|
| | | yield return null;
|
| | | _bottomPart.SetActive(true);
|
| | | StartCoroutine(SetPanelScale());
|
| | | }
|
| | |
|
| | | IEnumerator SetPanelScale()
|
| | | {
|
| | | yield return null;
|
| | | itemTipsModel.SetCurTips(this.GetComponent<RectTransform>());
|
| | | SetGetWaysPos();
|
| | | //_itemInfoTips.localPosition = Vector3.zero;
|
| | | tipAlpha.alpha = 1;
|
| | | }
|
| | |
|
| | | #region 设置坐标
|
| | | public void SetGetWaysPos()
|
| | | {
|
| | | if(itemTipsModel.compareAttrData != null)
|
| | | {
|
| | | getWaysTips.anchoredPosition3D = Vector3.zero;
|
| | | }
|
| | | else
|
| | | {
|
| | | getWaysTips.anchoredPosition3D = new Vector3(this.GetComponent<RectTransform>().sizeDelta.x / 2, 0, 0);
|
| | | }
|
| | | }
|
| | | #endregion
|
| | |
|
| | | private void InitUI()
|
| | | {
|
| | | if (itemAttrData == null)
|
| | | return;
|
| | |
|
| | | _closeBtn.gameObject.SetActive(true);
|
| | | _getWaysTipsAlpha.alpha = 0;
|
| | | tipAlpha.alpha = 0;
|
| | | SetTopUI();
|
| | | SetMidUI();
|
| | | }
|
| | |
|
| | | private void SetTopUI()
|
| | | {
|
| | |
|
| | | ItemCellModel cellModel = new ItemCellModel(itemAttrData.itemId,false,0,itemAttrData.isBind);
|
| | | _itemCell.Init(cellModel);
|
| | | _nameText.text = itemAttrData.itemConfig.ItemName;
|
| | | _nameText.color = UIHelper.GetUIColor(itemAttrData.itemConfig.ItemColor);
|
| | | equipScoreDes.text = Language.Get("EquipWin_EquipPointText_1");
|
| | | equipScoreValue.text = itemAttrData.score.ToString();
|
| | | CheckUselimit();
|
| | | }
|
| | |
|
| | | private void CheckUselimit()
|
| | | {
|
| | | int[] uselimits = itemAttrData.itemConfig.UseCondiType;
|
| | | if (uselimits == null) return;
|
| | |
|
| | | needLvValue.gameObject.SetActive(false);
|
| | | needLvDes.gameObject.SetActive(false);
|
| | | realmTitleText.gameObject.SetActive(false);
|
| | | realmImg.gameObject.SetActive(false);
|
| | | for (int i = 0; i < needPointTextlist.Count; i++)
|
| | | {
|
| | | needPointTextlist[i].gameObject.SetActive(false);
|
| | | needPointNumlist[i].gameObject.SetActive(false);
|
| | | }
|
| | | for (int i = 0; i < uselimits.Length; i++)
|
| | | {
|
| | | switch (uselimits[i])
|
| | | {
|
| | | case 0:
|
| | | if (itemAttrData.itemConfig.UseLV > 1)
|
| | | {
|
| | | needLvValue.gameObject.SetActive(true);
|
| | | needLvDes.gameObject.SetActive(true);
|
| | | }
|
| | | needLvDes.text = Language.Get("KnapS110");
|
| | | if (itemAttrData.isHavePutLimit)
|
| | | {
|
| | | needLvValue.text = itemAttrData.itemConfig.UseLV.ToString();
|
| | | if (PlayerDatas.Instance.baseData.LV >= itemAttrData.itemConfig.UseLV)
|
| | | {
|
| | | needLvValue.color = conditionColor;
|
| | | needLvDes.color = conditionColor;
|
| | | }
|
| | | else
|
| | | {
|
| | | needLvValue.color = UIHelper.GetUIColor(TextColType.Red);
|
| | | needLvDes.color = UIHelper.GetUIColor(TextColType.Red);
|
| | | }
|
| | | }
|
| | | else
|
| | | {
|
| | | needLvValue.text = 1.ToString();
|
| | | needLvDes.color = conditionColor;
|
| | | needLvValue.color = conditionColor;
|
| | | }
|
| | |
|
| | | break;
|
| | | case 1:
|
| | | if(itemAttrData.isHavePutLimit)
|
| | | {
|
| | | realmTitleText.gameObject.SetActive(true);
|
| | | realmImg.gameObject.SetActive(true);
|
| | | realmTitleText.text = Language.Get("RealmLimit1");
|
| | | RealmConfig realmConfig = Config.Instance.Get<RealmConfig>(itemAttrData.itemConfig.RealmLimit);
|
| | | if (itemAttrData.itemConfig.RealmLimit <= 0)
|
| | | {
|
| | | realmImg.SetSprite("NoRealm");
|
| | | }
|
| | | else
|
| | | {
|
| | | if (realmConfig != null)
|
| | | {
|
| | | realmImg.SetSprite(realmConfig.Img);
|
| | | }
|
| | | }
|
| | |
|
| | | if (PlayerDatas.Instance.baseData.realmLevel >= itemAttrData.itemConfig.RealmLimit)
|
| | | {
|
| | | realmTitleText.color = conditionColor;
|
| | | }
|
| | | else
|
| | | {
|
| | | realmTitleText.color = UIHelper.GetUIColor(TextColType.Red);
|
| | | }
|
| | | }
|
| | | |
| | | break;
|
| | | case 2:
|
| | | RefreshNeedPointUI();
|
| | | break;
|
| | | }
|
| | | }
|
| | |
|
| | | }
|
| | |
|
| | | private void RefreshNeedPointUI()
|
| | | {
|
| | | needPointDict.Clear();
|
| | | if (itemAttrData.itemConfig.LimitSTR > 0)
|
| | | {
|
| | | needPointDict.Add(AttrEnum.POWER, itemAttrData.itemConfig.LimitSTR);
|
| | | }
|
| | |
|
| | | if (itemAttrData.itemConfig.LimitPHY > 0)
|
| | | {
|
| | | needPointDict.Add(AttrEnum.AGILITY, itemAttrData.itemConfig.LimitPHY);
|
| | | }
|
| | |
|
| | | if (itemAttrData.itemConfig.LimitPNE > 0)
|
| | | {
|
| | | needPointDict.Add(AttrEnum.MENTALITY, itemAttrData.itemConfig.LimitPNE);
|
| | | }
|
| | |
|
| | | List<AttrEnum> needlist = needPointDict.Keys.ToList();
|
| | |
|
| | | int i = 0;
|
| | | for (i = 0; i < needPointTextlist.Count; i++)
|
| | | {
|
| | | if (i < needlist.Count)
|
| | | {
|
| | | needPointTextlist[i].gameObject.SetActive(true);
|
| | | needPointNumlist[i].gameObject.SetActive(true);
|
| | | switch (needlist[i])
|
| | | {
|
| | | case AttrEnum.POWER:
|
| | | if (itemAttrData.isHavePutLimit)
|
| | | {
|
| | | SetNeedPointUI(needPointDict[needlist[i]],needPointTextlist[i], needPointNumlist[i], Language.Get("KnapS113"));
|
| | | }
|
| | | else
|
| | | {
|
| | | SetNeedPointUI(1,needPointTextlist[i], needPointNumlist[i], Language.Get("KnapS113"));
|
| | | }
|
| | | break;
|
| | | case AttrEnum.AGILITY:
|
| | | if (itemAttrData.isHavePutLimit)
|
| | | {
|
| | | SetNeedPointUI(needPointDict[needlist[i]],needPointTextlist[i], needPointNumlist[i], Language.Get("KnapS112"));
|
| | | }
|
| | | else
|
| | | {
|
| | | SetNeedPointUI(1,needPointTextlist[i], needPointNumlist[i], Language.Get("KnapS112"));
|
| | | }
|
| | |
|
| | | break;
|
| | | case AttrEnum.MENTALITY:
|
| | | if (itemAttrData.isHavePutLimit)
|
| | | {
|
| | | SetNeedPointUI(needPointDict[needlist[i]],needPointTextlist[i], needPointNumlist[i], Language.Get("KnapS111"));
|
| | | }
|
| | | else
|
| | | {
|
| | | SetNeedPointUI(1,needPointTextlist[i], needPointNumlist[i], Language.Get("KnapS111"));
|
| | | }
|
| | | break;
|
| | | }
|
| | |
|
| | | }
|
| | | else
|
| | | {
|
| | | needPointTextlist[i].gameObject.SetActive(false);
|
| | | needPointNumlist[i].gameObject.SetActive(false);
|
| | | }
|
| | | }
|
| | |
|
| | | }
|
| | |
|
| | |
|
| | | private void SetNeedPointUI(float needPoint,Text needPoinText, Text needPoinNum, string msg)
|
| | | {
|
| | | needPoinNum.color = conditionColor;
|
| | | needPoinText.color = conditionColor;
|
| | | needPoinNum.text = needPoint.ToString();
|
| | | needPoinText.text = msg;
|
| | | }
|
| | |
|
| | | private void SetMidUI()
|
| | | {
|
| | | SetBasicAttrUI();
|
| | | SetExhaustedAttrUI();
|
| | | SetLegendAttrUI();
|
| | | SetGemAttrUI();
|
| | | for (int i = 0; i < curAttrTypeNum; i++)
|
| | | {
|
| | | if (i == curAttrTypeNum - 1)
|
| | | {
|
| | | attrCutLinelist[curAttrTypeNum - 1].SetActive(false);
|
| | | }
|
| | | else
|
| | | {
|
| | | attrCutLinelist[i].SetActive(true);
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | #region 设置属性UI
|
| | | private void SetBasicAttrUI()
|
| | | {
|
| | | curAttrTypeNum += 1;
|
| | | basicAttr.SetActive(true);
|
| | | basicTitleText.text = Language.Get("RolePanel_BaseAttrText_1");
|
| | | basicAttrDes.text = itemTipsModel.GetBasicAttr(itemAttrData);
|
| | | }
|
| | |
|
| | | private void SetExhaustedAttrUI()
|
| | | {
|
| | | if (itemAttrData.exhaustedMaxDataDict == null)
|
| | | {
|
| | | exhaustedAttr.SetActive(false);
|
| | | return;
|
| | | }
|
| | | curAttrTypeNum += 1;
|
| | | exhaustedAttr.SetActive(true);
|
| | | exhaustedTitleText.text = Language.Get("EquipWin_ExtinctPropObj_Text_1");
|
| | | exhaustedAttrDes.text = itemTipsModel.GetExhaustedAtrr(itemAttrData);
|
| | | }
|
| | |
|
| | | private void SetLegendAttrUI()
|
| | | {
|
| | | if (itemAttrData.legendDataDict == null)
|
| | | {
|
| | | legendAttr.SetActive(false);
|
| | | return;
|
| | | }
|
| | | curAttrTypeNum += 1;
|
| | | legendAttr.SetActive(true);
|
| | | legendTitleText.text = Language.Get("EquipWin_LegendPropObj_Text_1");
|
| | | legendAttrDes.text = itemTipsModel.GetLegendAttr(itemAttrData);
|
| | |
|
| | | if (itemAttrData.isPreview)
|
| | | {
|
| | | legendCntPreview.gameObject.SetActive(true);
|
| | | legendCntPreview.text = itemTipsModel.GetEquipLegendAttrCntPreview(itemAttrData);
|
| | | }
|
| | | else
|
| | | {
|
| | | legendCntPreview.gameObject.SetActive(false);
|
| | | }
|
| | | }
|
| | |
|
| | |
|
| | | private void SetGemAttrUI()
|
| | | {
|
| | | if (itemAttrData.itemConfig.LV < itemTipsModel.gemOpenLvs[0])
|
| | | {
|
| | | gemAttr.SetActive(false);
|
| | | return;
|
| | | }
|
| | | curAttrTypeNum += 1;
|
| | | gemAttr.SetActive(true);
|
| | | gemTitleText.text = Language.Get("EquipWin_GemPropObj_Text_1");
|
| | | int cnt = 0;
|
| | | int vipCnt = 0;
|
| | | if (itemAttrData.itemConfig.LV >= itemTipsModel.gemOpenLvs[0])
|
| | | {
|
| | | cnt++;
|
| | | }
|
| | |
|
| | | if (itemAttrData.itemConfig.LV >= itemTipsModel.gemOpenLvs[1])
|
| | | {
|
| | | cnt++;
|
| | | }
|
| | |
|
| | | if (itemAttrData.itemConfig.LV >= itemTipsModel.gemOpenLvs[2])
|
| | | {
|
| | | cnt++;
|
| | | }
|
| | |
|
| | | if (PlayerDatas.Instance.baseData.VIPLv >= itemTipsModel.gemOpenVipLv)
|
| | | {
|
| | | vipCnt++;
|
| | | }
|
| | |
|
| | | int i = 0;
|
| | | for (i = 0; i < gemObjlist.Count; i++)
|
| | | {
|
| | | int stoneId = 0;
|
| | | if (itemAttrData.stones != null)
|
| | | {
|
| | | if (i < itemAttrData.stones.Length)
|
| | | {
|
| | | stoneId = (int)itemAttrData.stones[i];
|
| | | }
|
| | | }
|
| | |
|
| | | if (i < gemObjlist.Count - 1)
|
| | | {
|
| | | if (i < cnt)
|
| | | {
|
| | |
|
| | | gemObjlist[i].gameObject.SetActive(true);
|
| | | gemObjlist[i].InitModel(stoneId, i, itemAttrData.itemConfig.EquipPlace, false);
|
| | | }
|
| | | else
|
| | | {
|
| | | gemObjlist[i].InitModel(stoneId, i, itemAttrData.itemConfig.EquipPlace, true);
|
| | | gemObjlist[i].gameObject.SetActive(false);
|
| | | }
|
| | |
|
| | | }
|
| | | else
|
| | | {
|
| | | if (vipCnt != 0)
|
| | | {
|
| | | gemObjlist[i].InitModel(stoneId, i, itemAttrData.itemConfig.EquipPlace, false);
|
| | | }
|
| | | else
|
| | | {
|
| | | gemObjlist[i].InitModel(stoneId, i, itemAttrData.itemConfig.EquipPlace, true);
|
| | | }
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | |
|
| | | private void SetMidUIHeight(float midHeight)
|
| | | {
|
| | | scrollRect.enabled = false;
|
| | |
|
| | | if (midHeight < itemTipsModel.equipMidHeights[0])
|
| | | {
|
| | | scrollLayout.preferredHeight = itemTipsModel.equipMidHeights[0];
|
| | | }
|
| | | else if (midHeight > itemTipsModel.equipMidHeights[1])
|
| | | {
|
| | | scrollRect.enabled = true;
|
| | | scrollLayout.preferredHeight = itemTipsModel.equipMidHeights[1];
|
| | | }
|
| | | else
|
| | | {
|
| | | scrollLayout.preferredHeight = midHeight;
|
| | | }
|
| | | }
|
| | | #endregion
|
| | |
|
| | | #region 点击事件
|
| | | private void OnClickGetItemBtn()
|
| | | {
|
| | | if (_getWaysTipsAlpha.alpha <= 0)
|
| | | {
|
| | | Vector3 pos = Vector3.zero;
|
| | | if(itemTipsModel.compareAttrData != null)
|
| | | {
|
| | | equipTipsObj.SetActive(false);
|
| | | pos = new Vector3(0,0, 0);
|
| | | }
|
| | | else
|
| | | {
|
| | | pos = new Vector3(this.GetComponent<RectTransform>().sizeDelta.x, 0, 0);
|
| | | }
|
| | | _itemInfoTips.DOAnchorPos3D(pos, _moveTime);
|
| | | _getWaysTipsAlpha.DOFade(1, _moveTime);
|
| | | _closeBtn.gameObject.SetActive(false);
|
| | |
|
| | | CreateWayCell();
|
| | | }
|
| | | else
|
| | | {
|
| | | _itemInfoTips.DOAnchorPos3D(new Vector3(this.GetComponent<RectTransform>().sizeDelta.x, 0, 0), _moveTime);
|
| | | _getWaysTipsAlpha.DOFade(0, _moveTime);
|
| | | _closeBtn.gameObject.SetActive(true);
|
| | | if (itemTipsModel.compareAttrData != null)
|
| | | {
|
| | | equipTipsObj.SetActive(true);
|
| | | }
|
| | | }
|
| | |
|
| | | }
|
| | |
|
| | | private void CloseWin()
|
| | | {
|
| | | KnapSackEventMgr.Instance.HideItemPopWin();
|
| | | }
|
| | | #endregion
|
| | |
|
| | | #endregion
|
| | |
|
| | | #region getWaysTips逻辑
|
| | | private List<GetItemWaysConfig> getWayslist;
|
| | | protected virtual void CreateWayCell()
|
| | | {
|
| | | getWayslist = itemTipsModel.GetWaysList(itemAttrData);
|
| | | _waysCtrl.Refresh();
|
| | | int i = 0;
|
| | | int remain = getWayslist.Count % waysLineCell.childCount;
|
| | | int line = (int)getWayslist.Count / waysLineCell.childCount;
|
| | | if (remain > 0)
|
| | | {
|
| | | line += 1;
|
| | | }
|
| | |
|
| | | for (i = 0; i < line; i++)
|
| | | {
|
| | | _waysCtrl.AddCell(ScrollerDataType.Header,i);
|
| | | }
|
| | | _waysCtrl.Restart();
|
| | | }
|
| | |
|
| | | private void RefreshWayCell(ScrollerDataType type, CellView cell)
|
| | | {
|
| | | int i = 0;
|
| | | for(i = 0; i < cell.transform.childCount; i++)
|
| | | {
|
| | | WayCell wayCell = cell.transform.GetChild(i).GetComponent<WayCell>();
|
| | | if (wayCell == null)
|
| | | wayCell = cell.transform.GetChild(i).gameObject.AddComponent<WayCell>();
|
| | |
|
| | | int index = (cell.transform.childCount) * cell.index + i;
|
| | | if(index <= getWayslist.Count - 1)
|
| | | {
|
| | | cell.transform.GetChild(i).gameObject.SetActive(true);
|
| | | GetItemWaysConfig itemWaysModel = getWayslist[index];
|
| | | wayCell.icon.SetSprite(itemWaysModel.Icon);
|
| | | wayCell.wayName.text = itemWaysModel.Text;
|
| | | wayCell.funcName.text = itemWaysModel.name;
|
| | | wayCell.wayButton.RemoveAllListeners();
|
| | | wayCell.wayButton.AddListener(()=> {
|
| | | ClickWayCell(itemWaysModel);
|
| | | });
|
| | | }
|
| | | else
|
| | | {
|
| | | cell.transform.GetChild(i).gameObject.SetActive(false);
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | public void ClickWayCell(GetItemWaysConfig itemWaysModel)
|
| | | {
|
| | | if(!string.IsNullOrEmpty(itemWaysModel.SelectActive) && itemWaysModel.SelectActive != "")
|
| | | {
|
| | | QuestModel.currentDailyQuest = int.Parse(itemWaysModel.SelectActive);
|
| | | }
|
| | | CloseWin();
|
| | | WindowJumpMgr.Instance.WindowJumpTo((JumpUIType)itemWaysModel.OpenpanelId);
|
| | | }
|
| | |
|
| | | #endregion
|
| | |
|
| | |
|
| | |
|
| | | }
|
| | | }
|