From eb27e5fd31f73b998a4bbd85511a31e40b8c61b7 Mon Sep 17 00:00:00 2001
From: hch <305670599@qq.com>
Date: 星期五, 21 十一月 2025 17:03:47 +0800
Subject: [PATCH] 0312 关闭游戏内日志
---
Main/System/Team/TeamBase.cs | 208 +++++++++++++++++++++++++++++++++++++++++++--------
1 files changed, 175 insertions(+), 33 deletions(-)
diff --git a/Main/System/Team/TeamBase.cs b/Main/System/Team/TeamBase.cs
index e0f4653..13f0f91 100644
--- a/Main/System/Team/TeamBase.cs
+++ b/Main/System/Team/TeamBase.cs
@@ -28,7 +28,7 @@
private int ShapeType;
public int ServerShapeType { get; private set; }
- public TeamHero[] tempHeroes = new TeamHero[TeamConst.MaxTeamHeroCount];
+ public TeamHero[] tempHeroes { get; private set; } = new TeamHero[TeamConst.MaxTeamHeroCount];
public TeamHero[] serverHeroes { get; private set; } = new TeamHero[TeamConst.MaxTeamHeroCount];
@@ -40,8 +40,13 @@
}
// 杩欒竟鏉ョ殑鍙互娌℃湁闃熶紞绫诲瀷
- public TeamBase(HB424_tagSCTurnFightInit.tagSCTurnFightLineup lineUp)
+ public TeamBase(HB424_tagSCTurnFightInit.tagSCTurnFightLineup lineUp, bool isBoss = false)
{
+ if (isBoss)
+ {
+ tempHeroes = new TeamHero[TeamConst.MaxTeamSlotCount];
+ serverHeroes = new TeamHero[TeamConst.MaxTeamSlotCount];
+ }
teamIndex = lineUp.Num;
playerId = lineUp.OwnerID;
ShapeType = lineUp.ShapeType;
@@ -53,8 +58,8 @@
{
var fightObj = lineUp.ObjList[i];
TeamHero hero = new TeamHero(fightObj, this);
- tempHeroes[fightObj.PosNum] = hero;
- serverHeroes[fightObj.PosNum] = hero;
+ tempHeroes[hero.positionNum] = hero;
+ serverHeroes[hero.positionNum] = hero;
}
else
{
@@ -99,7 +104,7 @@
{
if (IsEmpty())
{
- Debug.LogError("Cannot save an empty team. You should at least have one hero in the team.");
+ SysNotifyMgr.Instance.ShowTip("HeroFunc3");
return;
}
@@ -109,6 +114,7 @@
savePack.PosCnt = (byte)GetTeamHeroCount();
savePack.HeroPosList = new CB412_tagCSHeroLineupSave.tagCSHeroLineupPos[savePack.PosCnt];
+ int index = 0;
foreach (var hero in tempHeroes)
{
if (hero != null)
@@ -122,15 +128,17 @@
continue;
}
- savePack.HeroPosList[posNum] = new CB412_tagCSHeroLineupSave.tagCSHeroLineupPos
+ savePack.HeroPosList[index] = new CB412_tagCSHeroLineupSave.tagCSHeroLineupPos
{
ItemIndex = (ushort)heroInfo.itemHero.gridIndex,
- PosNum = (byte)posNum
+ PosNum = (byte)(posNum + 1)
};
+ index++;
}
}
-
GameNetSystem.Instance.SendInfo(savePack);
+ SysNotifyMgr.Instance.ShowTip("HeroFunc4");
+ //闈炰富绾块樀瀹瑰鎴风鑷繁鍋氭垬鍔涘彉鍖栵紝涓荤嚎闃靛鏈嶅姟绔垬鍔涘彉鏇翠細鍚屾鎺ㄩ��
}
public void OnChangeShapeType(int newShapeType)
@@ -144,7 +152,7 @@
ShapeType = newShapeType;
}
- // hero info could be null if the hero is removed from the team
+
public void RefreshServerData(int shapeType, int positionIndex, HeroInfo heroInfo)
{
TeamHero teamHero = heroInfo == null ? null : new TeamHero(heroInfo, positionIndex, this);
@@ -184,6 +192,20 @@
}
return null;
}
+
+
+ public TeamHero GetHeroByHeroID(int heroId)
+ {
+ foreach (var hero in tempHeroes)
+ {
+ if (hero != null && hero.heroId == heroId)
+ {
+ return hero;
+ }
+ }
+ return null;
+ }
+
public TeamHero GetServerHero(string guid)
{
@@ -210,6 +232,77 @@
return false;
}
+ public bool HasHeroInServer(string guid)
+ {
+ foreach (var hero in serverHeroes)
+ {
+ if (hero != null && hero.guid == guid)
+ {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ public TeamHero GetServerHeroByIndex(int index)
+ {
+ if (index < 0 || index >= serverHeroes.Length)
+ {
+ return null;
+ }
+ return serverHeroes[index];
+ }
+
+
+ //鑾峰彇鎵�鏈変笂闃电殑姝﹀皢
+ public List<TeamHero> GetHerosOnTeam()
+ {
+ List<TeamHero> tmpHeros = new List<TeamHero>();
+ foreach (var hero in tempHeroes)
+ {
+ if (hero != null)
+ {
+ tmpHeros.Add(hero);
+ }
+ }
+ return tmpHeros;
+ }
+
+ public TeamHero GetNextServerHero(string guid)
+ {
+ if (string.IsNullOrEmpty(guid))
+ {
+ //鍙栫涓�涓�
+ foreach (var hero in serverHeroes)
+ {
+ if (hero != null)
+ {
+ return hero;
+ }
+ }
+ return null;
+ }
+ else
+ {
+ //鍙栦笅涓�涓�
+ bool findNext = false;
+ foreach (var hero in serverHeroes)
+ {
+ if (hero != null && hero.guid == guid)
+ {
+ findNext = true;
+ }
+ else if (findNext && hero != null)
+ {
+ return hero;
+ }
+ }
+ //娌℃壘鍒� 鍙栫涓�涓�
+ return GetNextServerHero("");
+ }
+ }
+
+ //瀹㈡埛绔粠0寮�濮嬶紝鏈嶅姟绔粠1寮�濮�
public int GetEmptyPosition()
{
for (int i = 0; i < tempHeroes.Length; i++)
@@ -222,20 +315,43 @@
return -1; // No empty position
}
+ public int GetPosition(string guid)
+ {
+ foreach (var hero in serverHeroes)
+ {
+ if (hero != null && hero.guid == guid)
+ {
+ return hero.positionNum;
+ }
+ }
+ return -1;
+ }
+
// 甯冮樀鎺ュ彛
- public void SetTeamHero(int posNum, TeamHero hero)
+ private void SetTeamHero(int posNum, TeamHero hero)
{
tempHeroes[posNum] = hero;
}
// 甯冮樀鎺ュ彛
- public void SetServerTeamHero(int posNum, TeamHero hero)
+ private void SetServerTeamHero(int posNum, TeamHero hero)
{
serverHeroes[posNum] = hero;
tempHeroes[posNum] = hero;
}
- public void AddHero(HeroInfo heroInfo, int targetPosition)
+ // 甯冮樀鎺ュ彛: 鎭㈠闃靛
+ public void RestoreTeam()
+ {
+ for (int i = 0; i < tempHeroes.Length; i++)
+ {
+ tempHeroes[i] = serverHeroes[i];
+ }
+ }
+
+ //checkLock 锛氭槸鍚﹂獙璇佷笂闃典汉鏁伴檺鍒�
+ //targetPosition 浠�0寮�濮�
+ public void AddHero(HeroInfo heroInfo, int targetPosition, bool checkLock)
{
if (targetPosition < 0 || targetPosition >= tempHeroes.Length)
{
@@ -243,57 +359,71 @@
return;
}
- TeamHero targetHero = tempHeroes[targetPosition];
+ if (checkLock)
+ {
+ var lockCnt = HeroUIManager.Instance.lockIndexList.Count;
+ if (lockCnt > 0 && TeamConst.MaxTeamHeroCount - GetHerosOnTeam().Count <= lockCnt)
+ {
+ HeroUIManager.Instance.ShowUnLockTip(HeroUIManager.Instance.lockIndexList[0]);
+ return;
+ }
+ }
- if (null == targetHero)
- {
- TeamHero newHero = new TeamHero(heroInfo, targetPosition, this);
- SetTeamHero(targetPosition, newHero);
- }
- else
- {
- SetTeamHero(targetPosition, new TeamHero(heroInfo, targetPosition, this));
- }
+ SetTeamHero(targetPosition, new TeamHero(heroInfo, targetPosition, this));
}
-
+ //checkLock 锛氭槸鍚﹂獙璇佷笂闃典汉鏁伴檺鍒�
// add鍙彲鑳芥槸鐐逛笅闈㈠崱鐗�
- public bool AddHero(HeroInfo heroInfo)
+ public bool AddHero(HeroInfo heroInfo, out int pos, bool checkLock)
{
+ pos = -1;
if (heroInfo == null || heroInfo.itemHero == null) return false;
-
- // 濡傛灉褰撳墠鑻遍泟宸茬粡鍦ㄩ槦浼嶉噷浜� 灏变笉澶勭悊浜�
- if (GetHero(heroInfo.itemHero.guid) != null)
+ if (checkLock)
{
- return false; // Hero already in team
+ var lockCnt = HeroUIManager.Instance.lockIndexList.Count;
+ if (lockCnt > 0 && TeamConst.MaxTeamHeroCount - GetHerosOnTeam().Count <= lockCnt)
+ {
+ HeroUIManager.Instance.ShowUnLockTip(HeroUIManager.Instance.lockIndexList[0]);
+ return false;
+ }
+ }
+
+
+ // 鍚屼竴鑻遍泟 鍙兘涓婇樀涓�涓�
+ if (GetHeroByHeroID(heroInfo.heroId) != null)
+ {
+ SysNotifyMgr.Instance.ShowTip("HeroFunc2");
+ return false;
}
else
{
- int emptyPosition = GetEmptyPosition();
+ pos = GetEmptyPosition();
- if (emptyPosition < 0)
+ if (pos < 0)
{
- Debug.LogError("No empty position available in the team.");
+ SysNotifyMgr.Instance.ShowTip("HeroFunc1");
return false; // No empty position available
}
- TeamHero teamHero = new TeamHero(heroInfo, GetEmptyPosition(), this);
+ TeamHero teamHero = new TeamHero(heroInfo, pos, this);
SetTeamHero(teamHero.positionNum, teamHero);
return true;
}
}
- public bool RemoveHero(HeroInfo heroInfo)
+ public bool RemoveHero(HeroInfo heroInfo, out int pos)
{
+ pos = -1;
if (heroInfo == null || heroInfo.itemHero == null) return false;
TeamHero teamHero = GetHero(heroInfo.itemHero.guid);
if (teamHero != null)
{
+ pos = teamHero.positionNum;
// 浠庡綋鍓嶉槦浼嶉噷绉婚櫎璇ヨ嫳闆�
SetTeamHero(teamHero.positionNum, null);
return true;
@@ -319,6 +449,18 @@
return false; // Hero not found
}
+ public bool RemoveHero(int pos)
+ {
+ SetTeamHero(pos, null);
+ return true;
+ }
+
+ public void RemoveAllHeroes()
+ {
+ tempHeroes = new TeamHero[TeamConst.MaxTeamHeroCount];
+ }
+
+
public void SwapPosition(int index1, int index2)
{
if (index1 < 0 || index1 >= tempHeroes.Length || index2 < 0 || index2 >= tempHeroes.Length)
--
Gitblit v1.8.0