55 lines
1.1 KiB
C#
55 lines
1.1 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using LitJson;
|
|
using UnityEngine;
|
|
|
|
namespace Wizard;
|
|
|
|
public class AvatarBattleAllInfo
|
|
{
|
|
public class PeriodData
|
|
{
|
|
|
|
public double StartUnixTime { get; set; }
|
|
|
|
public double EndUnixTime { get; set; }
|
|
}
|
|
|
|
private Dictionary<string, AvatarBattleInfo> _avatarBattleDictionary = new Dictionary<string, AvatarBattleInfo>();
|
|
|
|
public PeriodData FreeMatchPeriod = new PeriodData();
|
|
|
|
private bool _avatarBattleScheduleExist;
|
|
|
|
private float _receiveSinceTime;
|
|
|
|
private double _receiveServerUnixTime;
|
|
|
|
public AvatarBattleInfo Get(string id)
|
|
{
|
|
if (string.IsNullOrEmpty(id))
|
|
{
|
|
return null;
|
|
}
|
|
if (_avatarBattleDictionary.TryGetValue(id, out var value))
|
|
{
|
|
return value;
|
|
}
|
|
return null;
|
|
}
|
|
|
|
private bool IsWithinPeriod(PeriodData period)
|
|
{
|
|
if (!_avatarBattleScheduleExist)
|
|
{
|
|
return false;
|
|
}
|
|
double num = _receiveServerUnixTime + (double)Time.realtimeSinceStartup - (double)_receiveSinceTime;
|
|
if (num > period.EndUnixTime)
|
|
{
|
|
return false;
|
|
}
|
|
return num > period.StartUnixTime;
|
|
}
|
|
}
|