| | |
| | | using UnityEngine.UI; |
| | | |
| | | /// <summary> |
| | | /// 内政 |
| | | /// 内政 - 基本用于淘金 |
| | | /// </summary> |
| | | public class AffairBaseWin : UIBase |
| | | { |
| | | [SerializeField] Button bagBtn; |
| | | |
| | | //淘金相关 |
| | | [SerializeField] GameObject fullGoldRush; |
| | | [SerializeField] Image goldRushIcon; |
| | | [SerializeField] Text goldRushCountText; |
| | | [SerializeField] Button goldRushItemBtn; |
| | | [SerializeField] Image goldRushItemProcess; |
| | | [SerializeField] Text autoText; |
| | | [SerializeField] GameObject flowAutoEffect; |
| | | [SerializeField] Button autoBtn; |
| | | |
| | | protected override void InitComponent() |
| | | { |
| | | bagBtn.AddListener(() => |
| | | { |
| | | UIManager.Instance.OpenWindow<RolePackWin>(); |
| | | } |
| | | { |
| | | UIManager.Instance.OpenWindow<RolePackWin>(); |
| | | } |
| | | ); |
| | | |
| | | goldRushIcon.SetIconWithMoneyType(52); |
| | | goldRushItemBtn.AddListener(() => |
| | | { |
| | | ItemTipUtility.ShowMoneyTip(52, false); |
| | | } |
| | | ); |
| | | autoBtn.AddListener(() => |
| | | { |
| | | // UIManager.Instance.OpenWindow<RolePackWin>(); |
| | | } |
| | | ); |
| | | } |
| | | |
| | | protected override void OnPreOpen() |
| | | { |
| | | GoldRushManager.Instance.OnGoldRushCampEvent += OnGoldRushCampEvent; |
| | | GoldRushManager.Instance.OnGoldRushInfoEvent += OnGoldRushInfoEvent; |
| | | GoldRushManager.Instance.OnAutoWorkingEvent += OnAutoWorkingEvent; |
| | | GlobalTimeEvent.Instance.secondEvent += OnSecondEvent; |
| | | PlayerDatas.Instance.playerDataRefreshEvent += PlayerDataRefreshEvent; |
| | | Display(); |
| | | GoldRushManager.Instance.GetAllAward(); |
| | | } |
| | | |
| | | protected override void OnPreClose() |
| | | { |
| | | GoldRushManager.Instance.OnGoldRushCampEvent -= OnGoldRushCampEvent; |
| | | GoldRushManager.Instance.OnGoldRushInfoEvent -= OnGoldRushInfoEvent; |
| | | GoldRushManager.Instance.OnAutoWorkingEvent -= OnAutoWorkingEvent; |
| | | GlobalTimeEvent.Instance.secondEvent -= OnSecondEvent; |
| | | PlayerDatas.Instance.playerDataRefreshEvent -= PlayerDataRefreshEvent; |
| | | } |
| | | |
| | | void Display() |
| | | { |
| | | fullGoldRush.SetActive(GoldRushManager.Instance.GetWarehouseCnt() >= GoldRushManager.Instance.maxWorkerCount); |
| | | RefreshGoldRushMoney(); |
| | | autoText.text = Language.Get(GoldRushManager.Instance.isAutoWorking ? "GoldRush34" : "GoldRush24"); |
| | | } |
| | | |
| | | void OnGoldRushCampEvent(int campID) |
| | | { |
| | | } |
| | | |
| | | void OnGoldRushInfoEvent() |
| | | { |
| | | fullGoldRush.SetActive(GoldRushManager.Instance.GetWarehouseCnt() >= GoldRushManager.Instance.maxWorkerCount); |
| | | } |
| | | |
| | | void OnSecondEvent() |
| | | { |
| | | RefreshGoldRushMoney(); |
| | | } |
| | | |
| | | void OnAutoWorkingEvent() |
| | | { |
| | | if (GoldRushManager.Instance.isAutoWorking) |
| | | { |
| | | autoText.text = Language.Get("GoldRush34"); |
| | | flowAutoEffect.SetActive(true); |
| | | |
| | | } |
| | | else |
| | | { |
| | | autoText.text = Language.Get("GoldRush24"); |
| | | flowAutoEffect.SetActive(false); |
| | | } |
| | | } |
| | | |
| | | void RefreshGoldRushMoney() |
| | | { |
| | | var count = UIHelper.GetMoneyCnt(52); |
| | | if (count > 0) |
| | | { |
| | | goldRushCountText.text = count + "/" + GoldRushManager.Instance.goldRushMissionMaxCnt; |
| | | } |
| | | else |
| | | { |
| | | //倒计时 |
| | | goldRushCountText.text = TimeUtility.SecondsToMS(GoldRushManager.Instance.restoreMissionSeconds - (TimeUtility.AllSeconds - GoldRushManager.Instance.lastRecoverTime)); |
| | | } |
| | | goldRushItemProcess.fillAmount = (float)count / GoldRushManager.Instance.goldRushMissionMaxCnt; |
| | | } |
| | | |
| | | void PlayerDataRefreshEvent(PlayerDataType type) |
| | | { |
| | | if (type == PlayerDataType.GoldRush) |
| | | { |
| | | RefreshGoldRushMoney(); |
| | | } |
| | | } |
| | | } |