using System;
|
using System.Collections;
|
using System.Collections.Generic;
|
using TableConfig;
|
using UnityEngine;
|
namespace Snxxz.UI
|
{
|
public class OSGiftModel : Model, IPlayerLoginOk, IBeforePlayerDataInitialize, IOpenServerActivity
|
{
|
public override void Init()
|
{
|
PlayerDatas.Instance.PlayerDataRefreshInfoEvent += PlayerDataRefreshInfoEvent;
|
storeModel.RefreshBuyShopLimitEvent += RefreshBuyShopLimitEvent;
|
vipModel.firstChargeRewardEvent += FirstChargeRewardEvent;
|
OpenServerActivityCenter.Instance.Register(6, this);
|
}
|
|
public override void UnInit()
|
{
|
|
}
|
|
public void OnPlayerLoginOk()
|
{
|
activate = CheckActivate();
|
if (onStateUpate != null)
|
{
|
onStateUpate(6);
|
}
|
}
|
|
public event Action<int> onStateUpate;
|
|
public bool activate { get; private set; }
|
|
private bool m_GiftGetNotify = false;
|
public bool giftGetNotify
|
{
|
get { return m_GiftGetNotify; }
|
set
|
{
|
m_GiftGetNotify = value;
|
OSGiftRedpoint.state = value ? RedPointState.Simple : RedPointState.None;
|
}
|
}
|
|
StoreModel storeModel
|
{
|
get
|
{
|
return ModelCenter.Instance.GetModel<StoreModel>();
|
}
|
}
|
|
VipModel vipModel { get { return ModelCenter.Instance.GetModel<VipModel>(); } }
|
|
public bool IsOpen
|
{
|
get
|
{
|
return CheckActivate();
|
}
|
}
|
|
public bool priorityOpen
|
{
|
get
|
{
|
return OSGiftRedpoint.state == RedPointState.Simple;
|
}
|
}
|
|
private void RefreshBuyShopLimitEvent()
|
{
|
bool _activate = CheckActivate();
|
if (activate != _activate)
|
{
|
activate = _activate;
|
if (onStateUpate != null)
|
{
|
onStateUpate(6);
|
}
|
}
|
}
|
|
private void FirstChargeRewardEvent()
|
{
|
bool _activate = CheckActivate();
|
if (activate != _activate)
|
{
|
activate = _activate;
|
if (onStateUpate != null)
|
{
|
onStateUpate(6);
|
}
|
}
|
}
|
|
public bool CheckActivate()
|
{
|
if (PlayerDatas.Instance.baseData.coinPointTotal == 0
|
|| !ModelCenter.Instance.GetModel<VipModel>().firstChargeRewardGet)
|
{
|
return false;
|
}
|
List<StoreConfig> _list = null;
|
StoreConfig.TryGetStoreConfigs((int)StoreFunc.OSGift,out _list);
|
for (int i = 0; i < _list.Count; i++)
|
{
|
var _limit = storeModel.GetBuyShopLimit((uint)_list[i].ID);
|
if (_limit == null || _limit.BuyCnt < _list[i].PurchaseNumber[0])
|
{
|
return true;
|
}
|
}
|
return false;
|
}
|
|
private void PlayerDataRefreshInfoEvent(PlayerDataRefresh _type)
|
{
|
bool _activate = CheckActivate();
|
if (_type == PlayerDataRefresh.ChangeCoinPointTotal && activate != _activate)
|
{
|
activate = _activate;
|
if (onStateUpate != null)
|
{
|
onStateUpate(6);
|
}
|
}
|
}
|
|
public void OnBeforePlayerDataInitialize()
|
{
|
giftGetNotify = false;
|
}
|
|
public Redpoint OSGiftRedpoint = new Redpoint(MainRedDot.REDPOINT_OPENSERVER, 20906);
|
}
|
}
|