From 81298e554df8d11aeefe7b08aa3d45f1593bf586 Mon Sep 17 00:00:00 2001
From: hch <305670599@qq.com>
Date: 星期二, 29 七月 2025 21:11:42 +0800
Subject: [PATCH] 0312 防范报错
---
Main/System/Battle/BattleField/BattleField.cs | 3 ++-
Main/System/Team/TeamManager.cs | 4 ++--
Main/System/Battle/BattleObject/BattleObject.cs | 2 +-
Main/System/Battle/BattleObject/BattleObjectFactory.cs | 2 +-
Main/System/Battle/BattleObject/BattleObjMgr.cs | 16 +++++++++-------
Main/System/HeroUI/HeroListWin.cs | 2 ++
Main/System/HeroUI/HeroUIManager.cs | 27 +++++----------------------
7 files changed, 22 insertions(+), 34 deletions(-)
diff --git a/Main/System/Battle/BattleField/BattleField.cs b/Main/System/Battle/BattleField/BattleField.cs
index d2006d5..9193c08 100644
--- a/Main/System/Battle/BattleField/BattleField.cs
+++ b/Main/System/Battle/BattleField/BattleField.cs
@@ -151,7 +151,8 @@
{
return;
}
-
+ if (recordPlayer == null || battleObjMgr == null)
+ return;
recordPlayer.Run();
battleObjMgr.Run();
diff --git a/Main/System/Battle/BattleObject/BattleObjMgr.cs b/Main/System/Battle/BattleObject/BattleObjMgr.cs
index 2999e0b..f09454d 100644
--- a/Main/System/Battle/BattleObject/BattleObjMgr.cs
+++ b/Main/System/Battle/BattleObject/BattleObjMgr.cs
@@ -33,15 +33,17 @@
}
for (int i = 0; i < teamBase.serverHeroes.Length; i++)
+ {
+ TeamHero teamHero = teamBase.serverHeroes[i];
+ if (teamHero != null)
{
- TeamHero teamHero = teamBase.serverHeroes[i];
- if (teamHero != null)
- {
- BattleObject battleObj = BattleObjectFactory.CreateBattleObject(battleField, posNodeList, teamHero, _Camp);
- allBattleObjDict.Add(battleObj.ObjID, battleObj);
- campDict.Add(teamHero.positionNum, battleObj);
- }
+ BattleObject battleObj = BattleObjectFactory.CreateBattleObject(battleField, posNodeList, teamHero, _Camp);
+ if (battleObj.ObjID == 0)
+ continue;
+ allBattleObjDict.Add(battleObj.ObjID, battleObj);
+ campDict.Add(teamHero.positionNum, battleObj);
}
+ }
}
public BattleObject GetBattleObject(int objId)
diff --git a/Main/System/Battle/BattleObject/BattleObject.cs b/Main/System/Battle/BattleObject/BattleObject.cs
index 9aa12be..ee58fc9 100644
--- a/Main/System/Battle/BattleObject/BattleObject.cs
+++ b/Main/System/Battle/BattleObject/BattleObject.cs
@@ -67,7 +67,7 @@
motionBase = new MotionBase();
motionBase.Init(heroGo.GetComponentInChildren<SkeletonGraphic>(true));
motionBase.onAnimationComplete += OnAnimationComplete;
-
+ buffMgr = new BattleObjectBuffMgr();
buffMgr.Init(this);
renderers = heroGo.GetComponentsInChildren<Renderer>(true);
diff --git a/Main/System/Battle/BattleObject/BattleObjectFactory.cs b/Main/System/Battle/BattleObject/BattleObjectFactory.cs
index 000fba5..65a1275 100644
--- a/Main/System/Battle/BattleObject/BattleObjectFactory.cs
+++ b/Main/System/Battle/BattleObject/BattleObjectFactory.cs
@@ -13,7 +13,7 @@
{
HeroSkinConfig skinCfg = teamHero.skinConfig;
GameObject battleGO = ResManager.Instance.LoadAsset<GameObject>("Hero/SpineRes", "Hero_001"/*skinCfg.SpineRes*/);
- SkeletonGraphic skeletonGraphic = battleGO.GetComponent<SkeletonGraphic>();
+ SkeletonGraphic skeletonGraphic = battleGO.GetComponentInChildren<SkeletonGraphic>();
skeletonGraphic.skeletonDataAsset = ResManager.Instance.LoadAsset<SkeletonDataAsset>("Hero/SpineRes/", skinCfg.SpineRes);
skeletonGraphic.Initialize(true);
GameObject goParent = posNodeList[teamHero.positionNum];
diff --git a/Main/System/HeroUI/HeroListWin.cs b/Main/System/HeroUI/HeroListWin.cs
index bdb9c5a..db06fc2 100644
--- a/Main/System/HeroUI/HeroListWin.cs
+++ b/Main/System/HeroUI/HeroListWin.cs
@@ -84,6 +84,8 @@
{
for (int i = 0; i < team.serverHeroes.Length; i++)
{
+ if (team.serverHeroes[i] == null)
+ continue;
var hero = HeroManager.Instance.GetHero(team.serverHeroes[i].guid);
if (hero != null)
{
diff --git a/Main/System/HeroUI/HeroUIManager.cs b/Main/System/HeroUI/HeroUIManager.cs
index f7db73b..f36047c 100644
--- a/Main/System/HeroUI/HeroUIManager.cs
+++ b/Main/System/HeroUI/HeroUIManager.cs
@@ -189,31 +189,14 @@
return new Int2((int)country, maxValue);
}
- //AttackType 0 鏀诲嚮闃靛 1 闃插畧闃靛
- int GetSelectTeamTypeByAttackType(int AttackType)
+ //鍦ㄤ笉鍚岄〉绛句笅閫堿ttackType 0 鏀诲嚮闃靛 1 闃插畧闃靛
+ public int GetSelectTeamTypeByAttackType(int AttackType)
{
- if (selectTeamType == TeamType.Arena)
+ if (selectTeamType == TeamType.Arena || selectTeamType == TeamType.ArenaDefense)
{
- if (AttackType == 0)
- {
- return (int)TeamType.Arena;
- }
- else if (AttackType == 1)
- {
- return (int)TeamType.ArenaDefense;
- }
+ return AttackType == 0 ? (int)TeamType.Arena : (int)TeamType.ArenaDefense;
}
- else if (selectTeamType == TeamType.ArenaDefense)
- {
- if (AttackType == 0)
- {
- return (int)TeamType.ArenaDefense;
- }
- else if (AttackType == 1)
- {
- return (int)TeamType.Arena;
- }
- }
+
return (int)TeamType.Story;
}
diff --git a/Main/System/Team/TeamManager.cs b/Main/System/Team/TeamManager.cs
index 6557b47..38c6ec8 100644
--- a/Main/System/Team/TeamManager.cs
+++ b/Main/System/Team/TeamManager.cs
@@ -151,8 +151,8 @@
if (!teamDict.TryGetValue(teamType, out team))
{
team = new TeamBase(teamType);
- team.CreateDefault(HeroManager.Instance.GetPowerfulHeroList());
- teamDict.Add(teamType, team);
+ // team.CreateDefault(HeroManager.Instance.GetPowerfulHeroList());
+ // teamDict.Add(teamType, team);
}
return team;
--
Gitblit v1.8.0