hch
2 天以前 f2c78eecd49edc328225b77492e7f45e157bad02
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
using System;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
 
 
//自动淘金选项
public class GoldRushAutoCell : CellView
{
    [SerializeField] Toggle autoToggle;
    [SerializeField] ItemCell itemCell;
    [SerializeField] Text nameText;
    [SerializeField] CountControler countControler;
 
    [SerializeField] Transform lockGo;
    [SerializeField] Text lockText;
 
    int arrIndex;
    int itemLV;
    public void Display(int _index)
    {
        arrIndex = _index;
        int itemID = GoldRushManager.Instance.autoRefreshItemIDs[arrIndex];
        itemLV = GoldRushManager.Instance.GetAutoItemLV(arrIndex);
        bool isOn = itemLV > 0;
        itemLV = itemLV > 0 ? itemLV : 1;
        if (IsLock(itemID, out int funcID))
        {
            lockGo.SetActive(true);
            lockText.text = Language.Get("L1038", FuncOpenLVConfig.Get(funcID).Name);
            countControler.SetActive(false);
            autoToggle.SetActive(false);
        }
        else
        {
            lockGo.SetActive(false);
            countControler.SetActive(true);
            autoToggle.SetActive(true);
            autoToggle.onValueChanged.AddListener((value) =>
            {
                autoToggle.isOn = value;
                GoldRushManager.Instance.SetAutoItemLV(arrIndex, value ? itemLV : 0);
            });
            autoToggle.isOn = isOn;
            countControler.Init(ChangeWorkerCount, GoldRushItemConfig.maxLVDic[itemID], itemLV,
            AddWorker, DecWorker, Language.Get("L1113"));
        }
 
        var config = GoldRushItemConfig.GetConfig(itemID, itemLV);
        if (config == null)
        {
            return;
        }
        itemCell.Init(new ItemCellModel(itemID, false, config.ItemCount));
        itemCell.button.AddListener(() =>
        {
            ItemTipUtility.Show(itemID);
        });
 
        nameText.text = GoldRushManager.Instance.GetCampItemName(config);
 
 
    }
 
 
    bool IsLock(int itemID, out int funcID)
    {
        funcID = 0;
        if (GoldRushManager.Instance.itemIDUnLockFuncIDDict.ContainsKey(itemID))
        {
            funcID = GoldRushManager.Instance.itemIDUnLockFuncIDDict[itemID];
            if (!FuncOpen.Instance.IsFuncOpen(funcID))
            {
                return true;
            }
 
            return false;
        }
        return false;
    }
 
    void ChangeWorkerCount(int lv)
    {
        itemLV = lv;
        if (!autoToggle.isOn)
        {
            return;
        }
        if (lv == GoldRushManager.Instance.GetAutoItemLV(arrIndex))
        {
            return;
        }
        GoldRushManager.Instance.SetAutoItemLV(arrIndex, lv);
    }
 
    bool AddWorker(int lv)
    {
        return true;
    }
 
    bool DecWorker(int count)
    {
        if (count <= 1)
        { 
            return false;
        }
        return true;
    }
 
 
}