少年修仙传客户端代码仓库
lcy
2024-12-16 a39c35fc6449430cd02bccb681c4a0a880e46cd9
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
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using System;
using vnxbqy.UI;
 
public class ItemTimeUtility : Singleton<ItemTimeUtility>
{
 
    LogicUpdate logicUpdate;
 
    Dictionary<string, DateTime> auctionEndTimes = new Dictionary<string, DateTime>();
    Dictionary<string, DateTime> useEndTimes = new Dictionary<string, DateTime>();
 
    PackModel packModel { get { return ModelCenter.Instance.GetModel<PackModel>(); } }
 
    public ItemTimeUtility()
    {
        logicUpdate = new LogicUpdate(1f);
        logicUpdate.Start(OnUpdate);
    }
 
    public void AddUseEndTime(string guid, DateTime endTime)
    {
        useEndTimes[guid] = endTime;
    }
 
    public void RemoveUseEndTime(string guid)
    {
        if (useEndTimes.ContainsKey(guid))
        {
            useEndTimes.Remove(guid);
        }
    }
 
    public void AddAuctionEndTime(string guid, DateTime endTime)
    {
        auctionEndTimes[guid] = endTime;
    }
 
    public void RemoveAuctionEndTime(string guid)
    {
        if (auctionEndTimes.ContainsKey(guid))
        {
            auctionEndTimes.Remove(guid);
        }
    }
 
    private void OnUpdate()
    {
        foreach (var item in auctionEndTimes)
        {
            if (TimeUtility.ServerNow > item.Value)
            {
                ProcessAuctionOverdue(item.Key);
            }
        }
    }
 
    private void ProcessAuctionOverdue(string guid)
    {
        ItemOperateUtility.Instance.ProcessOverdueItem(guid);
    }
 
}