少年修仙传客户端代码仓库
client_Wu Xijin
2019-06-13 033958214c0b16d7e7b93cc821b018c295251867
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
//--------------------------------------------------------
//    [Author]:           第二世界
//    [  Date ]:           Saturday, October 28, 2017
//--------------------------------------------------------
 
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
 
using UnityEngine.UI;
//关于PK战斗状态改变面板
 
namespace Snxxz.UI
{
 
    public class CombatModeWin : Window
    {
        public float headings = 20f;
        public float height = 60f;
        [SerializeField]
        RectTransform _Viewport;
        [SerializeField]
        ScrollerController m_ScrollerController;
        [SerializeField]
        Button _CloseBtn;
        private Dictionary<int, string> _dic = new Dictionary<int, string>();
        private int _PkType = 0;
        private int[] AtkTypeList;
        #region Built-in
        BuffModel m_BuffModel;
        BuffModel Buffmodel { get { return m_BuffModel ?? (m_BuffModel = ModelCenter.Instance.GetModel<BuffModel>()); } }
        PKModel m_PKModel;
        PKModel pKModel { get { return m_PKModel ?? (m_PKModel = ModelCenter.Instance.GetModel<PKModel>()); } }
        PlayerMainDate m_MainModel;
        PlayerMainDate onMainModel { get { return m_MainModel ?? (m_MainModel = ModelCenter.Instance.GetModel<PlayerMainDate>()); } }
        protected override void BindController()
        {
            string PkStr = FuncConfigConfig.Get("PKText").Numerical1;
            _dic = ConfigParse.GetDic<int, string>(PkStr);
        }
 
        protected override void AddListeners()
        {
            _CloseBtn.AddListener(CloseBtn);
        }
 
        protected override void OnPreOpen()
        {
            int MapID = PlayerDatas.Instance.baseData.MapID;
            var config = MapConfig.Get(MapID);
            AtkTypeList = pKModel.GetArea(config.AtkType).ToArray();
 
            _PkType = Buffmodel.PkType;//获取当前PK状态
            if (_PkType != 2)
            {
                _dic.Remove(2);
            }
            m_ScrollerController.OnRefreshCell += OnRefreshGridCell;
            OnCreateGridLineCell(m_ScrollerController);
            _Viewport.sizeDelta = _Viewport.sizeDelta.SetY(AtkTypeList.Length * height + headings);
        }
 
        protected override void OnAfterOpen()
        {
 
        }
 
        protected override void OnPreClose()
        {
            m_ScrollerController.OnRefreshCell -= OnRefreshGridCell;
        }
 
        protected override void OnAfterClose()
        {
        }
        #endregion
 
 
        void CloseBtn()
        {
 
            Close();
        }
        private void OnCreateGridLineCell(ScrollerController gridCtrl)
        {
            gridCtrl.Refresh();
            for (int i = 0; i < AtkTypeList.Length; i++)
            {
                gridCtrl.AddCell(ScrollerDataType.Header, AtkTypeList[i]);
            }
            gridCtrl.Restart();
        }
        private void OnRefreshGridCell(ScrollerDataType type, CellView cell)
        {
            PKButton _PkButton = cell.GetComponent<PKButton>();
            if (_PkType == cell.index)
                _PkButton.ElectImage.SetActive(true);
            else
                _PkButton.ElectImage.SetActive(false);
            TextSwitch(cell.index, _PkButton.Model, _PkButton.ContentText);
            _PkButton.StateSelection.RemoveAllListeners();
            bool IsBossBool = MapArea.IsInMapArea(PlayerDatas.Instance.hero.CurMapArea, MapArea.E_Type.Boss);//是否在Boss区域
            _PkButton.StateSelection.AddListener(() =>
            {
                DTCA202_tagMCAttackMode.Send_SwitchAttackMode((E_AttackMode)cell.index);
                Close();
            });
            // throw new NotImplementedException();
        }
 
 
        void TextSwitch(int _EnumType, Image _imge, Text _text)
        {
            switch (_EnumType)
            {
                case 0:
 
                    _imge.SetSprite("Atk_Peace");//和平
                    _text.text = _dic[0];
                    break;
                case 1:
 
                    _imge.SetSprite("Atk_All");//全体
                    _text.text = _dic[1];
                    break;
                case 2:
                    _imge.SetSprite("Atk_Defence");//防卫
                    _text.text = _dic[2];
                    break;
                case 3:
 
                    DebugEx.LogError("集团");
                    break;
                case 4:
 
                    DebugEx.LogError("组队");
                    break;
                case 5:
 
                    _imge.SetSprite("Atk_Force");//强制
                    _text.text = _dic[5];
                    break;
                case 6:
                    break;
                case 7:
                    _imge.SetSprite("Atk_Scramble");
                    _text.text = _dic.ContainsKey(7) ? _dic[7] : string.Empty;
                    break;
                default:
                    break;
            }
        }
    }
 
 
 
 
 
}