hch
昨天 18fe79ffe26f3591c322701001a73d4270e9d931
197 子 【内政】淘金系统 / 【内政】淘金系统-客户端
6个文件已修改
2 文件已重命名
437 ■■■■■ 已修改文件
Main/System/HeroUI/HeroSkinModel.cs 3 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Main/System/HeroUI/HeroSkinModel.cs.meta 补丁 | 查看 | 原始文档 | blame | 历史
Main/System/InternalAffairs/AffairBaseWin.cs 9 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Main/System/InternalAffairs/GoldRushManager.cs 43 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Main/System/InternalAffairs/GoldRushRefreshWin.cs 9 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Main/System/InternalAffairs/GoldRushWorkCell.cs 154 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Main/System/InternalAffairs/GoldRushWorkerCell.cs 68 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Main/System/InternalAffairs/GoldRushWorkerWin.cs 151 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Main/System/HeroUI/HeroSkinModel.cs
File was renamed from Main/System/HeroUI/HeroModel.cs
@@ -1,11 +1,14 @@
using UnityEngine;
//武将外观配置
public class HeroModel : MonoBehaviour
{
    [SerializeField] UIHeroController heroModel;
    public int heroSkinID = 0;
    public float scale = 1;
    public string actionName = "idle";
    [Header("初始是否可见")]
    public bool enable = true;
Main/System/HeroUI/HeroSkinModel.cs.meta
Main/System/InternalAffairs/AffairBaseWin.cs
@@ -43,7 +43,6 @@
    protected override void OnPreOpen()
    {
        GoldRushManager.Instance.OnGoldRushCampEvent += OnGoldRushCampEvent;
        GoldRushManager.Instance.OnGoldRushInfoEvent += OnGoldRushInfoEvent;
        GoldRushManager.Instance.OnAutoWorkingEvent += OnAutoWorkingEvent;
        GlobalTimeEvent.Instance.secondEvent += OnSecondEvent;
@@ -54,7 +53,6 @@
    protected override void OnPreClose()
    {
        GoldRushManager.Instance.OnGoldRushCampEvent -= OnGoldRushCampEvent;
        GoldRushManager.Instance.OnGoldRushInfoEvent -= OnGoldRushInfoEvent;
        GoldRushManager.Instance.OnAutoWorkingEvent -= OnAutoWorkingEvent;
        GlobalTimeEvent.Instance.secondEvent -= OnSecondEvent;
@@ -63,18 +61,15 @@
    void Display()
    {
        fullGoldRush.SetActive(GoldRushManager.Instance.GetWarehouseCnt() >= GoldRushManager.Instance.maxWorkerCount);
        fullGoldRush.SetActive(GoldRushManager.Instance.GetFinishGoldRushCount() >= GoldRushManager.Instance.warehouseMaxCnt);
        RefreshGoldRushMoney();
        autoText.text = Language.Get(GoldRushManager.Instance.isAutoWorking ? "GoldRush34" : "GoldRush24");
    }
    void OnGoldRushCampEvent(int campID)
    {
    }
    void OnGoldRushInfoEvent()
    {
        fullGoldRush.SetActive(GoldRushManager.Instance.GetWarehouseCnt() >= GoldRushManager.Instance.maxWorkerCount);
        fullGoldRush.SetActive(GoldRushManager.Instance.GetFinishGoldRushCount() >= GoldRushManager.Instance.warehouseMaxCnt);
    }
    void OnSecondEvent()
Main/System/InternalAffairs/GoldRushManager.cs
@@ -12,7 +12,7 @@
    public int panningCnt;  //累计总次数
    public int lastRecoverTime;  // 上次免费恢复淘金令时间戳,为0时可不用倒计时
    public int housekeeperEndTime;   // 自动管家到期时间戳,有值同时也代表免费试用已使用
    public byte[] warehouseIDList;
    public byte[] warehouseIDList;  //完成的,包含0空,主要用于领取的索引
    public Dictionary<int, HB037_tagSCGoldRushCampInfo.tagSCGoldRushCamp> campInfoDict = new Dictionary<int, HB037_tagSCGoldRushCampInfo.tagSCGoldRushCamp>();
    public event Action<int> OnGoldRushCampEvent;    //服务端通知营地信息
@@ -26,7 +26,7 @@
    public const int followWorkerCount = 3;   //小兵的数量,非监工
    int m_MaxWorkerCount;   //配表的最大数量
    public int m_MaxWorkerCount;   //配表的最大数量
    //监工的数量,解锁影响
    public int maxWorkerCount
    {
@@ -456,8 +456,22 @@
        return false;
    }
    //获取已完成的营地数量
    public int GetFinishGoldRushCount()
    {
        int cnt = 0;
        foreach (var id in warehouseIDList)
        {
            if (id != 0)
            {
                ++cnt;
            }
        }
        return cnt;
    }
    //检查是否有可解锁的营地
    bool CheckCanUnLockCamp()
        bool CheckCanUnLockCamp()
    {
        foreach (var campID in GoldRushCampConfig.GetKeys())
        {
@@ -512,6 +526,29 @@
    }
    //0 已解锁 1 等级锁 2 金钱锁
    public int GetWorkerLockState(int workerID)
    {
        if (IsWorkerUnLock(workerID))
        {
            return 0;
        }
        var config = GoldRushWorkerConfig.Get(workerID);
        if (config.PlayerLVUnlock != 0)
        {
            return 1;
        }
        if (config.MoneyUnlock.Length != 0)
        {
            return 2;
        }
        return 0;
    }
    //自动淘金 先填充营地 再填充多个监工
    void SetAutoWorking(bool _isOpenAuto, bool _isAutoWorking)
Main/System/InternalAffairs/GoldRushRefreshWin.cs
@@ -64,7 +64,12 @@
        config = GoldRushItemConfig.Get(goldID);
        int emptyCnt = GoldRushManager.Instance.GetEmptyWorkerCount();
        itemCell.Init(new ItemCellModel(config.ItemID, false, config.ItemCount));
        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(GoldRushManager.Instance.selectCampID);
        if (endTime == 0)
@@ -216,6 +221,7 @@
        }
        GoldRushManager.Instance.SendGoldRushOP(2, GoldRushManager.Instance.selectCampID, workerCount);
        SysNotifyMgr.Instance.ShowTip("GoldRush6");
        CloseWindow();
    }
@@ -264,6 +270,7 @@
        {
            //调整监工
            GoldRushManager.Instance.SendGoldRushOP(2, GoldRushManager.Instance.selectCampID, workerCount);
            SysNotifyMgr.Instance.ShowTip("GoldRush1");
            CloseWindow();
        }
    }
Main/System/InternalAffairs/GoldRushWorkCell.cs
@@ -6,12 +6,164 @@
//淘金中信息列表显示
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.4f);
                }
                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");
    }
}
Main/System/InternalAffairs/GoldRushWorkerCell.cs
@@ -6,9 +6,73 @@
//淘金工人的列表显示
public class GoldRushWorkerCell : CellView
{
    [SerializeField] Button tentBtn;
    [SerializeField] Text nameText;
    [SerializeField] UIHeroController heroModel;
    [SerializeField] Transform lockRect;
    [SerializeField] Transform lockLVRect;
    [SerializeField] Text lockLVText;
    [SerializeField] Button unLockBtn;
    [SerializeField] Button lockMoneyBtn;
    [SerializeField] Text lockMoneyText;
    [SerializeField] Image lockMoneyIcon;
    public void Display(int workerID)
    {
        var config = GoldRushWorkerConfig.Get(workerID);
        nameText.text = config.Name;
        heroModel.Create(config.SkinID, 0.7f);
        var lockState = GoldRushManager.Instance.GetWorkerLockState(workerID);
        if (lockState == 0)
        {
            lockRect.SetActive(false);
        }
        else if (lockState == 1)
        {
            lockRect.SetActive(true);
            int lockLV = config.PlayerLVUnlock;
            if (PlayerDatas.Instance.baseData.LV < lockLV)
            {
                lockLVRect.SetActive(true);
                lockLVText.text = Language.Get("L1037", lockLV);
            }
            else
            {
                unLockBtn.SetActive(true);
                unLockBtn.AddListener(() =>
                {
                    if (PlayerDatas.Instance.baseData.LV < lockLV)
                        return;
                    GoldRushManager.Instance.SendGoldRushUnlock(1, workerID);
                });
            }
            lockMoneyBtn.SetActive(false);
        }
        else if (lockState == 2)
        {
            lockRect.SetActive(true);
            lockLVRect.SetActive(false);
            unLockBtn.SetActive(false);
            lockMoneyBtn.SetActive(true);
            lockMoneyIcon.SetIconWithMoneyType(config.MoneyUnlock[0]);
            lockMoneyText.text = config.MoneyUnlock[1].ToString();
            lockMoneyBtn.AddListener(() =>
            {
                ConfirmCancel.MoneyIconToggleConfirmByType(ToggleCheckType.GoldRush, config.MoneyUnlock[1], config.MoneyUnlock[0],
                    Language.Get("GoldRush36", UIHelper.GetIconNameWithMoneyType(config.MoneyUnlock[0]), config.MoneyUnlock[1]), () =>
                        {
                            if (!UIHelper.CheckMoneyCount(config.MoneyUnlock[0], config.MoneyUnlock[1], 2))
                            {
                                return;
                            }
                            GoldRushManager.Instance.SendGoldRushUnlock(1, workerID);
                        });
            });
        }
    }
}
Main/System/InternalAffairs/GoldRushWorkerWin.cs
@@ -1,4 +1,6 @@
using System;
using System.Collections.Generic;
using System.Linq;
using Cysharp.Threading.Tasks;
using UnityEngine;
using UnityEngine.UI;
@@ -27,17 +29,26 @@
    [SerializeField] Text unlockWorkerCntText;  //解锁监工数量
    [SerializeField] Text totalWorkFinishCount; //淘金完成总次数
    [NonSerialized] public List<int> goldRushMissionList = new List<int>();
    protected override void InitComponent()
    {
        workMgrBtn.AddListener(OnWorkMgrBtnClick);
        workersBtn.AddListener(OnWorkerBtnClick);
        getAllAwardBtn.AddListener(GetAllAward);
    }
    protected override void OnPreOpen()
    {
        CreateManagerScroller();
        CreateWorkersScroller();
        GoldRushManager.Instance.OnGoldRushCampEvent += OnGoldRushCampEvent;
        GoldRushManager.Instance.OnGoldRushInfoEvent += OnGoldRushInfoEvent;
        workMgrScroller.OnRefreshCell += OnRefreshWorkMgrCell;
        workersScroller.OnRefreshCell += OnRefreshWorkersCell;
        GlobalTimeEvent.Instance.secondEvent += OnSecondEvent;
        if (functionOrder == 0)
        {
@@ -52,6 +63,11 @@
    protected override void OnPreClose()
    {
        GoldRushManager.Instance.OnGoldRushCampEvent -= OnGoldRushCampEvent;
        GoldRushManager.Instance.OnGoldRushInfoEvent -= OnGoldRushInfoEvent;
        workMgrScroller.OnRefreshCell -= OnRefreshWorkMgrCell;
        workersScroller.OnRefreshCell -= OnRefreshWorkersCell;
        GlobalTimeEvent.Instance.secondEvent -= OnSecondEvent;
    }
@@ -59,6 +75,7 @@
    {
        if (functionOrder == 0)
        {
            RefreshWorkingList();
            DispalyWorkMgr();
        }
        else
@@ -67,16 +84,126 @@
        }
    }
    //派遣中管理
    void DispalyWorkMgr()
    {
        workMgrRect.SetActive(true);
        workersRect.SetActive(false);
        int workingCnt = GoldRushManager.Instance.GetWarehouseCnt();
        if (workingCnt == 0)
        {
            workMgrScroller.SetActive(false);
            workMgrEmpty.SetActive(true);
            getAllAwardBtn.SetActive(false);
        }
        else
        {
            workMgrScroller.SetActive(true);
            workMgrEmpty.SetActive(false);
            getAllAwardBtn.SetActive(true);
        }
        lazyWorkerCntText.text = Language.Get("GoldRush20") + GoldRushManager.Instance.GetEmptyWorkerCount() + "/" + GoldRushManager.Instance.maxWorkerCount;
        warehouseCntText.text = Language.Get("GoldRush21") + workingCnt + "/" + GoldRushManager.Instance.warehouseMaxCnt;
        workMgrScroller.m_Scorller.RefreshActiveCellViews();
    }
    //派遣中的队列 + 完成的队列,动态变化的
    void CreateManagerScroller()
    {
        workMgrScroller.Refresh();
        for (int i = 0; i < GoldRushManager.Instance.warehouseMaxCnt; ++i)
        {
            workMgrScroller.AddCell(ScrollerDataType.Header, i);
        }
        workMgrScroller.Restart();
    }
    //派遣中的队列 + 完成的队列,动态变化的
    //ID组成
    // 派遣中类型1*100000 + campid*100 + 0
    // 完成类型2*100000 + goldid*100 + 索引
    void RefreshWorkingList()
    {
        goldRushMissionList.Clear();
        var keys = GoldRushManager.Instance.campInfoDict.Keys.ToList();
        for (int i = 0; i < keys.Count; i++)
        {
            var campInfo = GoldRushManager.Instance.campInfoDict[keys[i]];
            if (campInfo.GoldID == 0 || campInfo.EndTime == 0)
            {
                continue;
            }
            goldRushMissionList.Add(100000 * 1 + campInfo.CampID * 100 + 0);
        }
        for (int i = 0; i < GoldRushManager.Instance.warehouseIDList.Length; i++)
        {
            if (GoldRushManager.Instance.warehouseIDList[i] == 0)
            {
                continue;
            }
            goldRushMissionList.Add(100000 * 2 + GoldRushManager.Instance.warehouseIDList[i] * 100 + i);
        }
    }
    void OnRefreshWorkMgrCell(ScrollerDataType type, CellView cell)
    {
        var _cell = cell as GoldRushWorkCell;
        if (cell.index >= goldRushMissionList.Count)
        {
            _cell.Display(-1);
        }
        else
        {
            _cell.Display(goldRushMissionList[cell.index]);
        }
    }
    void OnSecondEvent()
    {
        if (functionOrder == 0)
        {
            workMgrScroller.m_Scorller.RefreshActiveCellViews();
        }
    }
    void DispalyWorkers()
    {
        workMgrRect.SetActive(false);
        workersRect.SetActive(true);
        unlockWorkerCntText.text = Language.Get("GoldRush39") + GoldRushManager.Instance.maxWorkerCount + "/" + GoldRushManager.Instance.m_MaxWorkerCount;
        totalWorkFinishCount.text = Language.Get("GoldRush40") + GoldRushManager.Instance.panningCnt;
        workersScroller.m_Scorller.RefreshActiveCellViews();
    }
    void CreateWorkersScroller()
    {
        workersScroller.Refresh();
        var keys = GoldRushWorkerConfig.GetKeys().ToList();
        for (int i = 0; i < keys.Count; ++i)
        {
            workersScroller.AddCell(ScrollerDataType.Header, keys[i]);
        }
        workersScroller.Restart();
    }
    void OnRefreshWorkersCell(ScrollerDataType type, CellView cell)
    {
        var _cell = cell as GoldRushWorkerCell;
        _cell.Display(cell.index);
    }
    void OnWorkMgrBtnClick()
@@ -84,11 +211,31 @@
        functionOrder = 0;
        Display();
    }
    void OnWorkerBtnClick()
    {
        functionOrder = 1;
        Display();
    }
    void GetAllAward()
    {
        if (GoldRushManager.Instance.GetFinishGoldRushCount() == 0)
        {
            return;
        }
        GoldRushManager.Instance.SendGoldRushWarehouseAward(0, 1);
    }
    void OnGoldRushCampEvent(int campID)
    {
        Display();
    }
    void OnGoldRushInfoEvent()
    {
        Display();
    }
}