| | |
| | | public class SpringFestivalModel : Model, IBeforePlayerDataInitialize, IPlayerLoginOk
|
| | | {
|
| | | public Dictionary<int, WeekPartyDayInfoClass> SpringFestivalInfoDic = new Dictionary<int, WeekPartyDayInfoClass>();//每天领取奖励信息
|
| | | public event Action SpringFestivalRewardUpdate;
|
| | | public event Action SpringFestivalRewardUpdate;//领奖记录变化
|
| | | public Dictionary<int, WeekPartyDayClass> SpringFestivalDayDic = new Dictionary<int, WeekPartyDayClass>();//每天的奖励信息
|
| | | public Dictionary<int, WeekPartyActionClass> SpringFestivalDic = new Dictionary<int, WeekPartyActionClass>();//活动模板总信息
|
| | | public Dictionary<int, Redpoint> RedPointDic = new Dictionary<int, Redpoint>();//红点
|
| | | private const int Redpoint_key1 = 21402;//周狂欢红点
|
| | | public Redpoint redPointStre1 = new Redpoint(214, Redpoint_key1);
|
| | | public int LimitLV = 0;//限制等级
|
| | | private int _SelectedNow = 0;
|
| | | public int SelectedNow//选中天
|
| | | {
|
| | | get { return _SelectedNow; }
|
| | | set { _SelectedNow = value; }
|
| | | }
|
| | |
|
| | | private int _DayNow = 0;
|
| | | public int DayNow//当前天
|
| | | {
|
| | | get { return _DayNow; }
|
| | | set { _DayNow = value; }
|
| | | }
|
| | | public override void Init()
|
| | | {
|
| | |
|
| | |
| | |
|
| | | public void OnPlayerLoginOk()
|
| | | {
|
| | | |
| | | GetDayNow();
|
| | | }
|
| | |
|
| | | public override void UnInit()
|
| | |
| | | dit.DayIndex = (int)DayInfo.DayIndex;
|
| | | dit.Point = (int)DayInfo.Point;
|
| | | dit.AwardRecord = (int)DayInfo.AwardRecord;
|
| | | for (int j = 0; j < dit.ActionType.Length; j++)
|
| | | for (int j = 0; j < DayInfo.ACount; j++)
|
| | | {
|
| | | if (dit.ActionType[j].TemplateID == DayInfo.TaskList[0].TemplateID)
|
| | | var taskList = DayInfo.TaskList[j];
|
| | | int Index = dit.ActionType.FindIndex(s => s.TemplateID == taskList.TemplateID);
|
| | | if (Index != -1)
|
| | | {
|
| | | dit.ActionType[Index].CurTimes = taskList.CurTimes;
|
| | | dit.ActionType[Index].GotTimes = taskList.GotTimes;
|
| | | }
|
| | | else
|
| | | {
|
| | | ActionTypeClass ActionType = new ActionTypeClass();
|
| | | ActionType.TemplateID = DayInfo.TaskList[0].TemplateID;
|
| | | ActionType.CurTimes = DayInfo.TaskList[0].CurTimes;
|
| | | ActionType.GotTimes = DayInfo.TaskList[0].GotTimes;
|
| | | dit.ActionType[j] = ActionType;
|
| | | ActionType.TemplateID = taskList.TemplateID;
|
| | | ActionType.CurTimes = taskList.CurTimes;
|
| | | ActionType.GotTimes = taskList.GotTimes;
|
| | | dit.ActionType.Add(ActionType);
|
| | | }
|
| | | }
|
| | | SpringFestivalInfoDic[(int)DayInfo.DayIndex] = dit;
|
| | | }
|
| | | else
|
| | | {
|
| | | WeekPartyDayInfo.ActionType = new ActionTypeClass[DayInfo.ACount];
|
| | | WeekPartyDayInfo.ActionType = new List<ActionTypeClass>();
|
| | | for (int k = 0; k < DayInfo.ACount; k++)
|
| | | {
|
| | | var Task = DayInfo.TaskList[k];
|
| | |
| | | ActionType.TemplateID = Task.TemplateID;
|
| | | ActionType.CurTimes = Task.CurTimes;
|
| | | ActionType.GotTimes = Task.GotTimes;
|
| | | WeekPartyDayInfo.ActionType[k] = ActionType;
|
| | | WeekPartyDayInfo.ActionType.Add(ActionType);
|
| | | }
|
| | | SpringFestivalInfoDic.Add((int)DayInfo.DayIndex, WeekPartyDayInfo);
|
| | | }
|
| | | }
|
| | | SetRedPoint();
|
| | | if (SpringFestivalRewardUpdate != null)
|
| | | {
|
| | | SpringFestivalRewardUpdate();
|
| | | }
|
| | | }
|
| | |
|
| | | public void SpringFestivalTemplate(HAA0A_tagMCWeekPartyInfo info)//每天模板信息
|
| | | {
|
| | | LimitLV = info.LimitLV;
|
| | | for (int i = 0; i < info.DayCnt; i++)
|
| | | {
|
| | | int Index = i;
|
| | | var DayInfo = info.DayInfoList[i];
|
| | | WeekPartyDayClass WeekPartyDay = new WeekPartyDayClass();
|
| | | WeekPartyDay.TemplateList = new int[DayInfo.ActCnt];
|
| | | for (int k = 0; k < DayInfo.ActCnt; k++)
|
| | | {
|
| | | WeekPartyDay.TemplateList[k] = DayInfo.TemplateList[k];
|
| | | }
|
| | | WeekPartyDay.WeekPartyItem = new WeekPartyItemClass[DayInfo.PCount];
|
| | | for (int p = 0; p < DayInfo.PCount; p++)
|
| | | {
|
| | | WeekPartyItemClass WeekPartyItem = new WeekPartyItemClass();
|
| | | var Item = DayInfo.PItemInfo[p];
|
| | | WeekPartyItem.NeedPoint = Item.NeedPoint;
|
| | | WeekPartyItem.ItemID = (int)Item.ItemID;
|
| | | WeekPartyItem.ItemCnt = (int)Item.ItemCnt;
|
| | | WeekPartyItem.IsBind = (int)Item.IsBind;
|
| | | WeekPartyDay.WeekPartyItem[p] = WeekPartyItem;
|
| | | }
|
| | | if (SpringFestivalDayDic.ContainsKey(Index))
|
| | | {
|
| | | SpringFestivalDayDic[Index] = WeekPartyDay;
|
| | | }
|
| | | else
|
| | | {
|
| | | SpringFestivalDayDic.Add(Index, WeekPartyDay);
|
| | | }
|
| | | }// 每天模板
|
| | | for (int i = 0; i < info.TCount; i++)
|
| | | {
|
| | | var ActionInfo = info.ActionInfo[i];
|
| | | WeekPartyActionClass WeekPartyAction = new WeekPartyActionClass();
|
| | | WeekPartyAction.TemplateID = (int)ActionInfo.TemplateID;
|
| | | WeekPartyAction.ActionType = (int)ActionInfo.ActionType;
|
| | | WeekPartyAction.TotalTimes = (int)ActionInfo.TotalTimes;
|
| | | WeekPartyAction.SingleTimes = (int)ActionInfo.SingleTimes;
|
| | | WeekPartyAction.Point = (int)ActionInfo.Point;
|
| | | WeekPartyAction.WeekPartyItem = new WeekPartyItemClass[ActionInfo.Count];
|
| | | for (int z = 0; z < ActionInfo.Count; z++)
|
| | | {
|
| | | var item = ActionInfo.ItemInfo[z];
|
| | | WeekPartyItemClass WeekPartyItem = new WeekPartyItemClass();
|
| | | WeekPartyItem.ItemID = (int)item.ItemID;
|
| | | WeekPartyItem.ItemCnt = (int)item.ItemCnt;
|
| | | WeekPartyItem.IsBind = item.IsBind;
|
| | | WeekPartyItem.NeedPoint = 0;
|
| | | WeekPartyAction.WeekPartyItem[z] = WeekPartyItem;
|
| | | }
|
| | | if (SpringFestivalDic.ContainsKey((int)ActionInfo.TemplateID))
|
| | | {
|
| | | SpringFestivalDic[(int)ActionInfo.TemplateID] = WeekPartyAction;
|
| | | }
|
| | | else
|
| | | {
|
| | | SpringFestivalDic.Add((int)ActionInfo.TemplateID, WeekPartyAction);
|
| | | }
|
| | | }// 活动模板信息
|
| | | SetRedPoint();
|
| | | }
|
| | |
|
| | | public int GetRewardNumber(int Day, int ID)//获取领奖次数
|
| | | {
|
| | | int Num = 0;
|
| | | if (SpringFestivalInfoDic.ContainsKey(Day))
|
| | | {
|
| | | var SpringFestivalDay = SpringFestivalInfoDic[Day];
|
| | |
|
| | | for (int i = 0; i < SpringFestivalDay.ActionType.Count; i++)
|
| | | {
|
| | | var ActionType = SpringFestivalDay.ActionType[i];
|
| | | if (ID == ActionType.TemplateID)
|
| | | {
|
| | | Num = ActionType.GotTimes;
|
| | | }
|
| | | }
|
| | | }
|
| | | return Num;
|
| | |
|
| | | }
|
| | | public int GetCarryOutNum(int Day, int ID)//获取已完成次数
|
| | | {
|
| | | int Num = 0;
|
| | | if (SpringFestivalInfoDic.ContainsKey(Day))
|
| | | {
|
| | | var SpringFestival = SpringFestivalInfoDic[Day];
|
| | |
|
| | | for (int i = 0; i < SpringFestival.ActionType.Count; i++)
|
| | | {
|
| | | var ActionType = SpringFestival.ActionType[i];
|
| | | if (ID == ActionType.TemplateID)
|
| | | {
|
| | | Num = ActionType.CurTimes;
|
| | | }
|
| | | }
|
| | | }
|
| | | return Num;
|
| | | }
|
| | | public int GetPoint(int day)//获取某一天的积分
|
| | | {
|
| | | int Point = 0;
|
| | | if (SpringFestivalInfoDic.ContainsKey(day))
|
| | | {
|
| | | Point = SpringFestivalInfoDic[day].Point;
|
| | | }
|
| | | return Point;
|
| | | }
|
| | | public void SendGetSpringFestival(int day, int temdayplateID)//领取春节活动奖励
|
| | | {
|
| | | CA504_tagCMPlayerGetReward getReward = new CA504_tagCMPlayerGetReward();
|
| | | getReward.RewardType = (byte)GotServerRewardType.Def_RewardType_WeekPartyAct;
|
| | | getReward.DataEx = (uint)day;
|
| | | string StrID = temdayplateID.ToString();
|
| | | getReward.DataExStrLen = (byte)StrID.Length;
|
| | | getReward.DataExStr = StrID;
|
| | | GameNetSystem.Instance.SendInfo(getReward);
|
| | | }
|
| | | public void SendGetSpringFestivalPoint(int day, int point)//领取春节积分奖励
|
| | | {
|
| | | CA504_tagCMPlayerGetReward getReward = new CA504_tagCMPlayerGetReward();
|
| | | getReward.RewardType = (byte)GotServerRewardType.Def_RewardType_WeekPartyPoint;
|
| | | getReward.DataEx = (uint)day;
|
| | | string StrID = point.ToString();
|
| | | getReward.DataExStrLen = (byte)StrID.Length;
|
| | | getReward.DataExStr = StrID;
|
| | | GameNetSystem.Instance.SendInfo(getReward);
|
| | | }
|
| | | public bool IsDayReward(int day, int index)//是否领取奖励
|
| | | {
|
| | | bool _bool = false;
|
| | | int AwardRecord = 0;
|
| | | foreach (var key in SpringFestivalInfoDic.Keys)
|
| | | {
|
| | | if (key == day)
|
| | | {
|
| | | AwardRecord = SpringFestivalInfoDic[key].AwardRecord;
|
| | | }
|
| | | }
|
| | | _bool = MathUtility.GetBitValue((uint)AwardRecord, (ushort)index);
|
| | | return _bool;
|
| | | }
|
| | | private void SetRedPoint()//红点设置
|
| | | {
|
| | | SetRedPointId();
|
| | | foreach (var key in RedPointDic.Keys)
|
| | | {
|
| | | RedPointDic[key].state = RedPointState.None;
|
| | | }
|
| | | foreach (var key in RedPointDic.Keys)
|
| | | {
|
| | | RedPointDic[key].state = SetRedPointState(key);
|
| | | }
|
| | | }
|
| | | private void SetRedPointId()//设置红点ID
|
| | | {
|
| | | if (RedPointDic.Count > 0)
|
| | | {
|
| | | return;
|
| | | }
|
| | | foreach (var key in SpringFestivalInfoDic.Keys)
|
| | | {
|
| | | int RedPoint = Redpoint_key1 * 10 + key;
|
| | | if (!RedPointDic.ContainsKey(key))
|
| | | {
|
| | | Redpoint redPointMountStare = new Redpoint(Redpoint_key1, RedPoint);
|
| | | RedPointDic.Add(key, redPointMountStare);
|
| | | }
|
| | | }
|
| | |
|
| | | }
|
| | | private RedPointState SetRedPointState(int day)//红点状态设置
|
| | | {
|
| | | if (!SpringFestivalDayDic.ContainsKey(day) || !SpringFestivalInfoDic.ContainsKey(day))
|
| | | {
|
| | | return RedPointState.None;
|
| | | }
|
| | | WeekPartyDayClass WeekPartyDay = new WeekPartyDayClass();
|
| | | int point = SpringFestivalInfoDic[day].Point;
|
| | | foreach (var key in SpringFestivalDayDic.Keys)
|
| | | {
|
| | | if (key == day)
|
| | | {
|
| | | WeekPartyDay = SpringFestivalDayDic[key];
|
| | | }
|
| | | }
|
| | | for (int i = 0; i < WeekPartyDay.WeekPartyItem.Length; i++)//积分奖励
|
| | | {
|
| | | var item = WeekPartyDay.WeekPartyItem[i];
|
| | | int type = i;
|
| | | bool IsBool = IsDayReward(day, type);
|
| | | if (point >= item.NeedPoint && !IsBool)
|
| | | {
|
| | | return RedPointState.GetReward;
|
| | | }
|
| | | }
|
| | | for (int i = 0; i < WeekPartyDay.TemplateList.Length; i++)
|
| | | {
|
| | | var TemplateID = WeekPartyDay.TemplateList[i];
|
| | | if (SpringFestivalDic.ContainsKey(TemplateID))
|
| | | {
|
| | | var WeekPartyAction = SpringFestivalDic[TemplateID];
|
| | | int number = WeekPartyAction.TotalTimes / WeekPartyAction.SingleTimes;
|
| | | int rewardNum = GetRewardNumber(day, TemplateID);//已领奖次数
|
| | | int carryOutNum = GetCarryOutNum(day, TemplateID);//已完成次数
|
| | | int TaypeNumber = 0;
|
| | | if (carryOutNum - rewardNum > 0)
|
| | | {
|
| | | TaypeNumber = (carryOutNum - rewardNum) / WeekPartyAction.SingleTimes;
|
| | | }
|
| | | if (TaypeNumber > 0 && rewardNum < number)
|
| | | {
|
| | | return RedPointState.GetReward;
|
| | | }
|
| | | }
|
| | | }
|
| | | return RedPointState.None;
|
| | | }
|
| | |
|
| | | public void GetDayNow()
|
| | | {
|
| | | OperationBase operationBase;
|
| | | if (OperationTimeHepler.Instance.TryGetOperationTime(Operation.SpringFestival, out operationBase))
|
| | | {
|
| | | int inday = (operationBase as EventDaysTime).GetInDayNow();
|
| | | if (inday >= 0 && inday < 7)
|
| | | {
|
| | | _DayNow = inday;
|
| | | }
|
| | | else if (inday >= 7)
|
| | | {
|
| | | _DayNow = 6;
|
| | | }
|
| | |
|
| | | }
|
| | | }
|
| | | } |
| | | |
| | | |