少年修仙传客户端代码仓库
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
//--------------------------------------------------------
//    [Author]:           第二世界
//    [  Date ]:           Tuesday, December 18, 2018
//--------------------------------------------------------
 
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
 
namespace Snxxz.UI
{
    [XLua.Hotfix]
    public class GatherSoulGenerateBossWin : Window
    {
        [SerializeField] Text m_Label;
        [SerializeField] Toggle m_AutoGenerate;
        [SerializeField] Button m_Confirm;
        [SerializeField] Button m_Cancel;
        [SerializeField] Button m_Close;
 
        GatherSoulDungeonModel model {
            get { return ModelCenter.Instance.GetModel<GatherSoulDungeonModel>(); }
        }
 
        bool autoGenerate = false;
 
        #region Built-in
        protected override void BindController()
        {
        }
 
        protected override void AddListeners()
        {
            m_Close.onClick.AddListener(CloseClick);
            m_Cancel.onClick.AddListener(CloseClick);
            m_Confirm.onClick.AddListener(Confirm);
        }
 
        protected override void OnPreOpen()
        {
            model.missionHelpUpdate += MissionHelpUpdate;
            m_AutoGenerate.isOn = model.mission.isAuto == 1;
            Display();
        }
 
        protected override void OnAfterOpen()
        {
        }
 
        protected override void OnPreClose()
        {
            model.missionHelpUpdate -= MissionHelpUpdate;
        }
 
        protected override void OnAfterClose()
        {
        }
        #endregion
 
        void Display()
        {
            DisplayLabel();
        }
 
        void DisplayLabel()
        {
            var mission = model.mission;
            if (mission.hasRefreshBoss == 1)
            {
                m_Label.text = Language.Get("GatherSoulAreadyGenerateBoss");
            }
            else
            {
                m_Label.text = Language.Get("GatherSoulGenerateBoss", model.generateBossCost);
            }
        }
 
        private void Confirm()
        {
            var mission = model.mission;
            if (mission.hasRefreshBoss == 1)
            {
                if (m_AutoGenerate.isOn == (mission.isAuto == 1))
                {
                    CloseClick();
                }
                else
                {
                    if (m_AutoGenerate.isOn)
                    {
                        var weelCount = model.dungeonWeelCount - mission.wheel;
                        ConfirmCost(weelCount);
                    }
                    else
                    {
                        CA508_tagCMDoFBAction pak = new CA508_tagCMDoFBAction();
                        pak.ActionType = 2;
                        pak.ActionInfo = 2;
                        GameNetSystem.Instance.SendInfo(pak);
                        CloseClick();
                    }
                }
            }
            else
            {
                var weelCount = m_AutoGenerate.isOn ? (model.dungeonWeelCount - mission.wheel + 1) : 1;
                ConfirmCost(weelCount);
            }
        }
 
        void ConfirmCost(int weelCount)
        {
            var cost = weelCount * model.generateBossCost;
            if (weelCount == 0)
            {
                CloseClick();
                return;
            }
            if (UIHelper.GetMoneyCnt(1) >= (ulong)cost)
            {
                CA508_tagCMDoFBAction pak = new CA508_tagCMDoFBAction();
                pak.ActionType = 2;
                pak.ActionInfo = m_AutoGenerate.isOn ? (uint)1 : 0;
                GameNetSystem.Instance.SendInfo(pak);
                CloseClick();
            }
            else
            {
                CloseClick();
                WindowCenter.Instance.Open<RechargeTipWin>();
            }
        }
 
        private void MissionHelpUpdate()
        {
            DisplayLabel();
        }
    }
 
}