少年修仙传客户端代码仓库
client_Wu Xijin
2018-10-15 966febfb534c66812e28636e0ea22f833b51d5fe
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
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
 
namespace Snxxz.UI
{
    public class FlashRushToBuyCoolDown : MonoBehaviour
    {
        [SerializeField] Text timeText;
        FlashRushToBuyModel rushToBuyModel { get { return ModelCenter.Instance.GetModel<FlashRushToBuyModel>(); } }
        bool isReplace = false;
        bool isStartReplace = false;
        private void Awake()
        {
            GlobalTimeEvent.Instance.halfMinuteEvent += UpdateHalfMinute;
        }
 
        private void OnEnable()
        {
            SecondEvent();
            GlobalTimeEvent.Instance.secondEvent -= SecondEvent;
            GlobalTimeEvent.Instance.secondEvent += SecondEvent;
        }
 
        private void OnDisable()
        {
            GlobalTimeEvent.Instance.secondEvent -= SecondEvent;
        }
 
        private void UpdateHalfMinute()
        {
            if (!isStartReplace) return;
 
            isReplace = !isReplace;
        }
 
        private void SecondEvent()
        {
            DisplayTime();
        }
 
        void DisplayTime()
        {
            var operation = rushToBuyModel.GetOperationFlashRushToBuy();
            if (operation == null) return;
            int seconds = 0;
            OperationTime operationTime;
            OperationFlashRushToBuy.FlashSaleShop saleShop;
            FlashRushToBuyModel.FlashRushToBuySate flashState = rushToBuyModel.GetActivityState(out seconds,out operationTime,out saleShop);
            isStartReplace = false;
            switch (flashState)
            {
                case FlashRushToBuyModel.FlashRushToBuySate.NoOpen:
                    break;
                case FlashRushToBuyModel.FlashRushToBuySate.InAdvance:
                    if(seconds <= 3600)
                    {
                        isStartReplace = true;
                        if(!isReplace)
                        {
                            timeText.text = TimeUtility.SecondsToHMS(seconds);
                        }
                        else
                        {
                            timeText.text = operation.ToDisplayBuyTime(operationTime.startHour, operationTime.startMinute);
                        }
                    }
                    else
                    {
                        timeText.text = operation.ToDisplayBuyTime(operationTime.startHour, operationTime.startMinute);
                    }
                    break;
                case FlashRushToBuyModel.FlashRushToBuySate.Begining:
                    timeText.text = "秒杀中";
                    break;
                case FlashRushToBuyModel.FlashRushToBuySate.End:
                    timeText.text = "活动已结束";
                    break;
            }
        }
    }
}