| | |
| | | |
| | | //投资对应奖励 |
| | | Dictionary<int, int[][]> m_InvestItems = new Dictionary<int, int[][]>(); |
| | | Dictionary<int, int> m_InvestDays = new Dictionary<int, int>(); //投资对应天数 |
| | | Dictionary<int, int> m_InvestMaxDays = new Dictionary<int, int>(); //投资对应最大购买累加天数 |
| | | |
| | | //投资对应充值ID |
| | | Dictionary<int, int[]> m_InvestRechargeIds = new Dictionary<int, int[]>(); |
| | | Dictionary<int, int> m_InvestCTGIDToType = new Dictionary<int, int>(); |
| | | |
| | | //投资对应购买情况 |
| | | Dictionary<int, InvestInfo> m_InvestInfos = new Dictionary<int, InvestInfo>(); |
| | | //投资类型 |
| | | public List<int> investTypes = new List<int>(); |
| | | |
| | | //--特权-- |
| | | //增加副本购买次数 |
| | | Dictionary<int, Dictionary<int, int>> m_InvestAddFBCount = new Dictionary<int, Dictionary<int, int>>(); |
| | | //副本购买次数免费的副本ID 和 m_InvestAddFBCount 配合使用 相当于 特权增加副本上限但是发包流程需和服务端商量 |
| | | Dictionary<int, int[]> m_InvestFreeFBID = new Dictionary<int, int[]>(); |
| | | //演武场增加上限 |
| | | Dictionary<int, int> m_InvestArenaMaxCnt = new Dictionary<int, int>(); |
| | | //祝福树能量增加上限 |
| | | Dictionary<int, int> m_InvestAddBlessEnergyCount = new Dictionary<int, int>(); |
| | | |
| | | // 特权权限数量 |
| | | Dictionary<int, int> m_PrivilegeLins = new Dictionary<int, int>(); |
| | | // 战斗倍数开启对应特权 |
| | | Dictionary<int, int> m_PrivilegeFightSpeed = new Dictionary<int, int>(); |
| | | // 英雄积分招募开启的特权类型 |
| | | int[] heroScoreCallOpenType; |
| | | |
| | | |
| | | public event Action<int> onInvestUpdate; |
| | | |
| | | public const int redpointID = 20931; |
| | | public Redpoint redpoint = new Redpoint(redpointID); |
| | | public Redpoint redpoint1 = new Redpoint(MainRedDot.RedPoint_PrivilegeCard, MainRedDot.RedPoint_PrivilegeCard * 10 + 1); |
| | | public Redpoint redpoint2 = new Redpoint(MainRedDot.RedPoint_PrivilegeCard, MainRedDot.RedPoint_PrivilegeCard * 10 + 2); |
| | | |
| | | |
| | | public override void Init() |
| | | { |
| | | FuncOpen.Instance.OnFuncStateChangeEvent += OnFuncStateChangeEvent; |
| | | DTC0102_tagCDBPlayer.beforePlayerDataInitializeEvent += OnBeforePlayerDataInitialize; |
| | | DTC0403_tagPlayerLoginLoadOK.playerLoginOkEvent += OnPlayerLoginOk; |
| | | |
| | | RechargeManager.Instance.rechargeCountEvent += OnRechargeCountEvent; |
| | | //通过配置决定是否有此投资项,如港台没有登录投资 |
| | | ParseConfig(); |
| | | |
| | |
| | | |
| | | public override void Release() |
| | | { |
| | | FuncOpen.Instance.OnFuncStateChangeEvent -= OnFuncStateChangeEvent; |
| | | DTC0102_tagCDBPlayer.beforePlayerDataInitializeEvent -= OnBeforePlayerDataInitialize; |
| | | DTC0403_tagPlayerLoginLoadOK.playerLoginOkEvent -= OnPlayerLoginOk; |
| | | RechargeManager.Instance.rechargeCountEvent -= OnRechargeCountEvent; |
| | | } |
| | | |
| | | public bool IsOpen() |
| | |
| | | public void OnBeforePlayerDataInitialize() |
| | | { |
| | | m_InvestInfos.Clear(); |
| | | lastTotalBuyCountDict.Clear(); |
| | | } |
| | | |
| | | public void OnPlayerLoginOk() |
| | | { |
| | | UpdateRedpoint(); |
| | | } |
| | | |
| | | |
| | | void ParseConfig() |
| | | { |
| | | var funcConfig = FuncConfigConfig.Get("InvestCost"); |
| | | m_InvestRechargeIds = ConfigParse.ParseIntArrayDict(funcConfig.Numerical1); |
| | | foreach (var item in m_InvestRechargeIds) |
| | | { |
| | | m_InvestCTGIDToType[item.Value[0]] = item.Key; |
| | | } |
| | | |
| | | funcConfig = FuncConfigConfig.Get("InvestDay"); |
| | | m_InvestDays = ConfigParse.ParseIntDict(funcConfig.Numerical1); |
| | | m_InvestMaxDays = ConfigParse.ParseIntDict(funcConfig.Numerical2); |
| | | m_InvestItems = ConfigParse.ParseIntArray2Dict(funcConfig.Numerical3); |
| | | |
| | | investTypes = m_InvestRechargeIds.Keys.ToList(); |
| | | investTypes.Sort(); |
| | | |
| | | funcConfig = FuncConfigConfig.Get("InvestPower"); |
| | | m_InvestAddFBCount = ConfigParse.ParseDictInDict(funcConfig.Numerical1); |
| | | m_InvestFreeFBID = ConfigParse.ParseIntArrayDict(funcConfig.Numerical2); |
| | | m_InvestArenaMaxCnt = ConfigParse.ParseIntDict(funcConfig.Numerical3); |
| | | m_InvestAddBlessEnergyCount = ConfigParse.ParseIntDict(funcConfig.Numerical4); |
| | | |
| | | funcConfig = FuncConfigConfig.Get("PrivilegeCard"); |
| | | m_PrivilegeLins = ConfigParse.ParseIntDict(funcConfig.Numerical1); |
| | | m_PrivilegeFightSpeed = ConfigParse.ParseIntDict(funcConfig.Numerical2); |
| | | heroScoreCallOpenType = JsonMapper.ToObject<int[]>(funcConfig.Numerical3); |
| | | |
| | | } |
| | | |
| | | public OrderInfoConfig GetOrderInfoId(int type) |
| | | Dictionary<int, int> lastTotalBuyCountDict = new Dictionary<int, int>(); |
| | | void OnRechargeCountEvent(int ctgID) |
| | | { |
| | | var ids = m_InvestRechargeIds[type]; |
| | | for (int i = 0; i < ids.Length; i++) |
| | | |
| | | if (m_InvestCTGIDToType.ContainsKey(ctgID)) |
| | | { |
| | | OrderInfoConfig config; |
| | | if (RechargeManager.Instance.TryGetOrderInfo(ids[i], out config)) |
| | | var type = m_InvestCTGIDToType[ctgID]; |
| | | RechargeManager.Instance.TryGetRechargeCount(ctgID, out var rechargeCount); |
| | | if (!DTC0403_tagPlayerLoginLoadOK.finishedLogin) |
| | | { |
| | | return config; |
| | | lastTotalBuyCountDict[type] = rechargeCount.totalCount; |
| | | return; |
| | | } |
| | | var count = 0; |
| | | lastTotalBuyCountDict.TryGetValue(type, out count); |
| | | if (count < rechargeCount.totalCount) |
| | | { |
| | | lastTotalBuyCountDict[type] = rechargeCount.totalCount; |
| | | UIManager.Instance.OpenWindow<PrivilegeActiveCardWin>(type); |
| | | } |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | |
| | | public bool hasInvestType(int type) |
| | | |
| | | //获取投资剩余时间 秒 |
| | | public int GetInvestLeftTime(int type) |
| | | { |
| | | return investTypes.Contains(type); |
| | | if (type == 1 && m_InvestInfos[type].InvestEndTime > 0) |
| | | { |
| | | //月卡 限时类型的投资 未到期就算投资 |
| | | return m_InvestInfos[type].InvestEndTime - TimeUtility.AllSeconds; |
| | | } |
| | | return 0; |
| | | } |
| | | |
| | | |
| | | // public int GetInvestPassDays(int type) |
| | | // { |
| | | // return m_InvestInfos.ContainsKey(type) ? m_InvestInfos[type].days : 0; |
| | | // } |
| | | |
| | | |
| | | |
| | | //id 为表里的ID |
| | | //0-未投资 1-未达成 2-可领取 3-已领取 |
| | | public int GetSingleInvestState(int type, int id) |
| | | //0-未投资 1-可领取 2-已领取 |
| | | public int GetInvestState(int type) |
| | | { |
| | | // if (IsInvested(type)) |
| | | // { |
| | | // var day = GetInvestPassDays(type); |
| | | // if (m_InvestItems.ContainsKey(type) |
| | | // && m_InvestItems[type].ContainsKey(id)) |
| | | // { |
| | | // if (IsRewardGot(type, id)) |
| | | // { |
| | | // return 3; |
| | | // } |
| | | // var config = InvestConfig.Get(id); |
| | | |
| | | // if (!m_InvestSingleInfos.ContainsKey(type)) |
| | | // { |
| | | // return 0; |
| | | // } |
| | | |
| | | // var index = id % 100; |
| | | // //每个数按位存31个激活索引 |
| | | // var listIndex = index / 31; |
| | | // var bitIndex = index % 31; |
| | | |
| | | |
| | | // return day < config.needDay ? 1 : 2; |
| | | // } |
| | | // } |
| | | if (IsInvested(type)) |
| | | { |
| | | if (m_InvestInfos[type].AwardState == 0) |
| | | { |
| | | return 1; |
| | | } |
| | | return 2; |
| | | } |
| | | return 0; |
| | | } |
| | | |
| | |
| | | if (type == 1) |
| | | { |
| | | //月卡 限时类型的投资 未到期就算投资 |
| | | return m_InvestInfos[type].InvestEndTime > 0 && m_InvestInfos[type].InvestEndTime < TimeUtility.AllSeconds; |
| | | return m_InvestInfos[type].InvestEndTime > 0 && m_InvestInfos[type].InvestEndTime > TimeUtility.AllSeconds; |
| | | } |
| | | |
| | | //永久类型的投资 只要购买了就算投资 |
| | |
| | | } |
| | | |
| | | |
| | | |
| | | private void OnFuncStateChangeEvent(int id) |
| | | { |
| | | if (id == (int)FuncOpenEnum.PrivilegeCard) |
| | | { |
| | | UpdateRedpoint(); |
| | | } |
| | | |
| | | } |
| | | |
| | | |
| | | |
| | | public void SendGetReward(int type, int id) |
| | | //type 投资类型 |
| | | public void SendGetReward(int type, int id = 0) |
| | | { |
| | | var pak = new CA541_tagCMGetInvestReward(); |
| | | pak.InvestType = (byte)type; |
| | |
| | | //购买投资 |
| | | public void BuyInvest(int type) |
| | | { |
| | | RechargeManager.Instance.CTG(GetOrderInfoId(type)); |
| | | RechargeManager.Instance.CTG(GetOrderInfo(type)); |
| | | } |
| | | |
| | | |
| | | public void UpdateInvestInfo(HA338_tagSCInvestInfo package) |
| | | { |
| | | if (!investTypes.Contains(package.InvestType)) |
| | | { |
| | | return; |
| | | } |
| | | |
| | | m_InvestInfos[package.InvestType] = new InvestInfo() |
| | | { |
| | |
| | | AwardState = package.AwardState |
| | | }; |
| | | |
| | | |
| | | |
| | | UpdateRedpoint(); |
| | | |
| | | if (onInvestUpdate != null) |
| | |
| | | return; |
| | | } |
| | | |
| | | redpoint1.state = GetInvestState(monthCardType) == 1 ? RedPointState.Simple : RedPointState.None; |
| | | redpoint2.state = GetInvestState(foreverCardType) == 1 ? RedPointState.Simple : RedPointState.None; |
| | | |
| | | } |
| | | |
| | | |
| | | #region 特权接口 |
| | | |
| | | //副本增加的购买次数上限 |
| | | public int GetAddFBBuyCount(int _mapID) |
| | | { |
| | | int addCount = 0; |
| | | foreach (var item in m_InvestAddFBCount) |
| | | { |
| | | if (!IsInvested(item.Key)) |
| | | { |
| | | continue; |
| | | } |
| | | foreach (var mapID in item.Value.Keys) |
| | | { |
| | | if (mapID == _mapID) |
| | | { |
| | | addCount += item.Value[mapID]; |
| | | } |
| | | } |
| | | } |
| | | |
| | | return addCount; |
| | | } |
| | | |
| | | //副本免费的购买次数 |
| | | public bool GetFBIsFree(int _mapID) |
| | | { |
| | | foreach (var item in m_InvestFreeFBID) |
| | | { |
| | | if (!IsInvested(item.Key)) |
| | | { |
| | | continue; |
| | | } |
| | | foreach (var mapID in item.Value) |
| | | { |
| | | if (mapID == _mapID) |
| | | { |
| | | return true; |
| | | } |
| | | } |
| | | } |
| | | return false; |
| | | } |
| | | |
| | | |
| | | public int GetPrivilegeLins(int type) |
| | | { |
| | | if (m_PrivilegeLins.ContainsKey(type)) |
| | | { |
| | | return m_PrivilegeLins[type]; |
| | | } |
| | | return 0; |
| | | } |
| | | |
| | | public OrderInfoConfig GetOrderInfo(int type) |
| | | { |
| | | var ids = m_InvestRechargeIds[type]; |
| | | for (int i = 0; i < ids.Length; i++) |
| | | { |
| | | OrderInfoConfig config; |
| | | if (RechargeManager.Instance.TryGetOrderInfo(ids[i], out config)) |
| | | { |
| | | return config; |
| | | } |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | public int GetCTGID(int type) |
| | | { |
| | | return m_InvestRechargeIds[type][0]; |
| | | } |
| | | |
| | | public int[][] GetDayAwards(int type) |
| | | { |
| | | return m_InvestItems[type]; |
| | | } |
| | | |
| | | //演武场凭证上限 |
| | | public int GetArenaAddMaxCount() |
| | | { |
| | | int addCount = 0; |
| | | foreach (var item in m_InvestArenaMaxCnt) |
| | | { |
| | | if (!IsInvested(item.Key)) |
| | | { |
| | | continue; |
| | | } |
| | | addCount += item.Value; |
| | | } |
| | | |
| | | return addCount; |
| | | } |
| | | |
| | | //购买天数是否达上限 |
| | | public bool IsBuyMaxDay(int type) |
| | | { |
| | | if (m_InvestMaxDays.ContainsKey(type) && m_InvestInfos.ContainsKey(type)) |
| | | { |
| | | if (m_InvestInfos[type].InvestEndTime > 0) |
| | | { |
| | | return (m_InvestInfos[type].InvestEndTime - TimeUtility.AllSeconds) / 60 / 60 / 24 + m_InvestDays[type] >= m_InvestMaxDays[type]; |
| | | } |
| | | } |
| | | return false; |
| | | } |
| | | |
| | | //祝福能量上限 |
| | | public int GetBlessAddEnergyMax() |
| | | { |
| | | int addCount = 0; |
| | | foreach (var item in m_InvestAddBlessEnergyCount) |
| | | { |
| | | if (!IsInvested(item.Key)) |
| | | { |
| | | continue; |
| | | } |
| | | addCount += item.Value; |
| | | } |
| | | |
| | | return addCount; |
| | | } |
| | | |
| | | //是否激活英雄积分召唤 |
| | | public bool IsActiveHeroScoreCall() |
| | | { |
| | | foreach (var type in heroScoreCallOpenType) |
| | | { |
| | | if (IsInvested(type)) |
| | | { |
| | | return true; |
| | | } |
| | | } |
| | | return false; |
| | | } |
| | | |
| | | public bool IsActiveFightSpeed(int speed) |
| | | { |
| | | foreach (var item in m_PrivilegeFightSpeed) |
| | | { |
| | | if (!IsInvested(item.Key)) |
| | | { |
| | | continue; |
| | | } |
| | | if (item.Value == speed) |
| | | { |
| | | return true; |
| | | } |
| | | } |
| | | return false; |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | |
| | | |
| | | |
| | | public struct InvestInfo |
| | | { |