少年修仙传客户端代码仓库
lcy
2024-12-16 a39c35fc6449430cd02bccb681c4a0a880e46cd9
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
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
//--------------------------------------------------------
//    [Author]:           第二世界
//    [  Date ]:           Saturday, January 06, 2018
//--------------------------------------------------------
 
using System;
using System.Collections;
using System.Collections.Generic;
 
using UnityEngine;
using UnityEngine.UI;
 
namespace vnxbqy.UI
{
 
    public class WorshipInfoListWin : Window
    {
        [SerializeField] RawImage rawImage;
        [SerializeField] Text m_PlayerName;
        [SerializeField] Text m_WorshipText; //膜拜原因
        [SerializeField] Image m_TitleIcon;
        [SerializeField] Button m_WorshipBtn;
        [SerializeField] Button m_CloseBtn;
        [SerializeField] Toggle m_Toggle;
 
 
        WorshipInfoListModel worshipInfoListModel { get { return ModelCenter.Instance.GetModel<WorshipInfoListModel>(); } }
 
        int showIndex = 0;
        WorshipInfoListModel.WorshipPlayer player;
        float showNextTime = 0; //下一个显示起始时间,用于防范服务端没有回报问题
        #region Built-in
        protected override void BindController()
        {
        }
 
        protected override void AddListeners()
        {
            m_CloseBtn.onClick.AddListener(CloseClick);
            m_Toggle.SetListener((bool isOn) => {
                worshipInfoListModel.notShowTip = isOn;
            });
 
            m_WorshipBtn.AddListener(Worship);
        }
 
        protected override void OnPreOpen()
        {
            m_Toggle.isOn = worshipInfoListModel.notShowTip;
            worshipInfoListModel.WorshipResultEvent += WorshipResult;
            showIndex = 0;
            m_Toggle.isOn = false;
            Display();
 
        }
 
        protected override void OnAfterOpen()
        {
        }
 
        protected override void OnPreClose()
        {
            worshipInfoListModel.WorshipResultEvent -= WorshipResult;
            UI3DModelExhibition.InstanceClone7.StopShow();
            worshipInfoListModel.players.Clear();
        }
 
        protected override void OnAfterClose()
        {
        }
        protected override void LateUpdate()
        {
            if (showNextTime != 0 && Time.time > showNextTime + 1)
            {
                showIndex++;
                showNextTime = 0;
                Display();
            }
        }
 
 
        #endregion
 
        void Worship()
        {
            var pack = new CB020_tagCGWorship();
            pack.PlayerID = player.playerID;
            pack.WorshipType = player.worshipType;
            pack.WorshipValue = player.worshipValue;
            GameNetSystem.Instance.SendInfo(pack);
 
            showNextTime = Time.time;
            if (m_Toggle.isOn)
                CloseClick();
        }
 
        private void DisplayTitle()
        {
            DienstgradConfig config = DienstgradConfig.Get(player.playerInfo.TitleID);
            if (config == null)
            {
                if (player.playerInfo.TitleID != 0)
                {
                    Debug.LogError("DienstgradConfig not found, ID:" + player.playerInfo.TitleID);
                }
                m_TitleIcon.SetActive(false);
                return;
            }
            m_TitleIcon.SetActive(true);
            UIFrame frame = m_TitleIcon.GetComponent<UIFrame>();
            if (UIFrameMgr.Inst.ContainsDynamicImage(config.Image))
            {
                m_TitleIcon.raycastTarget = false;
                frame.enabled = true;
                frame.ResetFrame(config.Image);
            }
            else
            {
                frame.enabled = false;
                m_TitleIcon.SetSprite(config.Image);
            }
        }
 
 
        void Display()
        {
            if (showIndex >= worshipInfoListModel.players.Count)
            {
                CloseClick();
                return;
            }
            player = worshipInfoListModel.players[showIndex];
 
            DisplayTitle();
            
            int serverID = UIHelper.GetServerIDByAccount(player.playerInfo.AccID);
            string serverName = ServerListCenter.Instance.GetServerName(serverID);
 
            m_PlayerName.text = StringUtility.Contact(player.playerInfo.Name, " ", Language.Get("Z2002", serverName));
            m_WorshipText.text =  Language.Get(StringUtility.Contact("WorshipType_", player.worshipType, "_", player.worshipValue));
            ShowPlayer();
        }
 
        public void ShowPlayer()
        {
            int _suitLevel = (int)(player.playerInfo.EquipShowSwitch % 10);
            int clothes = worshipInfoListModel.GetItemId(RoleEquipType.Clothes, player.playerInfo.EquipShowID);
            int weapon = worshipInfoListModel.GetItemId(RoleEquipType.Weapon, player.playerInfo.EquipShowID);
            int weapon2 = worshipInfoListModel.GetItemId(RoleEquipType.Weapon2, player.playerInfo.EquipShowID);
            int fashionClothes = worshipInfoListModel.GetItemId(RoleEquipType.FashionClothes, player.playerInfo.EquipShowID);
            int fashionWeapon = worshipInfoListModel.GetItemId(RoleEquipType.FashionWeapon, player.playerInfo.EquipShowID);
            int fashionWeapon2 = worshipInfoListModel.GetItemId(RoleEquipType.FashionWeapon2, player.playerInfo.EquipShowID);
 
            var data = new UI3DPlayerExhibitionData
            {
                job = player.playerInfo.Job,
                fashionClothesId = fashionClothes,
                fashionWeaponId = fashionWeapon,
                fashionSecondaryId = fashionWeapon2,
                clothesId = clothes,
                suitLevel = _suitLevel,
                weaponId = weapon,
                wingsId = 0,
                secondaryId = weapon2,
                reikiRootEffectId = 0,
                isDialogue = false,
                equipLevel = (int)player.playerInfo.EquipShowSwitch / 10 % 100,
                scale = 0.8f,
                titleID = player.playerInfo.TitleID,
            };
 
            rawImage.SetActiveIL(true);
            UI3DModelExhibition.InstanceClone7.ShowPlayer(rawImage, data);
            rawImage.raycastTarget = false;
        }
 
        void WorshipResult()
        {
            showNextTime = 0;
            if (player.playerID == worshipInfoListModel.playerIDResult && player.worshipType == worshipInfoListModel.worshipTypeResult)
            {
                showIndex++;
            }
            Display();
        }
    }
}