少年修仙传客户端代码仓库
hch
2025-06-12 204ef05a831c9484e2abc561d27ecbff7c797453
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
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
 
namespace vnxbqy.UI
{
    public class FlashRushToBuyCoolDown : MonoBehaviour
    {
        [SerializeField] Text timeText;
        FlashRushToBuyModel rushToBuyModel { get { return ModelCenter.Instance.GetModel<FlashRushToBuyModel>(); } }
        bool isReplace = false;
 
        private void OnEnable()
        {
            DisplayTime();
            WindowCenter.Instance.windowBeforeOpenEvent += OpenWindow;
        }
 
        private void OnDisable()
        {
            WindowCenter.Instance.windowBeforeOpenEvent -= OpenWindow;
        }
 
 
        private void OpenWindow(Window win)
        {
            if (win.name != typeof(MainInterfaceWin).Name) return;
 
            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);
            switch (flashState)
            {
                case FlashRushToBuyModel.FlashRushToBuySate.NoOpen:
                    break;
                case FlashRushToBuyModel.FlashRushToBuySate.InAdvance:
                    var operationDate = operation.startDate.AddDays(saleShop.dayIndex);
                    DateTime openTime = new DateTime(operationDate.year,operationDate.month,operationDate.day);
                    int offsetDay = Mathf.CeilToInt((float)(openTime - TimeUtility.ServerNow).TotalDays);
                    if(offsetDay > 1)
                    {
                        string saleDate = StringUtility.Contact(operationDate.day, "/", operationDate.month);
                        timeText.text = saleDate;
                    }
                    else if(offsetDay == 1)
                    {
                        timeText.text = Language.Get("FlashRushToBuy110");
                    }
                    else
                    {
                        timeText.text = Language.Get("FlashRushToBuy106", operation.ToDisplayBuyTime(operationTime.startHour, operationTime.startMinute));
                    }
                    //if(seconds <= 3600)
                    //{
                    //    int split = (3600 - seconds)/30 % 2;
                    //    if(split == 0)
                    //    {
                    //        timeText.text = Language.Get("FlashRushToBuy109", TimeUtility.SecondsToMS(seconds));
                    //    }
                    //    else
                    //    {
                    //        timeText.text = Language.Get("FlashRushToBuy106", operation.ToDisplayBuyTime(operationTime.startHour, operationTime.startMinute));
                    //    }
                    //}
                    //else
                    //{
                    //    timeText.text = Language.Get("FlashRushToBuy106", operation.ToDisplayBuyTime(operationTime.startHour, operationTime.startMinute));
                    //}
                    break;
                case FlashRushToBuyModel.FlashRushToBuySate.Begining:
                    timeText.text = Language.Get("FlashRushToBuy107");
                    break;
                case FlashRushToBuyModel.FlashRushToBuySate.End:
                    timeText.text = Language.Get("ActivityEnd");
                    break;
            }
        }
    }
}