using System.Collections;
|
using System.Collections.Generic;
|
using UnityEngine;
|
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>();
|
}
|
);
|
|
goldRushIcon.SetIconWithMoneyType(52);
|
goldRushItemBtn.AddListener(() =>
|
{
|
ItemTipUtility.ShowMoneyTip(52, false);
|
}
|
);
|
autoBtn.AddListener(() =>
|
{
|
UIManager.Instance.OpenWindow<GoldRushAutoWin>();
|
}
|
);
|
}
|
|
protected override void OnPreOpen()
|
{
|
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.OnGoldRushInfoEvent -= OnGoldRushInfoEvent;
|
GoldRushManager.Instance.OnAutoWorkingEvent -= OnAutoWorkingEvent;
|
GlobalTimeEvent.Instance.secondEvent -= OnSecondEvent;
|
PlayerDatas.Instance.playerDataRefreshEvent -= PlayerDataRefreshEvent;
|
}
|
|
void Display()
|
{
|
fullGoldRush.SetActive(GoldRushManager.Instance.GetFinishGoldRushCount() >= GoldRushManager.Instance.warehouseMaxCnt);
|
RefreshGoldRushMoney();
|
autoText.text = Language.Get(GoldRushManager.Instance.isAutoWorking ? "GoldRush34" : "GoldRush24");
|
}
|
|
|
void OnGoldRushInfoEvent()
|
{
|
fullGoldRush.SetActive(GoldRushManager.Instance.GetFinishGoldRushCount() >= GoldRushManager.Instance.warehouseMaxCnt);
|
}
|
|
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();
|
}
|
}
|
}
|