hch
2 天以前 7222adcc97941b57a61f0f8e8469f0f66b9ee1a1
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
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
 
 
//淘金中信息列表显示
public class GoldRushWorkCell : CellView
{
    [SerializeField] Transform _cell;
    [SerializeField] ItemCell itemCell;
    [SerializeField] Text nameText;
    [SerializeField] Text timeText;
    [SerializeField] Slider slider;
    [SerializeField] UIHeroController[] heroModels;
    [SerializeField] CountControler countControler;
    [SerializeField] Button awardBtn;
 
    GoldRushItemConfig config;
    int campID;
    //派遣中的队列 + 完成的队列,动态变化的
    //ID组成
    // 派遣中类型1*100000 + campid*100 + 0
    // 完成类型2*100000 + goldid*100 + 索引
    public void Display(int missionID)
    {
        if (missionID == -1)
        { 
            _cell.SetActive(false);
            return;
        }
        _cell.SetActive(true);
        int type = missionID / 100000;
        int targetID = missionID / 100 % 1000;
        int index = missionID % 100;
 
        campID = 0;
        int goldID = targetID;
 
        if (type == 1)
        {
            campID = targetID;
            goldID = GoldRushManager.Instance.GetCampGoldID(campID);
        }
        if (goldID == 0)
        {
            this.SetActive(false);
            return;
        }
 
        config = GoldRushItemConfig.Get(goldID);
        int itemID = config.ItemID;
        itemCell.Init(new ItemCellModel(itemID, false, config.ItemCount));
        itemCell.button.AddListener(()=>
        {
            ItemTipUtility.Show(itemID);
        });
 
        nameText.text = GoldRushManager.Instance.GetCampItemName(config);
        var endTime = GoldRushManager.Instance.GetCampEndTime(campID);
 
        if (type == 1)
        {
            if (endTime != 0)
            {
                timeText.text = TimeUtility.SecondsToMS(endTime - TimeUtility.AllSeconds);
                //按原总时长当进度条
                slider.value = (config.NeedSeconds - (endTime - TimeUtility.AllSeconds)) / (float)config.NeedSeconds;
            }
            countControler.SetActive(true);//此处调整+/-会实时发包
            countControler.Init(ChangeWorkerCount, config.WorkerMax, GoldRushManager.Instance.GetCampWorkerCnt(campID), AddWorker, DecWorker);
            awardBtn.SetActive(false);
            var workCnt = GoldRushManager.Instance.GetCampWorkerCnt(campID);
            int skinCnt = GoldRushManager.Instance.skinIDs.Count;
            for (int i = 0; i < heroModels.Length; i++)
            {
                if (i < workCnt)
                {
                    heroModels[i].SetActive(true);
                    var skinID = GoldRushManager.Instance.skinIDs[(goldID % skinCnt + i) % skinCnt];
                    heroModels[i].Create(skinID, 0.5f);
                }
                else
                {
                    heroModels[i].SetActive(false);
                }
            }
 
        }
        else if (type == 2)
        {
            countControler.SetActive(false);
            awardBtn.SetActive(true);
            timeText.text = Language.Get("L1036");
            slider.value = slider.maxValue;
 
            awardBtn.AddListener(() =>
            {
                GoldRushManager.Instance.SendGoldRushWarehouseAward(index, 0);
            });
        }
            
 
    }
 
 
    void ChangeWorkerCount(int count)
    {
        //重新调整监工
        AssignWorker(count);
    }
 
    bool AddWorker(int count)
    {
        if (count >= config.WorkerMax)
        {
            return false;
        }
 
        //可派遣的监工: 空闲监工数+当前监工数
        if (count + 1 > GoldRushManager.Instance.GetEmptyWorkerCount() + GoldRushManager.Instance.GetCampWorkerCnt(campID))
        { 
            SysNotifyMgr.Instance.ShowTip("GoldRush2");
            return false;
        }
 
        return true;
    }
 
    bool DecWorker(int count)
    {
        if (count <= 1)
        { 
            ConfirmCancel.ShowPopConfirm(Language.Get("Mail101"),
            Language.Get("GoldRush38"), (bool isOK) =>
                {
                    if (isOK)
                    {
                        //撤回监工
                        GoldRushManager.Instance.SendGoldRushOP(3, campID, 0);
                    }
                });
            return false;
        }
        return true;
    }
 
    void AssignWorker(int workerCount)
    {
        if (workerCount == 0)
        {
            return;
        }
 
        if (workerCount > config.WorkerMax)
        {
            return;
        }
 
        if (workerCount == GoldRushManager.Instance.GetCampWorkerCnt(campID))
        {
            return;
        }
 
        GoldRushManager.Instance.SendGoldRushOP(2, campID, workerCount);
        SysNotifyMgr.Instance.ShowTip("GoldRush1");
    }
 
 
}