少年修仙传客户端代码仓库
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
//--------------------------------------------------------
//    [Author]:           第二世界
//    [  Date ]:           Tuesday, September 12, 2017
//--------------------------------------------------------
 
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
 
using vnxbqy.UI;
 
namespace vnxbqy.UI
{
    public class DungeonSweepWin : Window
    {
        [SerializeField] ItemBehaviour m_DungeonTicket;
        [SerializeField] ItemBehaviour m_SweepCost;
        [SerializeField] Button m_Cancel;
        [SerializeField] Button m_Confirm;
        [SerializeField] Button m_Close;
 
        DungeonModel model { get { return ModelCenter.Instance.GetModel<DungeonModel>(); } }
        PackModel playerPack { get { return ModelCenter.Instance.GetModel<PackModel>(); } }
 
        #region Built-in
        protected override void BindController()
        {
        }
 
        protected override void AddListeners()
        {
            m_Confirm.AddListener(ConfirmSweepResult);
            m_Cancel.AddListener(CloseClick);
            m_Close.AddListener(CloseClick);
        }
 
        protected override void OnPreOpen()
        {
            DisplayTicket();
            DisplaySweepCost();
        }
 
        protected override void OnAfterOpen()
        {
        }
 
        protected override void OnPreClose()
        {
        }
 
        protected override void OnAfterClose()
        {
        }
        #endregion
 
        private void DisplayTicket()
        {
            var tickets = model.GetTicketCost(model.currentDungeon.mapId, model.currentDungeon.lineId);
            if (tickets.id > 0)
            {
                m_DungeonTicket.SetItem(tickets);
                m_DungeonTicket.SetActive(true);
            }
            else
            {
                m_DungeonTicket.SetActive(false);
            }
        }
 
        private void DisplaySweepCost()
        {
            var cost = model.GetSweepCost(model.currentDungeon);
            m_SweepCost.SetItem(cost);
        }
 
        private void ConfirmSweepResult()
        {
            var error = 0;
            if (TestSweep(out error))
            {
                model.RequestSweep(model.currentDungeon);
            }
            else
            {
                switch (error)
                {
                    case 1:
                        DebugEx.Log("副本评级不足");
                        break;
                    case 2:
                        var tickets = model.GetTicketCost(model.currentDungeon.mapId, model.currentDungeon.lineId);
                        ItemTipUtility.Show(tickets.id);
                        break;
                    case 3:
                        var cost = model.GetSweepCost(model.currentDungeon);
                        var itemOwn = playerPack.GetItemCountByID(PackType.Item, cost.id);
                        var moneyNeed = GeneralDefine.autoBuyItemPrices[0] * (cost.count - itemOwn);
                        ConfirmCancel.ShowPopConfirm(
                          Language.Get("Mail101"),
                          Language.Get("MultipleSweep_Text3", cost.count - itemOwn, moneyNeed),
                          (bool _ok) =>
                          {
                              if (_ok)
                              {
                                  var moneyOwn = PlayerDatas.Instance.baseData.diamond ;
                                  if (moneyNeed > moneyOwn)
                                  {
                                      WindowCenter.Instance.Open<RechargeTipWin>();
                                  }
                                  else
                                  {
                                      model.RequestSweep(model.currentDungeon);
                                  }
                              }
                          }
                          );
 
                        break;
                    case 4:
                        WindowCenter.Instance.Open<DungeonBuyTimesWin>();
                        break;
                    case 5:
                        SysNotifyMgr.Instance.ShowTip("SweepFB_1");
                        break;
                }
            }
        }
 
        private bool TestSweep(out int error)
        {
            var dataMapId = model.GetDataMapIdByMapId(PlayerDatas.Instance.baseData.MapID);
            if (dataMapId == model.currentDungeon.mapId)
            {
                error = 5;
                return false;
            }
 
            var grade = model.GetGrade(model.currentDungeon);
            if (grade <= 0)
            {
                error = 1;
                return false;
            }
 
            var tickets = model.GetTicketCost(model.currentDungeon.mapId, model.currentDungeon.lineId);
            var ticketsOwn = playerPack.GetItemCountByID(PackType.Item, tickets.id);
            if (ticketsOwn < tickets.count)
            {
                error = 2;
                return false;
            }
 
            var cost = model.GetSweepCost(model.currentDungeon);
            var itemOwn = playerPack.GetItemCountByID(PackType.Item, cost.id);
            if (itemOwn < cost.count)
            {
                error = 3;
                return false;
            }
 
            var enterTimes = model.GetEnterTimes(model.currentDungeon.mapId);
            var totalTimes = model.GetTotalTimes(model.currentDungeon.mapId);
            var surplusTimes = totalTimes - enterTimes;
            if (surplusTimes <= 0)
            {
                error = 4;
                return false;
            }
 
            error = 0;
            return true;
        }
 
    }
 
}