using UnityEngine; using System; using System.Collections; using System.Linq; using Newtonsoft.Json.Linq; using System.Collections.Generic; /// /// /// public class ActiveProxy : ProxyBase { #region ` constructor ` public ActiveProxy() => this.opeCode = OpeCode.ope_active; #endregion #region 七日签到奖励 /// /// [6502] 七日签到福利 - 领取奖励 /// /// 第x天(1~7) /// 成功回调函数 public void Day7_DrawReward(int day, Action callback) { Post(CmdCode.cmd_active_day7_drawreward, new object[] { day }, resp => { var p = UserProxy.Instance.player; p.baseInfo.gold = Convert.ToInt32(resp.result["gold"].ToString()); p.baseInfo.cash = Convert.ToInt32(resp.result["cash"].ToString()); p.baseInfo.tili = Convert.ToInt32(resp.result["tili"].ToString()); p.collectHero.InitData((JObject)resp.result["hero"],p); // 英雄 p.PrivateState.day7_drawed.Add(day); // 同步领取记录 callback?.Invoke(sm_activity_day7.GetMoById(day).reward); }); } #endregion /// /// [6503] 查询开服时间戳 /// /// 成功回调函数 public void GetZonePublicTs(Action callback) { Post(CmdCode.cmd_active_getZonePublicTs, new object[] { }, resp => callback?.Invoke(new DateTime().FromUnixStamp((uint)resp.result))); } #region ' 废弃 ' /// /// [6509] 抽奖(已经变为开箱子功能) /// /// 道具的typeid /// 卡槽id(0,1,2,3) ----这个变为数量 /// <>cash是免冷却开宝箱所需要费的钻石数量 <> /// 成功回调函数 [Obsolete("2020.8.17")] public void Lottery(int type, int slotid, int cash = 0, Action callback = null, Action onfail = null) { Post(CmdCode.cmd_active_lottery, new object[] { type, slotid, cash }, resp => callback?.Invoke(resp.result)); } /// /// [6510] 新手抽奖 /// /// 道具的typeid /// 可选, 连抽次数 /// 成功回调函数 [Obsolete("2020.8.17")] public void LotteryNew(int type, int number = 1, Action callback = null) { Post(CmdCode.cmd_active_lottery_new, new object[] { type, number }, resp => callback?.Invoke(resp.result)); } /// /// [6511] 抽奖 - 领取保底奖励 /// /// 道具的typeid /// 奖励所需次数, 注意不是自己的抽奖次数 /// 成功回调函数 [Obsolete("2020.8.17")] public void Lottery_baodi_jiangli(int type, int cishu = 10, Action callback = null) { Post(CmdCode.cmd_active_lottery_baodi, new object[] { type, cishu }, resp => callback?.Invoke(resp.result)); } /// /// [6512] 抽奖 - 领取保底奖励 /// /// 卡槽id /// 成功回调函数 [Obsolete] public void Lottery_draw_hero(int slotid, Action callback = null) { Post(CmdCode.cmd_active_lottery_drawhero, new object[] { slotid }, resp => callback?.Invoke(resp.result)); } /// /// [6513] 抽奖 - 拉取最新的抽奖信息 /// /// [Obsolete] public void Loterry_info(Action callback = null) { Post(CmdCode.cmd_active_lottery_info, new object[] { }, resp => callback?.Invoke(resp.result)); } /// /// [6514] 抽奖 - 解锁卡槽 , 备注, 暂时没有任何消耗, 发送请求直接开启 /// /// 卡槽id /// 成功回调函数 [Obsolete] public void Lottery_unlock_slot(int slotid, Action callback = null) { Post(CmdCode.cmd_active_lottery_unlock_slot, new object[] { slotid }, resp => callback?.Invoke(resp.result)); } /// /// [6515] 抽奖 - 新生招募, 加速搜索, 默认行为,扣除一枚打车券,将slot->opents设置为now()之前的值. /// /// 卡槽id /// 成功回调函数 [Obsolete] public void Lottery_speedup_search(int slotid, Action callback = null) { Post(CmdCode.cmd_active_lottery_speedup_search, new object[] { slotid }, resp => callback?.Invoke(resp.result)); } /// /// [6514] 活动 - 领取全服注册礼包 /// /// 卡槽id /// 成功回调函数 [Obsolete("2020.8.18")] public void DrawRegGift(int slotid, Action callback = null) { Post(CmdCode.cmd_active_drawRegGift, new object[] { slotid }, resp => callback?.Invoke(resp.result)); } /// /// 6516 查询全服的注册人数 /// /// [Obsolete("2020.8.18")] public void GetRegNumber(Action callback = null) { Post(CmdCode.cmd_active_getRegNumber, new object[] { }, resp => callback?.Invoke(resp.result)); } /// /// 6515 领取 每天 时间段的 赠送体力活动 /// /// public void DrawPresentTili(Action callback = null) { Post(CmdCode.cmd_active_presentTili, new object[] { }, resp => callback?.Invoke(resp.result)); } #endregion /// /// [6512] 活动 - 凭兑换码领取礼包 /// /// 兑换码 /// 成功回调函数 public void DrawGiftByToken(string token, Action callback = null) { Post(CmdCode.cmd_active_drawGiftByToken, new object[] { (int)EActivityType.CDKeyActive, token }, resp => { var p = UserProxy.Instance.player; p.baseInfo.gold = Convert.ToInt32(resp.result["gold"].ToString()); p.baseInfo.cash = Convert.ToInt32(resp.result["cash"].ToString()); p.baseInfo.tili = Convert.ToInt32(resp.result["tili"].ToString()); p.collectHero.InitData((JObject)resp.result["hero"],p); // 英雄 var rewardstr = resp.result["reward"].ToString(); callback?.Invoke(rewardstr); }); } /// /// [6513] 活动 - 领取连续在线礼包 /// /// 礼包编号(1,2,3...顺序) /// public void DrawOnlineGift(int giftId, Action callback = null) { Post(CmdCode.cmd_active_drawOnlineGift, new object[] { giftId }, resp => { var p = UserProxy.Instance.player; p.baseInfo.gold = Convert.ToInt32(resp.result["gold"].ToString()); p.baseInfo.cash = Convert.ToInt32(resp.result["cash"].ToString()); p.baseInfo.tili = Convert.ToInt32(resp.result["tili"].ToString()); p.collectHero.InitData((JObject)resp.result["hero"],p); // 英雄 var rewardstr = resp.result["reward"].ToString(); p.PrivateState.onlineGiftts = resp.result["onlineGiftts"].ToObject(); p.PrivateState.onlineGiftIDs = resp.result["onlineGiftIDs"].ToObject>(); callback?.Invoke(resp.result); }); } /// /// 刷新下在线信息 /// /// public void GetOnlineInfo(Action callback) { Post(CmdCode.cmd_active_getTodayOnlineInfos, new object[] { }, resp => { var ret = resp.result.ToObject(); var p = UserProxy.Instance.player; p.PrivateState.onlineGiftts = ret.onlineGiftts; p.PrivateState.onlineGiftIDs = ret.onlineGiftIDs; callback?.Invoke(ret); }); } /// /// 获取神庙所有的标签时间 /// /// public void GetShenmiaoData(Action> callback) { Post(CmdCode.cmd_active_GetShenmiaoData, new object[] { }, resp => { var p = UserProxy.Instance.player; p.shenmiaoInfo.Initlize(resp.result["shenmiaoInfo"]); Dictionary activeDic = p.shenmiaoInfo.activeDic; List list = new List(); foreach (KeyValuePair kv in activeDic) { ShenMiaoVo vo = new ShenMiaoVo((EShenMiaoActiveType)kv.Key); list.Add(vo); } if (callback != null) { callback.Invoke(list); } }); } /// /// 抽奖 /// /// 1 or 10 /// public void GetShenmiaoPrize(EShenMiaoActiveType type,int num, Action> callback) { Post(CmdCode.cmd_active_shenmiaoDrawPrize, new object[] { (int)type,num }, resp => { var p = UserProxy.Instance.player; p.shenmiaoInfo.Initlize(resp.result["shenmiaoInfo"]); JArray arr = JArray.Parse(resp.result["list"].ToString()); List list = new List(); foreach (JToken id in arr) { ItemVo vo = new ItemVo(); vo.typeId = id.ToString(); vo.count = 1; list.Add(vo); } if (callback != null) { callback.Invoke(list); } }); } /// /// 神庙买券---临时 /// /// /// /// public void buyShenmiaoDrawTicket(int costId,int num,Action callback) { if (costId == 3320001) { costId = 801022; } else { costId = 801023; } Post(CmdCode.cmd_active_buyShenmiaoDrawTicket, new object[] { costId, num }, resp => { var p = UserProxy.Instance.player; p.baseInfo.cash = int.Parse(resp.result["cash"].ToString()); if (callback != null) { callback.Invoke(); } }); } /// /// 获取当前体力 /// /// /// public void GetCurTili(Action callback) { Post(CmdCode.cmd_active_GetCurTili, new object[] { }, resp => { var p = UserProxy.Instance.player; p.baseInfo.tili = int.Parse(resp.result["tili"].ToString()); p.PrivateState.TiliTime = long.Parse(resp.result["time"].ToString()); callback?.Invoke(); }); } /// /// 购买体力 /// /// public void BuyTili(Action callback) { Post(CmdCode.cmd_active_BuyTili, new object[] { }, resp => { var p = UserProxy.Instance.player; p.baseInfo.tili = int.Parse(resp.result["tili"].ToString()); p.PrivateState.TiliTime = long.Parse(resp.result["time"].ToString()); p.baseInfo.cash = int.Parse(resp.result["cash"].ToString()); p.PrivateState.buyTiliNum = int.Parse(resp.result["buyTiliNum"].ToString()); callback?.Invoke(); }); } #region 内部类 /// /// 活动UI /// public class UIVO_ActivityMain { /// /// 当前(正在进行)活动列表 /// /// public List CurActivities() => GameConfigData.Ins.activity.Values.Where(a => a.IsOpen()).ToList(); /// /// 7日签到信息 /// public class Day7_UIVO { /// /// 7天信息列表 /// public List dayInfos = new[] { 1, 2, 3, 4, 5, 6, 7 }.ToList().ConvertAll(i => new DayInfo(i)); /// /// 每天的信息 /// public class DayInfo { private Player p = UserProxy.Instance.player; /// /// 第几天 /// public readonly int day; public DayInfo(int _day) { this.day = _day; } /// /// 配置数据 /// public sm_activity_day7 Mo => sm_activity_day7.GetMoById(day); /// /// 奖励物品 /// public ItemVo item => ItemVo.ParsItemContentStr(Mo.reward).First(); /// /// 是否已经领取 /// public bool HasDrawed => p.PrivateState.day7_drawed.Contains(day); /// /// 是否可以领取 /// public bool CanDraw => p.PrivateState.LoginDays.Count >= day; } } /// /// 查询在线奖励信息返回值结构 /// public class OnlineGiftInfo_RetVo { public int onlineGiftts; public List onlineGiftIDs; /// /// 在线总时长 /// public TimeSpan TotalOnlineTime => TimeSpan.FromSeconds(onlineGiftts); } /// /// 在线奖励 /// public class OnlineGift_UIVO { /// /// 奖励信息 /// public List giftInfos = GameConfigData.Ins.activity_onlinegift.Values.ToList().ConvertAll(mo => new GiftInfo(mo)); public class GiftInfo { private readonly Player p = UserProxy.Instance.player; /// /// 时长(TimeSpan)(秒) /// public readonly sm_activity_onlinegift _mo; public GiftInfo(sm_activity_onlinegift _ts) => _mo = _ts; /// /// mo /// public sm_activity_onlinegift Mo => _mo; /// /// 换算为分钟 /// public int Minutes => Mo?.onlineSec / 60 ?? 0; /// /// 奖励道具 /// public ItemVo reward_item => ItemVo.ParsItemContentStr(Mo?.rewardstr ?? "").First(); /// /// 是否已经领取奖励 /// /// public bool HasDrawed() => p.PrivateState.onlineGiftIDs.Contains(Mo.typeId); /// /// 是否可以领取奖励 /// /// public bool CanDraw() => p.PrivateState.onlineGiftts >= Mo.onlineSec; } } } #endregion }