From ab51e29c1f5cc3838f44e702b01c7a43b641f572 Mon Sep 17 00:00:00 2001
From: hch <305670599@qq.com>
Date: 星期二, 04 十一月 2025 14:25:37 +0800
Subject: [PATCH] 197 子 【内政】淘金系统 / 【内政】淘金系统-客户端 - 功能开启前的限制
---
Main/System/Team/TeamBase.cs | 146 ++++++++++++++++++++++++++++++++++++++++++------
1 files changed, 128 insertions(+), 18 deletions(-)
diff --git a/Main/System/Team/TeamBase.cs b/Main/System/Team/TeamBase.cs
index 14622c7..13f0f91 100644
--- a/Main/System/Team/TeamBase.cs
+++ b/Main/System/Team/TeamBase.cs
@@ -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
{
@@ -187,9 +192,10 @@
}
return null;
}
+
public TeamHero GetHeroByHeroID(int heroId)
- {
+ {
foreach (var hero in tempHeroes)
{
if (hero != null && hero.heroId == heroId)
@@ -226,6 +232,76 @@
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()
{
@@ -237,6 +313,18 @@
}
}
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;
}
// 甯冮樀鎺ュ彛
@@ -252,7 +340,18 @@
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)
{
@@ -260,32 +359,43 @@
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, out int pos)
+ public bool AddHero(HeroInfo heroInfo, out int pos, bool checkLock)
{
pos = -1;
if (heroInfo == null || heroInfo.itemHero == null) return false;
+
+ if (checkLock)
+ {
+ 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;
+ return false;
}
else
{
--
Gitblit v1.8.0