| 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; | 
|     int itemID; | 
|     public void Display(int _index) | 
|     { | 
|         arrIndex = _index; | 
|         itemID = GoldRushManager.Instance.autoRefreshItemIDs[arrIndex]; | 
|         itemLV = GoldRushManager.Instance.GetAutoItemLV(arrIndex); | 
|         bool isOn = itemLV > 0; | 
|         itemLV = itemLV > 0 ? itemLV : 1; | 
|         if (GoldRushManager.Instance.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); | 
|   | 
|   | 
|     } | 
|   | 
|   | 
|   | 
|   | 
|     void ChangeWorkerCount(int lv) | 
|     { | 
|         itemLV = lv; | 
|         var config = GoldRushItemConfig.GetConfig(itemID, itemLV); | 
|         itemCell.Init(new ItemCellModel(itemID, false, config.ItemCount)); | 
|         nameText.text = GoldRushManager.Instance.GetCampItemName(config); | 
|         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; | 
|     } | 
|   | 
|   | 
| } |