From 39001a600fcae2bcf27c225df8752d75fb92fef4 Mon Sep 17 00:00:00 2001
From: yyl <yyl>
Date: 星期五, 31 十月 2025 11:18:26 +0800
Subject: [PATCH] Merge branch 'master' of http://192.168.1.20:10010/r/Project_SG_scripts
---
Main/System/Battle/BattleManager.cs | 146 +++++++++++++++++++++++++++++++++++++++++-------
1 files changed, 124 insertions(+), 22 deletions(-)
diff --git a/Main/System/Battle/BattleManager.cs b/Main/System/Battle/BattleManager.cs
index 966d0e7..f879dec 100644
--- a/Main/System/Battle/BattleManager.cs
+++ b/Main/System/Battle/BattleManager.cs
@@ -10,10 +10,29 @@
// 鍚屾椂鍙兘鏈変竴鍦烘垬鏂楀湪杩涜 guid, battlefield
protected Dictionary<string, BattleField> battleFields = new Dictionary<string, BattleField>();
+ public float[] speedGear; //鎴樻枟鍊嶆暟瀵瑰簲鐨勫疄闄呴�熺巼
+ public int speedIndex
+ {
+ get
+ {
+ return QuickSetting.Instance.GetQuickSettingValue<int>(QuickSettingType.BattleSpeed, 0);
+ }
+ set
+ {
+ QuickSetting.Instance.SetQuickSetting(QuickSettingType.BattleSpeed, value);
+ QuickSetting.Instance.SendPackage();
+ }
+ }
+ public readonly int[] speedIndexfuncIdArr = new int[] { 34, 35, 36 }; // 鎴樻枟鍊嶆暟瀵瑰簲鐨勫姛鑳絀D
+ public readonly int passFuncId = 33; // 璺宠繃鎴樻枟瀵瑰簲鐨勫姛鑳絀D
+ public int passRound; // 瓒呰繃X鍥炲悎鍙烦杩�
+ public int fightGuideID;
+ public int fightGuideMainLevelLimit;
+ public int fightGuideNoClickSeconds;
public Action<string, BattleField> onBattleFieldCreate;
- public Action<string, BattleField> onBattleFieldDestroy;
+ public Action onBattleFieldDestroy;
public bool isWaitServerStory = false; //涓荤嚎绛夋湇鍔$鍥炴姤 0425
@@ -24,8 +43,24 @@
LogicEngine.Instance.OnUpdate += Run;
DTC0403_tagPlayerLoginLoadOK.playerLoginOkEvent += OnPlayerLoginOk;
DTC0102_tagCDBPlayer.beforePlayerDataInitializeEvent += BeforePlayerInit;
+ ParseConfig();
}
+
+ void ParseConfig()
+ {
+ var config = FuncConfigConfig.Get("AutoGuaji");
+ speedGear = JsonMapper.ToObject<float[]>(config.Numerical4);
+
+ config = FuncConfigConfig.Get("FightGuide");
+ fightGuideID = int.Parse(config.Numerical1);
+ fightGuideMainLevelLimit = int.Parse(config.Numerical2);
+ fightGuideNoClickSeconds = int.Parse(config.Numerical3);
+
+ config = FuncConfigConfig.Get("BattleButton");
+ passRound= int.Parse(config.Numerical1);
+ }
+
public override void Release()
{
@@ -37,8 +72,8 @@
protected void OnPlayerLoginOk()
{
- long exAttr1 = PlayerDatas.Instance.GetPlayerDataByType(PlayerDataType.ExAttr1);
- long exAttr2 = PlayerDatas.Instance.GetPlayerDataByType(PlayerDataType.ExAttr2);
+ long exAttr1 = PlayerDatas.Instance.baseData.ExAttr1;
+ long exAttr2 = PlayerDatas.Instance.baseData.ExAttr2;
int MapID = 1;
int FuncLineID = (int)exAttr2;
@@ -63,7 +98,11 @@
redTeamList.Add(storyTeam);
- CreateBattleField(string.Empty, MapID, FuncLineID, extendData, redTeamList, blueTeamList);
+ HB424_tagSCTurnFightInit vNetData = new HB424_tagSCTurnFightInit();
+ vNetData.MapID = (uint)MapID;
+ vNetData.FuncLineID = (uint)FuncLineID;
+
+ CreateBattleField(string.Empty, vNetData, extendData, redTeamList, blueTeamList);
}
else
{
@@ -240,7 +279,7 @@
{
str += " " + list[i].GetType().Name + "\n";
}
- BattleDebug.LogError(str);
+ // BattleDebug.LogError(str);
return list;
}
@@ -359,11 +398,18 @@
{
uidList.Add(packUID);
}
+
}
public BattleField GetBattleField(ulong packUID)
{
- return GetBattleField(GetGUID(packUID));
+ string guid = GetGUID(packUID);
+ BattleField battleField = GetBattleField(GetGUID(packUID));
+ if (battleField == null || battleField.rejectNewPackage)
+ {
+ return null;
+ }
+ return battleField;
}
public BattleField GetBattleField(string guid)
@@ -396,6 +442,11 @@
return;
}
+ if (queue.Count <= 0)
+ {
+ return;
+ }
+
var pack = queue.Dequeue();
// Debug.LogError("DistributeNextReportPackage for guid : " + guid + " pack type : " + pack.GetType());
@@ -418,25 +469,16 @@
catch (Exception ex)
{
Debug.LogError("DistributeNextPackage: 鍒嗗彂鍖呭紓甯� " + ex);
- // 鍑洪敊鏃朵富鍔ㄧЩ闄ゅ綋鍓嶅寘锛岄槻姝㈡寰幆
- if (packQueue.Count > 0)
- {
- packQueue.Dequeue();
- }
}
-
- if (queue.Count <= 0)
- {
- battleReportDict.Remove(guid);
- battlePackRelationList.Remove(guid);
- }
-
}
#endregion
- public BattleField CreateBattleField(string guid, int MapID, int FuncLineID, JsonData extendData, List<TeamBase> redTeamList, List<TeamBase> blueTeamList)
+ public BattleField CreateBattleField(string guid, HB424_tagSCTurnFightInit vNetData, JsonData extendData, List<TeamBase> redTeamList, List<TeamBase> blueTeamList)
{
BattleField battleField = null;
+
+ int MapID = (int)vNetData.MapID;
+ int FuncLineID = (int)vNetData.FuncLineID;
bool isCreate = true;
if (battleFields.TryGetValue(guid, out battleField))
@@ -454,7 +496,7 @@
}
if (isCreate)
- {
+ {
battleField = BattleFieldFactory.CreateBattleField(guid, MapID, FuncLineID, extendData, redTeamList, blueTeamList);
if (string.IsNullOrEmpty(guid))
@@ -467,7 +509,7 @@
- battleField.Init(MapID, FuncLineID, extendData, redTeamList, blueTeamList);
+ battleField.Init(MapID, FuncLineID, extendData, redTeamList, blueTeamList, vNetData.TurnMax);
return battleField;
}
@@ -495,7 +537,7 @@
GameObject.DestroyImmediate(battleField.battleRootNode.gameObject);
- onBattleFieldDestroy?.Invoke(battleField.guid, battleField);
+ onBattleFieldDestroy?.Invoke();
}
@@ -548,4 +590,64 @@
return null;
}
+
+ //鍙戣繘鍏ユ垬鏂楀寘
+ private float lastTime = 0f;
+ private float turnCoolDown = 0.5f; // 鍐峰嵈鏃堕棿
+ public void SendTurnFight(uint mapID, uint funcLineID = 0, byte tagType = 0, uint tagID = 0, uint[] valueList = null)
+ {
+ // 杩炵画棰戠箒鍙戝寘锛岃Е鍙戞彁绀�
+ float currentTime = Time.time;
+ if (currentTime - lastTime < turnCoolDown)
+ {
+ SysNotifyMgr.Instance.ShowTip("BattleCoolDown");
+ return;
+ }
+ lastTime = currentTime;
+
+ CB410_tagCMTurnFight pack = new CB410_tagCMTurnFight();
+ pack.MapID = mapID;
+ pack.FuncLineID = funcLineID;
+ pack.TagType = tagType;
+ pack.TagID = tagID;
+ if (!valueList.IsNullOrEmpty())
+ {
+ pack.ValueList = valueList;
+ pack.ValueCount = (byte)valueList.Length;
+ }
+ GameNetSystem.Instance.SendInfo(pack);
+ }
+
+ // 鑾峰彇褰撳墠姝e湪鏄剧ず鐨勬垬鏂楀満鏅悕绉帮紝濡傛灉娌℃湁鍒欒繑鍥炵┖瀛楃涓�
+ public string GetActiveBattleName()
+ {
+ foreach (var kvp in battleFields)
+ {
+ BattleField battleField = kvp.Value;
+ if (battleField == null)
+ continue;
+
+ var battleName = battleField.ToString();
+ if (BattleConst.battleNameToWinName.ContainsKey(battleName)
+ && UIManager.Instance.IsOpened(BattleConst.battleNameToWinName[battleName]))
+ return battleName;
+ }
+ return "";
+ }
+
+ // 鑾峰彇褰撳墠姝e湪鏄剧ず鐨勬垬鏂楀満鏅�,濡傛灉娌℃湁鍒欒繑鍥瀗ull
+ public BattleField GetActiveBattleFieldByName(string battleName)
+ {
+ foreach (var kvp in battleFields)
+ {
+ BattleField battleField = kvp.Value;
+ if (battleField == null)
+ continue;
+
+ var name = battleField.ToString();
+ if (name == battleName)
+ return battleField;
+ }
+ return null;
+ }
}
\ No newline at end of file
--
Gitblit v1.8.0