少年修仙传客户端代码仓库
hch
2025-07-24 50e53441950268933694eeb5aad36147bbe1014d
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
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
using System.Collections.Generic;
using UnityEngine;
 
namespace vnxbqy.UI
{
    public class FairySiegeSummonDragonWin : Window
    {
        [SerializeField] ButtonEx btnAutoAtk; //自动攻击上次目标
        [SerializeField] ButtonEx btnFlzt; //飞龙在天
        [SerializeField] ButtonEx btnLtwj; //雷霆万钧
        [SerializeField] ButtonEx btnReward; //查看奖励
        [SerializeField] ButtonEx btnWatch; //观看他人动画
        [SerializeField] ImageEx imgAutoAtk;
        [SerializeField] ImageEx imgFlztItem; //使用技能的物品
        [SerializeField] ImageEx imgLtwjItem; //使用技能的物品
        [SerializeField] ImageEx imgWatch;
        [SerializeField] TextEx txtAutoAtk;
        [SerializeField] TextEx txtFlztCnt;
        [SerializeField] RichText txtFlztInfo;
        [SerializeField] TextEx txtLtwjCnt;
        [SerializeField] RichText txtLtwjInfo;
        [SerializeField] RedpointBehaviour rpFlzt;
        [SerializeField] RedpointBehaviour rpLtwj;
 
        FairySiegeActModel model { get { return ModelCenter.Instance.GetModel<FairySiegeActModel>(); } }
        PackModel packModel { get { return ModelCenter.Instance.GetModel<PackModel>(); } }
 
        #region Build-in
 
        protected override void AddListeners()
        {
            btnReward.SetListener(() => WindowCenter.Instance.Open<FairySiegeSummonDragonAwardWin>());
            btnFlzt.SetListener(FlztClick);
            btnLtwj.SetListener(LtwjClick);
            btnWatch.SetListener(WatchClick);
            btnAutoAtk.SetListener(AutoAtkClick);
        }
 
        protected override void BindController()
        {
        }
 
        protected override void OnPreOpen()
        {
            rpFlzt.redpointId = model.GetRedpointId(FairySiegeRedPointType.SummonDragonFLZT);
            rpLtwj.redpointId = model.GetRedpointId(FairySiegeRedPointType.SummonDragonLTWJ);
            packModel.refreshItemCountEvent += OnRefreshItemCountEvent;
            Display();
        }
 
        protected override void OnPreClose()
        {
            packModel.refreshItemCountEvent -= OnRefreshItemCountEvent;
        }
 
        protected override void OnAfterOpen()
        {
        }
 
        protected override void OnAfterClose()
        {
        }
 
        #endregion
 
        private void OnRefreshItemCountEvent(PackType type, int arg2, int arg3)
        {
            if (type != PackType.Item || model.flztSkillItemId != arg3 || model.ltwjSkillItemId != arg3!)
                return;
            Display();
        }
 
        private void Display()
        {
            imgAutoAtk.SetActive(model.isSummonDragonAutoAtk);
            imgWatch.SetActive(model.isSummonDragonWatch);
 
            var itemId = model.flztSkillItemId;
            var iconKey = ItemConfig.Get(itemId).IconKey;
            imgFlztItem.SetSprite(iconKey);
            var hasCnt = packModel.GetItemCountByID(PackType.Item, itemId);
            var needCnt = model.flztSkillNeedCnt;
            txtFlztCnt.text = StringUtility.Contact(hasCnt, "/", needCnt);
            txtFlztCnt.color = UIHelper.GetUIColor(hasCnt >= needCnt ? TextColType.Green : TextColType.Red);
            var fightPoint = UIHelper.ReplaceLargeNum(PlayerDatas.Instance.baseData.FightPoint * (ulong)model.flztSkillRate);
            var formula = Language.Get("FairySiege035", model.flztSkillRate);
            txtFlztInfo.text = StringUtility.Contact(Language.Get("FairySiege152", model.flztSkillAtkCityCnt, fightPoint), "</r>", formula);
 
            itemId = model.ltwjSkillItemId;
            iconKey = ItemConfig.Get(itemId).IconKey;
            imgLtwjItem.SetSprite(iconKey);
            hasCnt = packModel.GetItemCountByID(PackType.Item, itemId);
            needCnt = model.ltwjSkillNeedCnt;
            txtLtwjCnt.text = StringUtility.Contact(hasCnt, "/", needCnt);
            txtLtwjCnt.color = UIHelper.GetUIColor(hasCnt >= needCnt ? TextColType.Green : TextColType.Red);
            fightPoint = UIHelper.ReplaceLargeNum(PlayerDatas.Instance.baseData.FightPoint * (ulong)model.ltwjSkillRate);
            formula = Language.Get("FairySiege035", model.ltwjSkillRate);
            txtLtwjInfo.text = StringUtility.Contact(Language.Get("FairySiege152", model.ltwjSkillAtkCityCnt, fightPoint), "</r>", formula);
            if (model.isSummonDragonLastAtkFamilyId == model.BossCityId)
            {
                txtAutoAtk.text = Language.Get("FairySiege036", Language.Get("FairySiege150"));
            }
            else
            {
                txtAutoAtk.text = model.isSummonDragonLastAtkFamilyId > 0 && model.TryGetFairySiegeFamilyInfo((uint)model.isSummonDragonLastAtkFamilyId, out var fairySiegeFamilyInfo) ? Language.Get("FairySiege036", fairySiegeFamilyInfo.Name) : Language.Get("FairySiege110");
            }
        }
 
        private void FlztClick()
        {
            var itemId = model.flztSkillItemId;
            var hasCnt = packModel.GetItemCountByID(PackType.Item, itemId);
            var needCnt = model.flztSkillNeedCnt;
 
            // 所需物品数量不足
            if (hasCnt < needCnt)
            {
                SysNotifyMgr.Instance.ShowTip("RealmLevelUpError_3");
                return;
            }
            //仅能攻击自己所在分组城池
            if (!model.TryGetNowBatTypeAndGroup(model.myFamilyID, out int myBattleType, out int myBattleGroup))
                return;
            if (model.showBatType != myBattleType || model.showBatGroup != myBattleGroup)
            {
                SysNotifyMgr.Instance.ShowTip("FairySiege20");
                return;
            }
 
            //没勾选自动攻击上次目标
            if (!model.isSummonDragonAutoAtk)
            {
                OpenSummonDragonChooseWin();
                return;
            }
 
            //修罗城
            if (model.TryGetBossCityData(model.showBatType, model.showBatGroup, out FairySiegeBatSceneCity bossCityData))
            {
                if (model.isSummonDragonLastAtkFamilyId == model.BossCityId)
                {
                    model.SendAtk(2, (uint)model.isSummonDragonLastAtkFamilyId, 0);
                    CloseClick();
                    return;
                }
            }
 
            //本地记录的仙盟Id不是当前组的
            if (!model.IsFamilyIdInCurrentMatchRound((uint)model.isSummonDragonLastAtkFamilyId))
            {
                model.isSummonDragonLastAtkFamilyId = 0;
                OpenSummonDragonChooseWin();
                return;
            }
 
            //本地记录的仙盟Id城池已被击毁
            if (!model.TryGetBatSceneCityInfo(model.showBatType, model.showBatGroup, (uint)model.isSummonDragonLastAtkFamilyId, out FairySiegeBatSceneCity batSceneCity) ||
                batSceneCity == null || batSceneCity.HP <= 0
                )
            {
                model.isSummonDragonLastAtkFamilyId = 0;
                OpenSummonDragonChooseWin();
                SysNotifyMgr.Instance.ShowTip("FairySiege08");
                return;
            }
 
            model.SendAtk(2, (uint)model.isSummonDragonLastAtkFamilyId, 0);
            CloseClick();
        }
 
        //打开选择攻击名单界面
        private void OpenSummonDragonChooseWin()
        {
            WindowCenter.Instance.Open<FairySiegeSummonDragonChooseWin>();
            WindowCenter.Instance.Close<FairySiegeSummonDragonWin>();
        }
 
        public bool IsCityAllDead()
        {
            if (model.TryGetBossCityData(model.showBatType, model.showBatGroup, out FairySiegeBatSceneCity bossCityData))
                return false;
            if (model.TryGetRegularCityDataList(model.showBatType, model.showBatGroup, out List<FairySiegeBatSceneCity> regularCityDataList))
            {
                // 0 未摧毁-默认状态 1 未摧毁-被攻击 2 已被摧毁
                foreach (var item in regularCityDataList)
                {
                    if (item.CityID == model.myFamilyID)
                        continue;
                    if (item.HP > 0)
                        return false;
                }
            }
            return true;
        }
 
        private void LtwjClick()
        {
            var itemId = model.ltwjSkillItemId;
            var hasCnt = packModel.GetItemCountByID(PackType.Item, itemId);
            var needCnt = model.ltwjSkillNeedCnt;
            // 所需物品数量不足
            if (hasCnt < needCnt)
            {
                SysNotifyMgr.Instance.ShowTip("RealmLevelUpError_3");
                return;
            }
            //所有城池都被击毁
            if (IsCityAllDead())
            {
                SysNotifyMgr.Instance.ShowTip("FairySiege19");
                return;
            }
            //仅能攻击自己所在分组城池
            if (!model.TryGetNowBatTypeAndGroup(model.myFamilyID, out int myBattleType, out int myBattleGroup))
                return;
            if (model.showBatType != myBattleType || model.showBatGroup != myBattleGroup)
            {
                SysNotifyMgr.Instance.ShowTip("FairySiege20");
                return;
            }
 
            model.SendAtk(3, 0, 0);
            CloseClick();
        }
 
        private void WatchClick()
        {
            model.isSummonDragonWatch = !model.isSummonDragonWatch;
            imgWatch.SetActive(model.isSummonDragonWatch);
        }
 
        private void AutoAtkClick()
        {
            model.isSummonDragonAutoAtk = !model.isSummonDragonAutoAtk;
            imgAutoAtk.SetActive(model.isSummonDragonAutoAtk);
        }
    }
}