少年修仙传客户端代码仓库
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
161
162
163
164
165
using System;
 
using UnityEngine;
using UnityEngine.UI;
 
namespace Snxxz.UI
{
    [XLua.Hotfix]
    public class DungeonGetXianYuanCoinsBehvaiour : MonoBehaviour
    {
        [SerializeField] Text getCoinsText;
        DungeonModel m_Model;
        DungeonModel model
        {
            get
            {
                return m_Model ?? (m_Model = ModelCenter.Instance.GetModel<DungeonModel>());
            }
        }
        DungeonAssistModel assistModel { get { return ModelCenter.Instance.GetModel<DungeonAssistModel>(); } }
        Window window = null;
        string xianYuanCoinsInfo = string.Empty;
        DungeonOpenTimeConfig dungeonOpenTime;
 
 
        private void OnEnable()
        {
            SetDisplay();
            GetParentWindow(this.transform);
            model.updateMissionEvent += SetDisplay;
            PlayerDatas.Instance.playerDataRefreshEvent += UpdateVipLv;
            WindowCenter.Instance.windowBeforeOpenEvent += BeforeOpen;
        }
 
        private void OnDisable()
        {
            model.updateMissionEvent -= SetDisplay;
            WindowCenter.Instance.windowBeforeOpenEvent -= BeforeOpen;
            PlayerDatas.Instance.playerDataRefreshEvent -= UpdateVipLv;
        }
       
        private void UpdateVipLv(PlayerDataType type)
        {
            if (type != PlayerDataType.VIPLv) return;
 
            SetDisplay();
        }
 
        public void SetDisplay()
        {
            dungeonOpenTime = DungeonOpenTimeConfig.Get(PlayerDatas.Instance.baseData.MapID);
            xianYuanCoinsInfo = string.Empty;
            if (dungeonOpenTime != null)
            {
                if (dungeonOpenTime.FBPoint != 0)
                {
                    UpdateSocialAdd();
                    string addRatio = string.Empty;
                    bool isVipAddRatio = assistModel.TryGetCurVipAddRatio(out addRatio);
                    if (isVipAddRatio)
                    {
                        xianYuanCoinsInfo = StringUtility.Contact(xianYuanCoinsInfo, "\n", Language.Get("DungeonAssist142", Language.Get("DungeonAssist143", addRatio)));
                    }
                    else
                    {
                        xianYuanCoinsInfo = StringUtility.Contact(xianYuanCoinsInfo, "\n", Language.Get("DungeonAssist142", Language.Get("Market_Text_33")));
                    }
                    getCoinsText.text = xianYuanCoinsInfo;
                    this.gameObject.SetActive(true);
                }
                else
                {
                    this.gameObject.SetActive(false);
                }
            }
            else
            {
                this.gameObject.SetActive(false);
            }
          
        }
 
        public void UpdateSocialAdd()
        {
            int addCoins = 0;
            var mission = model.mission;
            int mapId = PlayerDatas.Instance.baseData.MapID;
            MapConfig mapConfig = MapConfig.Get(mapId);
            if(mapConfig.MapFBType != 1)
            {
                bool isHelp = mission.isHelp == 1;
                if(mission.relation != null && mission.relation.Length > 1)
                {
                    addCoins = mission.relation[1];
                }
                if (!isHelp)
                {
                    if (addCoins > 0)
                    {
                        xianYuanCoinsInfo = Language.Get("DungeonAssist141", StringUtility.Contact(dungeonOpenTime.FBPoint, "+", addCoins));
                    }
                    else
                    {
                        xianYuanCoinsInfo = Language.Get("DungeonAssist141", dungeonOpenTime.FBPoint);
                    }
                }
                else
                {
                    int remainNum = 0;
                    bool isRemain = assistModel.TryGetRemainAssistNum(mapId, out remainNum);
                    if (isRemain)
                    {
                        if(addCoins > 0)
                        {
                            xianYuanCoinsInfo = Language.Get("DungeonAssist147", StringUtility.Contact(dungeonOpenTime.HelpPoint, "+", addCoins));
                        }
                        else
                        {
                            xianYuanCoinsInfo = Language.Get("DungeonAssist147", dungeonOpenTime.HelpPoint);
                        }
                       
                    }
                    else
                    {
                        xianYuanCoinsInfo = Language.Get("DungeonAssist147", StringUtility.Contact("+", 0));
                    }
                }
            }
            else
            {
                bool isAddCoins = assistModel.TryGetRewardAdd(out addCoins);
                if (isAddCoins)
                {
                    xianYuanCoinsInfo = Language.Get("DungeonAssist141", StringUtility.Contact(dungeonOpenTime.FBPoint, "+", addCoins));
                }
                else
                {
                    xianYuanCoinsInfo = Language.Get("DungeonAssist141", dungeonOpenTime.FBPoint);
                }
            }
         
        }
 
        public void GetParentWindow(Transform obj)
        {
           var _window = obj.GetComponent<Window>();
            if(_window == null)
            {
                var parent = obj.transform.parent;
                GetParentWindow(parent);
            }
            else
            {
                this.window = _window;
            }
        }
 
        private void BeforeOpen(Window win)
        {
            if (window == null || win != window) return;
 
            SetDisplay();
        }
    }
}