少年修仙传客户端代码仓库
hch
2019-10-31 3c35f85432d317061f09c93319108de899469d55
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
//--------------------------------------------------------
//    [Author]:           第二世界
//    [  Date ]:           Tuesday, July 16, 2019
//--------------------------------------------------------
using UnityEngine;
using System.Collections;
using UnityEngine.UI;
 
namespace Snxxz.UI
{
 
    public class EquipStarMaterialSelectButton : MonoBehaviour
    {
        [SerializeField] Image m_Lock;
        [SerializeField] Button m_SelectMaterial;
        [SerializeField] Image m_Add;
        [SerializeField] ItemBehaviour m_ItemBehaviour;
 
        EquipStarModel starModel { get { return ModelCenter.Instance.GetModel<EquipStarModel>(); } }
 
        public void Display(bool isLock, int itemId)
        {
            var state = 1;
            if (isLock)
            {
                state = 1;
            }
            else
            {
                if (itemId == 0)
                {
                    state = 2;
                }
                else
                {
                    state = 3;
                }
            }
 
            switch (state)
            {
                case 1:
                    m_Lock.gameObject.SetActive(true);
                    m_Add.gameObject.SetActive(false);
                    m_ItemBehaviour.gameObject.SetActive(false);
                    m_SelectMaterial.RemoveAllListeners();
                    break;
                case 2:
                    m_Lock.gameObject.SetActive(false);
                    m_Add.gameObject.SetActive(true);
                    m_ItemBehaviour.gameObject.SetActive(false);
                    m_SelectMaterial.SetListener(OpenMaterialSelectWin);
                    break;
                case 3:
                    m_Lock.gameObject.SetActive(false);
                    m_Add.gameObject.SetActive(false);
                    m_ItemBehaviour.gameObject.SetActive(true);
                    m_ItemBehaviour.SetItem(itemId, 0);
                    m_SelectMaterial.SetListener(OpenMaterialSelectWin);
                    break;
            }
        }
 
        public void Dispose()
        {
 
        }
 
        private void OpenMaterialSelectWin()
        {
            starModel.normalMaterials.Clear();
            var equipPosition = new Int2(starModel.selectedLevel.value, starModel.selectedPlace.value);
            var starLevel = starModel.GetStarLevel(equipPosition);
            starModel.CalculateStarUpgradeProbability(new Int2(starModel.selectedLevel.value, starModel.selectedPlace.value));
 
            var materials = starModel.GetMaterials(equipPosition, starLevel + 1);
            if (materials.IsNullOrEmpty())
            {
                var getWays = starModel.GetMaterialGetWays(equipPosition, starLevel + 1);
                var getWayModel = ModelCenter.Instance.GetModel<GetWayModel>();
                getWayModel.SetWays(getWays.ToArray());
 
                WindowCenter.Instance.Open<GetWayWin>();
            }
            else
            {
                WindowCenter.Instance.Open<EquipStarMaterialSelectWin>();
            }
 
        }
 
    }
 
}