53 lines
1.7 KiB
C#
53 lines
1.7 KiB
C#
using asap.core;
|
|
using cfg;
|
|
using game;
|
|
using Newtonsoft.Json;
|
|
using System;
|
|
using UnityEngine;
|
|
|
|
public class EventPinataPackData
|
|
{
|
|
[JsonIgnore]
|
|
private readonly Tables _tables = GContext.container.Resolve<Tables>();
|
|
[JsonIgnore]
|
|
public TimeSpan RemainingTime =>
|
|
(EventID <= 0
|
|
|| !_tables.TbFishingEvent.DataMap.ContainsKey(EventID)
|
|
|| DateTime.Parse((_tables.TbFishingEvent[EventID]?.TimeDefinition as LimitedTime)?.StartTime) > ZZTimeHelper.UtcNow())
|
|
? default : (DateTime.Parse((_tables.TbFishingEvent[EventID]?.TimeDefinition as LimitedTime)?.EndTime)
|
|
- ZZTimeHelper.UtcNow()) ;
|
|
public bool IsActive
|
|
{
|
|
get
|
|
{
|
|
if (RemainingTime.TotalSeconds <= 0) return false;
|
|
if (EventPinataPackMain == null) return false;
|
|
var eventPackManager = GContext.container.Resolve<Tables>().TbEventPackManager?.GetOrDefault(EventPinataPackMain.PackId);
|
|
if (eventPackManager == null) return false;
|
|
return eventPackManager.MaxCount > PurchasedCount;
|
|
}
|
|
}
|
|
|
|
[JsonIgnore]
|
|
public EventPinataPackMain EventPinataPackMain => GContext.container.Resolve<EventPinataPackDataManager>().GetCurrentEventPinataPackMain();
|
|
|
|
|
|
public int EventID { get; set; }
|
|
|
|
public int PinataMainID { get; set; }
|
|
|
|
public int PurchasedCount { get; set; }
|
|
|
|
public void AddPurchasedCount(int value)
|
|
{
|
|
this.PurchasedCount += value;
|
|
GContext.container.Resolve<EventPinataPackDataManager>().SaveData();
|
|
}
|
|
public void SetData(EventPinataPackData data )
|
|
{
|
|
this.EventID = data.EventID;
|
|
this.PinataMainID = data.PinataMainID;
|
|
this.PurchasedCount = data.PurchasedCount;
|
|
}
|
|
}
|