From 9e89e605d5429babb4b33df2e47ea86dff9d2ba7 Mon Sep 17 00:00:00 2001
From: yyl <yyl>
Date: 星期四, 20 十一月 2025 11:55:04 +0800
Subject: [PATCH] Merge branch 'master' of http://192.168.1.20:10010/r/Project_SG_scripts
---
Main/System/Invest/InvestModel.cs | 322 ++++++++++++++++++++++++++++++++++++++++-------------
1 files changed, 243 insertions(+), 79 deletions(-)
diff --git a/Main/System/Invest/InvestModel.cs b/Main/System/Invest/InvestModel.cs
index 1634716..a11b019 100644
--- a/Main/System/Invest/InvestModel.cs
+++ b/Main/System/Invest/InvestModel.cs
@@ -12,26 +12,45 @@
//鎶曡祫瀵瑰簲濂栧姳
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>(); //鎶曡祫瀵瑰簲鏈�澶ц喘涔扮疮鍔犲ぉ鏁�
+
//鎶曡祫瀵瑰簲鍏呭�糏D
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>>();
+ //鍓湰璐拱娆℃暟鍏嶈垂鐨勫壇鏈琁D 鍜� 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();
@@ -41,9 +60,8 @@
public override void Release()
{
- FuncOpen.Instance.OnFuncStateChangeEvent -= OnFuncStateChangeEvent;
DTC0102_tagCDBPlayer.beforePlayerDataInitializeEvent -= OnBeforePlayerDataInitialize;
- DTC0403_tagPlayerLoginLoadOK.playerLoginOkEvent -= OnPlayerLoginOk;
+ RechargeManager.Instance.rechargeCountEvent -= OnRechargeCountEvent;
}
public bool IsOpen()
@@ -55,86 +73,88 @@
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;
}
@@ -149,7 +169,7 @@
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;
}
//姘镐箙绫诲瀷鐨勬姇璧� 鍙璐拱浜嗗氨绠楁姇璧�
@@ -157,19 +177,8 @@
}
-
- 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;
@@ -180,15 +189,12 @@
//璐拱鎶曡祫
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()
{
@@ -197,7 +203,7 @@
AwardState = package.AwardState
};
-
+
UpdateRedpoint();
if (onInvestUpdate != null)
@@ -213,9 +219,167 @@
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
{
--
Gitblit v1.8.0