hch
1 天以前 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
112
113
114
115
116
117
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();
        }
    }
}