using Snxxz.UI;
|
using System;
|
using System.Collections;
|
using System.Collections.Generic;
|
using System.Linq;
|
using UnityEngine;
|
|
//红包信息
|
public class FamilyRedPacket//红包信息
|
{
|
public int RedPacketID;//红包唯一ID
|
public int PlayerID;//玩家ID
|
public string Name;//玩家名字
|
public int Time;//时间
|
public int PlayeJob;//玩家职业
|
public int MoneyType;//金钱类型//1是V6红包
|
public int MoneyNum;//金钱数量
|
public int GetWay; //获得途径
|
public int PacketCnt; //可抢个数
|
public int State; //0未发,1未领取,2已领取,3全部领完
|
public string Wish; //祝福语
|
|
}
|
|
public class FamilyRedPacktGrabinfo//家族抢红包的信息
|
{
|
|
public string Name;//玩家名字
|
public int PlayerJob;//玩家职业
|
public int MoneyNum;//金钱数量
|
|
|
}
|
public class RedPacketModel : Model, IBeforePlayerDataInitialize, IPlayerLoginOk
|
{
|
|
public Dictionary<int, FamilyRedPacket> _DicRedBag = new Dictionary<int, FamilyRedPacket>();//接收红包信息
|
public Dictionary<int, FamilyRedPacktGrabinfo> _DicRedGrabinfo = new Dictionary<int, FamilyRedPacktGrabinfo>();//获取抢红包的信息字典
|
|
public delegate void RedEnvelopeToAdd(FamilyRedPacket _familyRedPacket);
|
public static event RedEnvelopeToAdd Event_RedEnvelopeToAdd;//红包的添加
|
public delegate void RedEnvelopeToRefresh(FamilyRedPacket _familyRedPacket);
|
public static event RedEnvelopeToRefresh Event_RedEnvelopeToRefresh;//红包的刷新
|
|
public delegate void DetailsRedEnvelopeRefresh();
|
public static event DetailsRedEnvelopeRefresh Event_DetailsRedEnvelopeRefresh;//红包详情的信息刷新
|
|
public int UseLimit = 0;//V6红包使用额度
|
|
|
public int RedBagId = 0;//获取当前选中红包的ID
|
|
public int redpackDetailId = 0;
|
|
public bool IsRedBagGetBool = false;
|
public static event Action OnRedBagGetEvent;//是否有可领取的红包
|
|
private const int Redpoint_key1 = 1070202;
|
public Redpoint redPointStre1 = new Redpoint(10702, Redpoint_key1);
|
|
public int RedEnvelopeID = 0;//发红包的ID(用于默认弹出开)
|
|
private int GrabRedBagId = 0;
|
public override void Init()
|
{
|
PlayerDatas.Instance.fairyData.OnRefreshFairyMine += OnRefreshFairyMine;
|
}
|
|
public override void UnInit()
|
{
|
|
}
|
|
public void OnBeforePlayerDataInitialize()
|
{
|
UseLimit = 0;
|
RedEnvelopeID = 0;
|
IsRedBagGetBool = false;
|
RedBagId = 0;
|
}
|
|
public void OnPlayerLoginOk()
|
{
|
|
}
|
|
private void OnRefreshFairyMine()//退出仙盟
|
{
|
if (_DicRedBag.Count > 0 && !PlayerDatas.Instance.fairyData.HasFairy)
|
{
|
var list = _DicRedBag.Values.ToList();
|
for (int i = 0; i < list.Count; i++)
|
{
|
if (IsDisplayInFamily(list[i].GetWay))
|
{
|
_DicRedBag.Remove(list[i].RedPacketID);
|
}
|
}
|
}
|
}
|
public void RedEnvelopeInfo(HA404_tagGCFamilyRedPacketInfo info)//家族红包总信息
|
{
|
|
|
if ((int)info.IsAll == 1)
|
{
|
_DicRedBag.Clear();
|
for (int i = 0; i < info.Count; i++)
|
{
|
if (!_DicRedBag.ContainsKey((int)info.RedPacketInfo[i].RedPacketID))
|
{
|
FamilyRedPacket _familyRed = new FamilyRedPacket();
|
_familyRed.RedPacketID = (int)info.RedPacketInfo[i].RedPacketID;
|
_familyRed.PlayerID = (int)info.RedPacketInfo[i].PlayerID;
|
_familyRed.Name = info.RedPacketInfo[i].Name;
|
_familyRed.Time = (int)info.RedPacketInfo[i].Time;
|
_familyRed.PlayeJob = (int)info.RedPacketInfo[i].PlayeJob;
|
_familyRed.MoneyType = (int)info.RedPacketInfo[i].MoneyType;
|
_familyRed.MoneyNum = (int)info.RedPacketInfo[i].MoneyNum;
|
_familyRed.GetWay = (int)info.RedPacketInfo[i].GetWay;
|
_familyRed.PacketCnt = (int)info.RedPacketInfo[i].PacketCnt;
|
_familyRed.State = (int)info.RedPacketInfo[i].State;
|
_familyRed.Wish = (string)info.RedPacketInfo[i].Wish;
|
_DicRedBag.Add((int)info.RedPacketInfo[i].RedPacketID, _familyRed);
|
|
}
|
|
}
|
|
}
|
else
|
{
|
for (int i = 0; i < info.Count; i++)
|
{
|
if (!_DicRedBag.ContainsKey((int)info.RedPacketInfo[i].RedPacketID))
|
{
|
FamilyRedPacket _familyRed = new FamilyRedPacket();
|
_familyRed.RedPacketID = (int)info.RedPacketInfo[i].RedPacketID;
|
_familyRed.PlayerID = (int)info.RedPacketInfo[i].PlayerID;
|
_familyRed.Name = info.RedPacketInfo[i].Name;
|
_familyRed.Time = (int)info.RedPacketInfo[i].Time;
|
_familyRed.PlayeJob = (int)info.RedPacketInfo[i].PlayeJob;
|
_familyRed.MoneyType = (int)info.RedPacketInfo[i].MoneyType;
|
_familyRed.MoneyNum = (int)info.RedPacketInfo[i].MoneyNum;
|
_familyRed.GetWay = (int)info.RedPacketInfo[i].GetWay;
|
_familyRed.PacketCnt = (int)info.RedPacketInfo[i].PacketCnt;
|
_familyRed.State = (int)info.RedPacketInfo[i].State;
|
_familyRed.Wish = (string)info.RedPacketInfo[i].Wish;
|
_DicRedBag.Add((int)info.RedPacketInfo[i].RedPacketID, _familyRed);
|
|
if (Event_RedEnvelopeToAdd != null)
|
Event_RedEnvelopeToAdd(_familyRed);
|
}
|
else
|
{
|
|
|
_DicRedBag[(int)info.RedPacketInfo[i].RedPacketID].RedPacketID = (int)info.RedPacketInfo[i].RedPacketID;
|
_DicRedBag[(int)info.RedPacketInfo[i].RedPacketID].PlayerID = (int)info.RedPacketInfo[i].PlayerID;
|
_DicRedBag[(int)info.RedPacketInfo[i].RedPacketID].Name = info.RedPacketInfo[i].Name;
|
_DicRedBag[(int)info.RedPacketInfo[i].RedPacketID].Time = (int)info.RedPacketInfo[i].Time;
|
_DicRedBag[(int)info.RedPacketInfo[i].RedPacketID].PlayeJob = (int)info.RedPacketInfo[i].PlayeJob;
|
_DicRedBag[(int)info.RedPacketInfo[i].RedPacketID].MoneyType = (int)info.RedPacketInfo[i].MoneyType;
|
_DicRedBag[(int)info.RedPacketInfo[i].RedPacketID].MoneyNum = (int)info.RedPacketInfo[i].MoneyNum;
|
_DicRedBag[(int)info.RedPacketInfo[i].RedPacketID].GetWay = (int)info.RedPacketInfo[i].GetWay;
|
_DicRedBag[(int)info.RedPacketInfo[i].RedPacketID].PacketCnt = (int)info.RedPacketInfo[i].PacketCnt;
|
_DicRedBag[(int)info.RedPacketInfo[i].RedPacketID].State = (int)info.RedPacketInfo[i].State;
|
if ((int)info.RedPacketInfo[i].RedPacketID == GrabRedBagId)
|
{
|
var Values = _DicRedGrabinfo.Values;
|
foreach (var value in Values)
|
{
|
if (value.Name == PlayerDatas.Instance.baseData.PlayerName)
|
{
|
_DicRedBag[(int)info.RedPacketInfo[i].RedPacketID].State = 2;
|
}
|
}
|
}
|
_DicRedBag[(int)info.RedPacketInfo[i].RedPacketID].Wish = (string)info.RedPacketInfo[i].Wish;
|
if (Event_RedEnvelopeToRefresh != null)
|
{
|
Event_RedEnvelopeToRefresh(_DicRedBag[(int)info.RedPacketInfo[i].RedPacketID]);
|
RedBagPoppingOpen();
|
}
|
|
}
|
}
|
}
|
|
IsRedBagGet();
|
RedPacketRedDot();
|
}
|
|
private void RedBagPoppingOpen()
|
{
|
if (_DicRedBag.ContainsKey(RedEnvelopeID) && WindowCenter.Instance.IsOpen<RedBagTipsWin>())
|
{
|
var redBag = _DicRedBag[RedEnvelopeID];
|
if (IsDisplayInFamily(redBag.GetWay) && redBag.GetWay != 0 && redBag.PlayerID == PlayerDatas.Instance.PlayerId && redBag.State == 1)
|
{
|
RedBagId = RedEnvelopeID;
|
WindowCenter.Instance.Open<RedpackOpenWin>();//打开领取界面
|
}
|
}
|
|
|
}
|
|
|
public void IsRedBagGet()
|
{
|
IsRedBagGetBool = false;
|
foreach (var value in _DicRedBag.Values)
|
{
|
if (!IsDisplayInFamily(value.GetWay))
|
{
|
continue;
|
}
|
if (value.State == 1)
|
{
|
IsRedBagGetBool = true;
|
}
|
}
|
if (IsRedBagGetBool)
|
{
|
if (OnRedBagGetEvent != null)
|
{
|
OnRedBagGetEvent();
|
}
|
}
|
}
|
|
|
private void RedPacketRedDot()
|
{
|
redPointStre1.state = RedPointState.None;
|
bool _bool = false;
|
foreach (var value in _DicRedBag.Values)
|
{
|
|
if (value.PlayerID == PlayerDatas.Instance.baseData.PlayerID && value.State == 0 && IsDisplayInFamily(value.GetWay))
|
{
|
_bool = true;
|
}
|
if (value.State == 1 && IsDisplayInFamily(value.GetWay))
|
{
|
_bool = true;
|
}
|
}
|
if (_bool)
|
{
|
redPointStre1.state = RedPointState.Simple;
|
}
|
|
}
|
|
public string RedPacketMaxName = null;//最大红包数量的ID
|
public void GrabRedEnvelope( HA405_tagGCFamilyRedPacketGrabInfo info)//家族抢红包信息
|
{
|
GrabRedBagId = (int)info.RedPacketID;
|
int _moneyNum = 0;
|
_DicRedGrabinfo.Clear();
|
|
for (int i = 0; i < info.Count;i++)
|
{
|
if (!_DicRedGrabinfo.ContainsKey(i))
|
{
|
FamilyRedPacktGrabinfo _familyRed = new FamilyRedPacktGrabinfo();
|
|
_familyRed.Name = info.GrabInfo[i].Name;
|
_familyRed.PlayerJob = info.GrabInfo[i].PlayeJob;
|
_familyRed.MoneyNum = (int)info.GrabInfo[i].MoneyNum;
|
if ((int)info.GrabInfo[i].MoneyNum > _moneyNum)
|
{
|
_moneyNum = (int)info.GrabInfo[i].MoneyNum;
|
RedPacketMaxName = info.GrabInfo[i].Name;
|
|
}
|
_DicRedGrabinfo.Add(i, _familyRed);
|
|
|
}
|
|
|
}
|
|
if (Event_DetailsRedEnvelopeRefresh != null)
|
Event_DetailsRedEnvelopeRefresh();
|
|
|
|
|
}
|
|
public bool IsDisplayInFamily(int getWay)
|
{
|
if (getWay == 5)
|
{
|
return false;
|
}
|
if (getWay == FestivalRedpackModel.FESTIVALSYSTEMREDPACK1
|
|| getWay == FestivalRedpackModel.FESTIVALSYSTEMREDPACK2
|
|| getWay == FestivalRedpackModel.FESTIVALTASKREDPACKTYPE)
|
{
|
return false;
|
}
|
return true;
|
}
|
|
}
|