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/Battle/BattleManager.cs | 323 ++++++++++++++++++++++++++++++-----------------------
1 files changed, 181 insertions(+), 142 deletions(-)
diff --git a/Main/System/Battle/BattleManager.cs b/Main/System/Battle/BattleManager.cs
index 7c22487..13c35bb 100644
--- a/Main/System/Battle/BattleManager.cs
+++ b/Main/System/Battle/BattleManager.cs
@@ -2,6 +2,7 @@
using UnityEngine;
using LitJson;
using System;
+using System.Linq;
public class BattleManager : GameSystemManager<BattleManager>
{
@@ -10,10 +11,30 @@
// 鍚屾椂鍙兘鏈変竴鍦烘垬鏂楀湪杩涜 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 int[] challengeBossGuides;
public Action<string, BattleField> onBattleFieldCreate;
- public Action<string, BattleField> onBattleFieldDestroy;
+ public Action onBattleFieldDestroy;
public bool isWaitServerStory = false; //涓荤嚎绛夋湇鍔$鍥炴姤 0425
@@ -24,8 +45,25 @@
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);
+ challengeBossGuides = JsonMapper.ToObject<int[]>(config.Numerical4);
+
+ config = FuncConfigConfig.Get("BattleButton");
+ passRound= int.Parse(config.Numerical1);
+ }
+
public override void Release()
{
@@ -37,8 +75,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 +101,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
{
@@ -105,6 +147,7 @@
{
if (!allow)
{
+ _package.socketType = ServerType.MainFight;
packQueue.Enqueue(_package);
}
}
@@ -126,6 +169,31 @@
List<GameNetPackBasic> packQueueSnapshot = new List<GameNetPackBasic>(packQueue);
List<GameNetPackBasic> newPackList = ParseBattlePackList(string.Empty, packQueueSnapshot);
+
+#if UNITY_EDITOR
+ Action printNewPack = () =>
+ {
+ string temp = "After AnalysisPackQueueAndDistribute newPackList count: " + newPackList.Count + "\n";
+ foreach (var pack in newPackList)
+ {
+ if (pack is CustomHB426CombinePack b426Pack)
+ {
+ temp += " pack type is " + pack.GetType().Name + " tag is " + (b426Pack.startTag != null ? b426Pack.startTag.Tag : "null") + "\n";
+ }
+ else if (pack is CustomB421ActionPack b421Pack)
+ {
+ temp += " pack type is " + pack.GetType().Name + " guid is " + b421Pack.guid + "\n";
+ }
+ else
+ {
+ temp += " pack type is " + pack.GetType().Name + "\n";
+ }
+ }
+ Debug.LogWarning(temp);
+ };
+
+ printNewPack();
+#endif
// HashSet<int> skipIndexes = new HashSet<int>();
// // 杩欓噷宸茬粡鏄寜鐓equeue鐨勯『搴忎簡
@@ -210,127 +278,15 @@
public static List<GameNetPackBasic> ParseBattlePackList(string guid, List<GameNetPackBasic> packQueueSnapshot)
{
- bool wrong = false;
+ var list = CustomHB426CombinePack.CombineToSkillPackFromList(guid, packQueueSnapshot);
+ // string str = "ParseBattlePackList \n";
+ // for (int i = 0; i < list.Count; i++)
+ // {
+ // str += " " + list[i].GetType().Name + "\n";
+ // }
+ // BattleDebug.LogError(str);
+ return list;
- List<GameNetPackBasic> newPackList = new List<GameNetPackBasic>();
-
- HB421_tagMCTurnFightObjAction b421Pack = null;
-
- for (int i = 0; i < packQueueSnapshot.Count; i++)
- {
- GameNetPackBasic pack = packQueueSnapshot[i];
- if (null == b421Pack)
- {
- if (pack is HB421_tagMCTurnFightObjAction _b421)
- {
- b421Pack = _b421;
- }
- else
- {
- newPackList.Add(pack);
- }
- continue;
- }
- else
- {
- List<GameNetPackBasic> b421List = new List<GameNetPackBasic>();
-
- bool find = false;
-
- for (int k = i; k < packQueueSnapshot.Count; k++/*, Debug.LogError(k + " : is plusing")*/)
- {
- GameNetPackBasic maybeB426Pack = packQueueSnapshot[k];
-
- if (maybeB426Pack is HB426_tagSCTurnFightTag b426Pack)
- {
- // Debug.LogError(k + " : find b426 " + maybeB426Pack.packUID + " sign " + b426Pack.Sign + " tag " + b426Pack.Tag);
- if (b426Pack.Sign == 0)
- {
- find = true;
- List<GameNetPackBasic> b426List = new List<GameNetPackBasic>();
- b426List.Add(b426Pack);
- for (int j = k + 1; j < packQueueSnapshot.Count; j++)
- {
- GameNetPackBasic maybeB426EndPack = packQueueSnapshot[j];
- if (maybeB426EndPack is HB426_tagSCTurnFightTag b426EndPack)
- {
- // Debug.LogError(j + " : find b426 end pack : " + b426EndPack.packUID + " sign " + b426EndPack.Sign + " tag " + b426EndPack.Tag);
-
- if (b426EndPack.Tag == b426Pack.Tag)
- {
- if (b426EndPack.Sign == 1)
- {
- b426List.Add(maybeB426EndPack);
- k = j;
- i = k;
- break;
- }
- else
- {
- Debug.LogError("閿欒鐨凷ign == 1");
- continue;
- }
- }
- else
- {
- // 鏂扮殑涓�瀵�
- }
- }
- else
- {
- b426List.Add(maybeB426EndPack);
- k = j;
- i = k;
- }
- }
- // 杩欓噷闈㈢殑b421杩樻病澶勭悊
- List<GameNetPackBasic> combinedList = CustomHB426CombinePack.CombineToSkillPackFromList(guid, b426List);
- b421List.AddRange(combinedList);
- }
- else
- {
- wrong = true;
- Debug.LogError("閿欒鐨刡426 鍒嗘瀽鏈夐棶棰� " + b426Pack.packUID);
- }
- }
- else
- {
- if (!find)
- {
- newPackList.Add(maybeB426Pack);
- i = k;
- }
- else
- {
- if (maybeB426Pack is HB421_tagMCTurnFightObjAction _b421)
- {
- i = k - 1;
- break;
- }
-
- b421List.Add(maybeB426Pack);
- i = k;
- }
- }
- }
- CustomB421ActionPack actionPack = CustomB421ActionPack.CreateB421ActionPack(guid, b421List);
- newPackList.Add(actionPack);
- b421Pack = null;
- }
- }
-
- if (wrong)
- {
- string output = string.Empty;
- for (int f = 0; f < packQueueSnapshot.Count; f++)
- {
- output += (packQueueSnapshot[f].packUID + "&" + packQueueSnapshot[f].GetType().ToString() + "|");
- }
-
- Debug.LogError(output);
- }
-
- return newPackList;
}
// 涓撳睘浜庝富绾挎垬鏂楃殑娲惧彂
@@ -447,11 +403,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)
@@ -484,6 +447,11 @@
return;
}
+ if (queue.Count <= 0)
+ {
+ return;
+ }
+
var pack = queue.Dequeue();
// Debug.LogError("DistributeNextReportPackage for guid : " + guid + " pack type : " + pack.GetType());
@@ -506,25 +474,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))
@@ -535,14 +494,21 @@
isCreate = false;
}
else
- {
+ {
BattleDebug.LogError("鎴樺満宸插瓨鍦� 鍏堣繘琛岄攢姣�");
battleField.Destroy();
}
}
+ var bf = GetBattleFieldByMapID(MapID);
+ if (bf != null && !string.IsNullOrEmpty(guid))
+ {
+ BattleDebug.LogError("鐩稿悓鍦板浘ID鐨勬垬鍦哄凡瀛樺湪 鍏堣繘琛岄攢姣�");
+ bf.Destroy();
+ }
+
if (isCreate)
- {
+ {
battleField = BattleFieldFactory.CreateBattleField(guid, MapID, FuncLineID, extendData, redTeamList, blueTeamList);
if (string.IsNullOrEmpty(guid))
@@ -555,7 +521,7 @@
- battleField.Init(MapID, FuncLineID, extendData, redTeamList, blueTeamList);
+ battleField.Init(MapID, FuncLineID, extendData, redTeamList, blueTeamList, vNetData.TurnMax);
return battleField;
}
@@ -583,7 +549,7 @@
GameObject.DestroyImmediate(battleField.battleRootNode.gameObject);
- onBattleFieldDestroy?.Invoke(battleField.guid, battleField);
+ onBattleFieldDestroy?.Invoke();
}
@@ -596,6 +562,7 @@
// 4-缁х画鎴樻枟 - 鐜╁涓荤嚎鎴樻枟涓紙鍖呭惈涓荤嚎灏忔��佷富绾縝oss锛夛紝鍓嶇琛ㄧ幇瀹屽悗绔悓姝ョ殑鎴樻枟鐗囨鍚庯紝鍙啀鍥炲璇ュ�硷紝鍚庣浼氭牴鎹垬鏂楅�昏緫鍙婃祦绋嬭嚜鍔ㄥ洖澶嶄笅涓�娈电殑鎴樻枟鐗囨灏佸寘锛屼竴鐩村惊鐜�
public void MainFightRequest(byte reqType, uint reqValue = 0)
{
+ // Debug.LogError("MainFightRequest reqType " + reqType + " reqValue " + reqValue);
CB413_tagCSMainFightReq req = new CB413_tagCSMainFightReq();
req.ReqType = reqType;
req.ReqValue = reqValue;
@@ -635,4 +602,76 @@
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;
+ }
+
+ public void DestroyAllBattleField()
+ {
+ var battleFieldsList = battleFields.Values.ToList();
+ foreach (var battleField in battleFieldsList)
+ {
+ if (battleField == null)
+ continue;
+ battleField.Destroy();
+ }
+ }
+
}
\ No newline at end of file
--
Gitblit v1.8.0