少年修仙传客户端代码仓库
client_Wu Xijin
2019-02-25 cdb0198fb8e85811ec1e06b15f36df9cbe0fdb9a
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
using System;
using System.Collections.Generic;
using System.Linq;
using UnityEngine;
using UnityEngine.UI;
 
using System.Text;
using Snxxz.UI;
using System.Collections;
 
public  class RoleEquipStrengthTips : MonoBehaviour
{
    #region 成员变量
    [SerializeField]
    CanvasGroup tipAlpha;
    private GameObject _curStrength;
    private Text _curStrengthText;
    private Text _curAttrValueText;
    private Text _haveStrengthText;
    private GameObject _nextStrength;
    private Text _nextStrengthText;
    private Text _nextAttrValueText;
    private Text _noOpenText;
    #endregion
 
    private int _curStrengthLv;
    private PlayerPropertyConfig _playerProModel;
    private Dictionary<int, Dictionary<int, int>> _roleStrengthInfoDict;
    private Dictionary<int, EquipmentInitialization> _haveStrengthInfoDict;
 
    private void Awake()
    {
        _curStrength = transform.Find("CurrentStrength").gameObject;
        _curStrengthText = transform.Find("CurrentStrength/TargetNowText").GetComponent<Text>();
        _curAttrValueText = transform.Find("CurrentStrength/AttrValueText").GetComponent<Text>();
        _haveStrengthText = transform.Find("CurrentStrength/CountNowText").GetComponent<Text>();
 
        _nextStrength = transform.Find("NextStrength").gameObject;
        _nextStrengthText = transform.Find("NextStrength/TargetNextText").GetComponent<Text>();
        _nextAttrValueText = transform.Find("NextStrength/ActNextText").GetComponent<Text>();
        _noOpenText = transform.Find("CurrentStrength/NoOpenText").GetComponent<Text>();
       
    }
    PlayerStrengthengDatas m_StrengthengModel;
    PlayerStrengthengDatas strengthengmodel
    {
        get
        {
            return m_StrengthengModel ?? (m_StrengthengModel = ModelCenter.Instance.GetModel<PlayerStrengthengDatas>());
        }
    }
    private void OnEnable()
    {
        _roleStrengthInfoDict = strengthengmodel.StrengtheningAll();
        _haveStrengthInfoDict = strengthengmodel._EqInfo;
        _nextStrength.SetActive(false);
        _curStrength.SetActive(false);
        RefreshUI();
        tipAlpha.alpha = 0;
        StartCoroutine(SetScrollSize());
    }
 
    private void RefreshUI()
    {
        if (_roleStrengthInfoDict.Count < 2)
            return;
        List<int> strengthLvs = _roleStrengthInfoDict.Keys.ToList();
       _curStrengthText.text = Language.Get("KnapS121").Replace("{0}",strengthLvs[0].ToString());
        StringBuilder curAttrStr = new StringBuilder();
        RectTransform size = _haveStrengthText.GetComponent<RectTransform>();
        foreach (int pro in _roleStrengthInfoDict[strengthLvs[0]].Keys)
        {
            curAttrStr.Append(SetIsPercentShow(pro, _roleStrengthInfoDict[strengthLvs[0]][pro]) + "\n");
        }
      
        if(curAttrStr.Length < 1)
        {
            _noOpenText.gameObject.SetActive(true);
            _curStrengthText.gameObject.SetActive(false);
            _curAttrValueText.gameObject.SetActive(false);
        }
        else
        {
            _noOpenText.gameObject.SetActive(false);
            _curStrengthText.gameObject.SetActive(true);
            _curAttrValueText.gameObject.SetActive(true);
        }
        _curAttrValueText.text = curAttrStr.ToString();
        StringBuilder nextAttrStr = new StringBuilder();
        foreach (int pro in _roleStrengthInfoDict[strengthLvs[1]].Keys)
        {
            nextAttrStr.Append(SetIsPercentShow(pro, _roleStrengthInfoDict[strengthLvs[1]][pro]) + "\n");
        }
        _nextStrengthText.text = Language.Get("KnapS121").Replace("{0}", _roleStrengthInfoDict.Keys.ToList()[1].ToString());
        _nextAttrValueText.text = nextAttrStr.ToString();
 
        _curStrengthLv = 0;
        foreach(var value in _haveStrengthInfoDict.Values)
        {
            _curStrengthLv += value.EquipPartStarLV;
        }
        _haveStrengthText.text = Language.Get("KnapS122").Replace("{0}",_curStrengthLv.ToString());
 
    }
 
    IEnumerator SetScrollSize()
    {
        yield return null;
        yield return null;
        _curStrength.SetActive(true);
        StartCoroutine(ShowBottomPart());
    }
 
    IEnumerator ShowBottomPart()
    {
        yield return null;
        _nextStrength.SetActive(true);
        StartCoroutine(SetPanelScale());
    }
 
    IEnumerator SetPanelScale()
    {
        yield return null;
        tipAlpha.alpha = 1;
    }
 
    //判断属性是否百分比显示
    public string SetIsPercentShow(int proId, int proValue)
    {
        _playerProModel = PlayerPropertyConfig.Get(proId);
        string strPro = "";
        if (_playerProModel == null)
        {
            DebugEx.LogError("不存在此属性" + proId);
            return "";
        }
 
        if (!_playerProModel.Name.Contains("%s"))
        {
            if (_playerProModel.ISPercentage == 0)
            {
                strPro = _playerProModel.Name + "+" + proValue;
            }
            else if (_playerProModel.ISPercentage == 1)
            {
                strPro = _playerProModel.Name + "+" + (float)Math.Round(proValue / 100f, 1) + "%";
            }
        }
        else
        {
            if (_playerProModel.ISPercentage == 0)
            {
                strPro = _playerProModel.Name.Replace("%s", proValue.ToString());
            }
            else if (_playerProModel.ISPercentage == 1)
            {
                strPro = _playerProModel.Name.Replace("%s", (float)Math.Round(proValue / 100f, 1) + "%");
            }
        }
 
        return strPro;
    }
 
}