透传cellindex

main
刘涛 2023-12-14 18:25:52 +08:00
parent 712c57669a
commit 8f206fa938
39 changed files with 99 additions and 214 deletions

View File

@ -24,7 +24,7 @@ namespace Framework
public static JSONNode LoadByteBuf(string file)
{
DebugUtil.LogY("TableManager LoadByteBuf {0}", file);
// DebugUtil.LogY("TableManager LoadByteBuf {0}", file);
var filePath = _CombiePath(file);
var loadAsset = AssetManager.Instance.LoadAsset<TextAsset>(filePath);
var jsonText = loadAsset.text;

View File

@ -16,7 +16,7 @@ namespace Code.Scripts.Gameplay.BT.Task
private GameUnit _owner;
public override void OnStart()
{
_owner = GameUnitMapper.Inst.GetUnitById(SharedBattleInfo.Value.ownerId);
_owner = GameUnitManager.instance.infightUnits.Search(SharedBattleInfo.Value.ownerId);
if (SharedBattleInfo.Value.PartolPointIndex == -1)
{

View File

@ -28,7 +28,7 @@ namespace Code.Scripts.Gameplay.BT.Conditional
_isBeingAttacked = false;
}
_owner = GameUnitMapper.Inst.GetUnitById(SharedBattleInfo.Value.ownerId);
_owner = GameUnitManager.instance.infightUnits.Search(SharedBattleInfo.Value.ownerId);
}
private void OnDamaged(EventDataGetDamaged data)

View File

@ -16,7 +16,7 @@ namespace Code.Scripts.Gameplay.BT.Conditional
public override void OnStart()
{
_owner = GameUnitMapper.Inst.GetUnitById(SharedBattleInfo.Value.ownerId);
_owner = GameUnitManager.instance.infightUnits.Search(SharedBattleInfo.Value.ownerId);
}

View File

@ -20,7 +20,7 @@ namespace Code.Scripts.Gameplay.BT.Conditional
public override void OnStart()
{
_owner = GameUnitMapper.Inst.GetUnitById(SharedBattleInfo.Value.ownerId);
_owner = GameUnitManager.instance.infightUnits.Search(SharedBattleInfo.Value.ownerId);
if (!_isRegistered)
{
EventManager.Instance.Register<EventDataSpecialAI>(EventManager.EventName.INFIGHT_CHARACTER_AI_CHAIN, OnSpecialTriggerChanged);

View File

@ -18,7 +18,7 @@ namespace Code.Scripts.Gameplay.BT.Conditional
public override void OnStart()
{
_level = LevelManager.Instance.CurrentLevel;
_owner = GameUnitMapper.Inst.GetUnitById(SharedBattleInfo.Value.ownerId);
_owner = GameUnitManager.instance.infightUnits.Search(SharedBattleInfo.Value.ownerId);
DebugUtil.LogG($"BTWithinSight OnAwake, aiOwner id: {_owner?.GetID()}");
}

View File

@ -14,7 +14,7 @@ namespace Code.Scripts.Gameplay.BT.Task
public override void OnStart()
{
_owner = GameUnitMapper.Inst.GetUnitById(SharedBattleInfo.Value.ownerId);
_owner = GameUnitManager.instance.infightUnits.Search(SharedBattleInfo.Value.ownerId);
if (_owner != null)
{
@ -26,7 +26,7 @@ namespace Code.Scripts.Gameplay.BT.Task
{
if (SharedBattleInfo.Value.theChosenOneId != Constants.INVALID_UINT_ID && !AIUtils.IsNeedStop(_owner))
{
_owner?.MoveAway(GameUnitMapper.Inst.GetUnitById(SharedBattleInfo.Value.theChosenOneId));
_owner?.MoveAway(GameUnitManager.instance.infightUnits.Search(SharedBattleInfo.Value.theChosenOneId));
DebugUtil.LogG($"BT move away update success, owner: {_owner?.GetID()}, target: {SharedBattleInfo.Value.theChosenOneId}");
}

View File

@ -17,7 +17,7 @@ namespace Code.Scripts.Gameplay.BT.Task
public override void OnStart()
{
_owner = GameUnitMapper.Inst.GetUnitById(SharedBattleInfo.Value.ownerId);
_owner = GameUnitManager.instance.infightUnits.Search(SharedBattleInfo.Value.ownerId);
if (_owner != null)
{
@ -32,7 +32,7 @@ namespace Code.Scripts.Gameplay.BT.Task
if(_lastTarget != SharedBattleInfo.Value.theChosenOneId && !AIUtils.IsNeedStop(_owner))
{
_lastTarget = SharedBattleInfo.Value.theChosenOneId;
_owner?.MoveTo(GameUnitMapper.Inst.GetUnitById(SharedBattleInfo.Value.theChosenOneId));
_owner?.MoveTo(GameUnitManager.instance.infightUnits.Search(SharedBattleInfo.Value.theChosenOneId));
DebugUtil.LogG($"BT move to update success, owner: {_owner?.GetID()}, target: {SharedBattleInfo.Value.theChosenOneId}");
}

View File

@ -16,7 +16,7 @@ namespace Code.Scripts.Gameplay.BT.Task
public override void OnStart()
{
_owner = GameUnitMapper.Inst.GetUnitById(SharedBattleInfo.Value.ownerId);
_owner = GameUnitManager.instance.infightUnits.Search(SharedBattleInfo.Value.ownerId);
}
public override TaskStatus OnUpdate()

View File

@ -23,7 +23,7 @@ namespace Code.Scripts.Gameplay.BT.Task
public override void OnStart()
{
// Remember the start time.
_owner = GameUnitMapper.Inst.GetUnitById(SharedBattleInfo.Value.ownerId);
_owner = GameUnitManager.instance.infightUnits.Search(SharedBattleInfo.Value.ownerId);
startTime = Time.time;
waitTime = SharedBattleInfo.Value.PatrolInfos[SharedBattleInfo.Value.PartolPointIndex].waitTime;
waitDuration = waitTime;

View File

@ -25,6 +25,11 @@ namespace Gameplay
var canReach = true;
var mapData = map.GetBlockData(to);
if (mapData == null)
{
canReach = false;
return result;
}
if (!MapUtils.CanPass(moveLevel, mapData.GetTerrainTypeProperty()))
{
// 如果终点不可通行,直接走无法走通的逻辑

View File

@ -103,10 +103,10 @@ namespace Utils.Bounds
}
// 对所有角色进行处理
var units = GameUnitMapper.Inst.unitList;
for (int i = 0; i < units.Count; i++)
var units = GameUnitManager.instance.infightUnits;
for (int i = 0; i < units.count; i++)
{
_OnUnitReady(units[i]);
_OnUnitReady(units.GetByIndex(i));
}
EventManager.Instance.Register<GameUnit>(EventManager.EventName.INFIGHT_UNIT_READY, _OnUnitReady);

View File

@ -87,10 +87,10 @@ namespace Utils.Bounds.Data
private List<GameUnit> _FilterUnits(EBoundsTarget targetType)
{
var result = new List<GameUnit>();
var allUnits = GameUnitMapper.Inst.unitList;
for (int i = 0; i < allUnits.Count; i++)
var allUnits = GameUnitManager.instance.infightUnits;
for (int i = 0; i < allUnits.count; i++)
{
var unit = allUnits[i];
var unit = allUnits.GetByIndex(i);
if (unit == null) continue;
if (unit.statusData.isDead) continue;
var canAdd = _FilterUnit(targetType, unit);

View File

@ -43,10 +43,10 @@ namespace Gameplay.Buff
public void Init()
{
var allUnits = GameUnitMapper.Inst.unitList;
for (int i = 0; i < allUnits.Count; i++)
var allUnits = GameUnitManager.instance.infightUnits;
for (int i = 0; i < allUnits.count; i++)
{
var unit = allUnits[i];
var unit = allUnits.GetByIndex(i);
if (unit.gameunitType != EGameUnitType.Character) continue;
if (unit.statusData.isDead) continue;
if (unit.commonData.troopId != creator.commonData.troopId) continue;
@ -59,7 +59,7 @@ namespace Gameplay.Buff
for (int i = 0; i < _addUnitIds.Count; i++)
{
var unitId = _addUnitIds[i];
var getUnit = GameUnitMapper.Inst.GetUnitById(unitId);
var getUnit = GameUnitManager.instance.infightUnits.Search(unitId);
if (getUnit == null) continue;
if (getUnit.statusData.isDead) continue;
getUnit.buffManager.RemoveBuffById(buffId);

View File

@ -44,11 +44,12 @@ namespace Gameplay.Buff
if (owner.statusData.isChaos && owner.controlData.targetEnemy == null)
{
// 找最近的unit
var allUnits = GameUnitMapper.Inst.unitList;
var allUnits = GameUnitManager.instance.infightUnits;
var minDistance = float.MaxValue;
GameUnit minUnit = null;
foreach (var unit in allUnits)
for (var i = 0; i < allUnits.count; ++i)
{
var unit = allUnits.GetByIndex(i);
if (unit == owner) continue;
if (!unit.statusData.CheckCanBeTarget()) continue;
var distance = Vector3.Distance(unit.transData.pos, owner.transData.pos);

View File

@ -121,10 +121,10 @@ namespace Gameplay.Character
// controlData.targetEnemy = null;
GameUnit target = null;
var allUnits = GameUnitMapper.Inst.unitList;
for (var i = 0; i < allUnits.Count; ++i)
var allUnits = GameUnitManager.instance.infightUnits;
for (var i = 0; i < allUnits.count; ++i)
{
var enemy = allUnits[i];
var enemy = allUnits.GetByIndex(i);
if (enemy == null) continue;
if (!enemy.statusData.CheckCanBeTarget()) continue;
if (enemy == this) continue;

View File

@ -180,11 +180,11 @@ namespace Gameplay.Character
int range)
{
var map = LevelManager.Instance.CurrentLevel.Map;
var allUnits = GameUnitMapper.Inst.unitList;
var allUnits = GameUnitManager.instance.infightUnits;
var result = new List<GameUnit>();
for (var i = 0; i < allUnits.Count; ++i)
for (var i = 0; i < allUnits.count; ++i)
{
var searchUnit = allUnits[i];
var searchUnit = allUnits.GetByIndex(i);
if (searchUnit.commonData.troopId == owner.troopId)
{
// 同一方

View File

@ -61,10 +61,10 @@ public partial class SROptions
[Category("GM"), DisplayName("设置表情")]
public void SetEmoji()
{
var allUnits = GameUnitMapper.Inst.unitList;
for (int i = 0; i < allUnits.Count; i++)
var allUnits = GameUnitManager.instance.infightUnits;
for (int i = 0; i < allUnits.count; i++)
{
var unit = allUnits[i];
var unit = allUnits.GetByIndex(i);
if (unit.gameunitType != EGameUnitType.Character) continue;
if (unit is Character character)

View File

@ -18,7 +18,7 @@ namespace Gameplay.Level
public void SelectUnit(uint id)
{
var newUnit = GameUnitMapper.Inst.GetUnitById(id);
var newUnit = GameUnitManager.instance.infightUnits.Search(id);
if (selectUnit == newUnit) return;
if (newUnit.commonData.canSelect)
{

View File

@ -146,7 +146,6 @@ namespace Gameplay.Level
AIManager.Instance.Init();
GameUnitManager.CreateInstance();
GameUnitMapper.CreateInstance();
SkillManager.CreateInstance();
BuffManager.CreateInstance();
@ -156,7 +155,6 @@ namespace Gameplay.Level
public void Release()
{
EmojiManager.inst.Dispose();
GameUnitMapper.Inst.Dispose();
SkillManager.instance.Dispose();
BuffManager.instance.Dispose();
@ -215,9 +213,6 @@ namespace Gameplay.Level
{
// 加载后处理
await _LoadPostProcess();
// 初始化GameUnitMapper
GameUnitMapper.Inst.Init();
AreaManager.CreateInstance();

View File

@ -123,7 +123,7 @@ namespace Gameplay.Level
{
if (TeamManager.Instance.IsInLevel(teamSelectID))
{
var unit = GameUnitMapper.Inst.GetUnitById(teamSelectID);
var unit = GameUnitManager.instance.infightUnits.Search(teamSelectID);
if (unit.gameunitType == EGameUnitType.Character)
{
if (unit.statusData.isOnVehicle)
@ -277,7 +277,7 @@ namespace Gameplay.Level
{
if (TeamManager.Instance.IsInLevel(teamSelectID))
{
var unit = GameUnitMapper.Inst.GetUnitById(teamSelectID);
var unit = GameUnitManager.instance.infightUnits.Search(teamSelectID);
if (unit.gameunitType == EGameUnitType.Character)
{
if (unit.statusData.isOnVehicle)
@ -331,7 +331,7 @@ namespace Gameplay.Level
}
// 检查通行级别是否可以放置
var blockData = map.GetBlockData(map.TGSCellIndex2BlockPosition(cellIndex));
var blockData = map.GetBlockData(cellIndex);
if (!MapUtils.CanPass(crossLevel, blockData.GetTerrainTypeProperty()))
{
return;
@ -402,7 +402,7 @@ namespace Gameplay.Level
private void _GetOutVehicle(uint uid,
int cellIndex)
{
var gameUnit = GameUnitMapper.Inst.GetUnitById(uid);
var gameUnit = GameUnitManager.instance.infightUnits.Search(uid);
if (gameUnit != null)
{
var character = (Character.Character)gameUnit;

View File

@ -18,10 +18,10 @@ namespace Gameplay.Level
// 设置为手动更新
Physics.simulationMode = SimulationMode.Script;
Physics2D.simulationMode = SimulationMode2D.Script;
// 更新地面
Physics.SyncTransforms();
}
protected override void _OnUpdate(float deltaTime)
@ -99,7 +99,7 @@ namespace Gameplay.Level
}
// 检查通行级别是否可以放置
var blockData = map.GetBlockData(map.TGSCellIndex2BlockPosition(cellIndex));
var blockData = map.GetBlockData(cellIndex);
if (!MapUtils.CanPass(crossLevel, blockData.GetTerrainTypeProperty()))
{
return;
@ -111,7 +111,7 @@ namespace Gameplay.Level
var characterIDHere = Constants.INVALID_UINT_ID;
bool teamSelectCharacterExist = false;
var unitList = GameUnitManager.instance.totalUnits;
var unitList = GameUnitManager.instance.infightUnits;
for (int i = 0; i < unitList.count; i++)
{
var unit = unitList.GetByIndex(i);
@ -163,9 +163,9 @@ namespace Gameplay.Level
var yaw = LevelUtils.SetCharaterToward(_level.GetLevelData().preparingRegionToward);
if (teamSelectCharacterExist)
{
var unit = GameUnitManager.instance.totalUnits.Search(characterIDHere);
if (TeamManager.Instance.SelectID == characterIDHere)
{
var unit = GameUnitManager.instance.totalUnits.Search(characterIDHere);
// 下阵
switch (unit.gameunitType)
{
@ -183,6 +183,7 @@ namespace Gameplay.Level
else
{
// 交换位置
var unit = GameUnitManager.instance.totalUnits.Search(characterIDHere);
var unitHere = unit;
var selectUnit = GameUnitManager.instance.totalUnits.Search(TeamManager.Instance.SelectID);

View File

@ -46,20 +46,9 @@ namespace Gameplay
//Object.DestroyImmediate(GameObject);
}
public MapBlockData GetBlockData(Vector2Int position)
{
return _mapData.GetBlockData(position);
}
public MapBlockData GetBlockData(int cellIndex)
{
var vec2Pos = TGSCellIndex2BlockPosition(cellIndex);
return GetBlockData(vec2Pos);
}
public bool CheckPosition(Vector2Int position)
{
return _mapData.CheckPosition(position);
return _mapData.GetBlockData(cellIndex);
}
public void SetTerrainType(int tgsCellIndex, int terrainTypeIndex)

View File

@ -81,9 +81,14 @@ public class MapData
}
}
public MapBlockData GetBlockData(Vector2Int position)
public MapBlockData GetBlockData(int cellIndex)
{
return CheckPosition(position) ? BlocksData[Position2BlockIndex(position)] : null;
if (cellIndex < 0 || cellIndex >= BlocksData.Count)
{
DebugUtil.LogError("GetBlockData failed, position:{0} is invalid!", cellIndex);
return null;
}
return BlocksData[cellIndex];
}
public bool CheckPosition(Vector2Int position)

View File

@ -80,10 +80,10 @@ namespace Gameplay.Pause
_paticalList = new List<ParticalPauser>();
// 先把场景中的绑定
var allUnits = GameUnitMapper.Inst.unitList;
for (int i = 0; i < allUnits.Count; i++)
var allUnits = GameUnitManager.instance.infightUnits;
for (int i = 0; i < allUnits.count; i++)
{
var unit = allUnits[i];
var unit = allUnits.GetByIndex(i);
_AddUnit(unit);
}

View File

@ -12,11 +12,11 @@ namespace Gameplay.PlayerSkill.Logic
protected override void _SearchUnits()
{
var allUnits = GameUnitMapper.Inst.unitList;
var allUnits = GameUnitManager.instance.infightUnits;
_selectUnits = new List<GameUnit>();
for (var i = 0; i < allUnits.Count; ++i)
for (var i = 0; i < allUnits.count; ++i)
{
var unit = allUnits[i];
var unit = allUnits.GetByIndex(i);
// 只针对己方单位
if (unit.commonData.troopId != owner.playerUnit.commonData.troopId) continue;
// 只针对角色生效

View File

@ -32,10 +32,10 @@ namespace Gameplay.PlayerSkill.Logic
if (selectUnit != null)
{
var allUnits = GameUnitMapper.Inst.unitList;
for (int i = 0; i < allUnits.Count; i++)
var allUnits = GameUnitManager.instance.infightUnits;
for (int i = 0; i < allUnits.count; i++)
{
var unit = allUnits[i];
var unit = allUnits.GetByIndex(i);
if (unit.commonData.troopId != owner.playerUnit.commonData.troopId)
{
// 只筛选友军

View File

@ -61,10 +61,10 @@ namespace Gameplay.Summon
{
var map = LevelManager.Instance.CurrentLevel.Map;
// 由于这里只检测友军,所以直接遍历所有友军即可
var allUnits = GameUnitMapper.Inst.unitList;
for (int i = 0; i < allUnits.Count; i++)
var allUnits = GameUnitManager.instance.infightUnits;
for (int i = 0; i < allUnits.count; i++)
{
var searchUnit = allUnits[i];
var searchUnit = allUnits.GetByIndex(i);
if (searchUnit.gameunitType != EGameUnitType.Character)
{
// 只对角色生效

View File

@ -455,13 +455,13 @@ public class TeamManager
{
if (m_waitFightIDList.Contains(uid))
{
// var unit = GameUnitMapper.Inst.GetUnitById(uid);
// var unit = GameUnitManager.instance.infightUnits.Search(uid);
// if (unit != null)
// {
// if (!unit.statusData.isDead && unit.statusData.isOnVehicle)
// {
// var character = (Character)unit;
// var vehicleUnit = GameUnitMapper.Inst.GetUnitById(character.runtimeData.belongVehicle.GetID());
// var vehicleUnit = GameUnitManager.instance.infightUnits.Search(character.runtimeData.belongVehicle.GetID());
// LevelManager.Instance.CurrentLevel.ShowUnitAroundRegion(vehicleUnit, isNeedShow);
// }
//
@ -664,7 +664,7 @@ public class TeamManager
{
if (IsInLevel(uid) || !m_allCharactersMap.ContainsKey(uid))
{
return GameUnitMapper.Inst.GetUnitById(uid).gameunitType == EGameUnitType.Character;
return GameUnitManager.instance.infightUnits.Search(uid).gameunitType == EGameUnitType.Character;
}
}
return GetUnitType(uid) == SingleTeamCharacterInfo.CharacType.Hero;
@ -674,7 +674,7 @@ public class TeamManager
{
if (LevelManager.Instance.CurrentLevel.IsInBattle())
{
return GameUnitMapper.Inst.GetUnitById(uid).gameunitType == EGameUnitType.Vehicle;
return GameUnitManager.instance.infightUnits.Search(uid).gameunitType == EGameUnitType.Vehicle;
}
return GetUnitType(uid) == SingleTeamCharacterInfo.CharacType.Vehicle;
}
@ -732,7 +732,7 @@ public class TeamManager
{
if (IsInLevel(m_waitFightIDList[i]))
{
var unit = GameUnitMapper.Inst.GetUnitById(m_waitFightIDList[i]);
var unit = GameUnitManager.instance.infightUnits.Search(m_waitFightIDList[i]);
if (unit.statusData.isOnVehicle)
{
++totalNum;
@ -749,7 +749,7 @@ public class TeamManager
for (int i = 0; i < m_onFightIDList.Count; i++)
{
var unit = GameUnitMapper.Inst.GetUnitById(m_onFightIDList[i]);
var unit = GameUnitManager.instance.infightUnits.Search(m_onFightIDList[i]);
if (unit.gameunitType == EGameUnitType.Character)
{
++totalNum;

View File

@ -446,7 +446,7 @@ public class UITeamFightController : UIWindow
{
if (ValueValidator.IsIdValid(_changeId) && TeamManager.Instance.GetIsChanging())
{
ToFightCallBack(GameUnitMapper.Inst.GetUnitById(_changeId));
ToFightCallBack(GameUnitManager.instance.infightUnits.Search(_changeId));
_changeId = 0;
}
}
@ -888,7 +888,7 @@ public class UITeamFightController : UIWindow
}
var singleInfo = TeamManager.Instance.GetSingleCharacByUid(uid);
var gameUnit = GameUnitMapper.Inst.GetUnitById(uid);
var gameUnit = GameUnitManager.instance.totalUnits.Search(uid);
if (singleInfo.Type == SingleTeamCharacterInfo.CharacType.Vehicle)
{
@ -914,7 +914,7 @@ public class UITeamFightController : UIWindow
}
else if (LevelManager.Instance.CurrentLevel.IsInBattle())
{
if (GameUnitMapper.Inst.GetUnitById(uid) != null)
if (GameUnitManager.instance.infightUnits.Search(uid) != null)
{
if (gameUnit.statusData.isDead)
{
@ -1279,7 +1279,7 @@ public class UITeamFightController : UIWindow
}
//Character character = LevelManager.Instance.CurrentLevel.CharacterManager.Get(uid);
GameUnit unit = GameUnitMapper.Inst.GetUnitById(uid);
GameUnit unit = GameUnitManager.instance.infightUnits.Search(uid);
SetSkillPutState(SkillPutState.Dragging);
EventManager.Instance.Send(EventManager.EventName.UI_START_USE_SKILL, unit);
InputManager.Instance.enabled = false;

View File

@ -123,13 +123,13 @@ public class UIVehicleHeadItemNode: UIHeadItemNodeBase
//分根据当前队列状态进行刷新
if (LevelManager.Instance.CurrentLevel.IsPreparing())
{
PreviewVehicle vehicle = GameUnitMapper.Inst.GetUnitById(uid) as PreviewVehicle;
PreviewVehicle vehicle = GameUnitManager.instance.totalUnits.Search(uid) as PreviewVehicle;
_vehicle = vehicle;
RefreshBefore(characterData);
}
else if (LevelManager.Instance.CurrentLevel.IsInBattle())
{
NormalVehicle vehicle = GameUnitMapper.Inst.GetUnitById(uid) as NormalVehicle;
NormalVehicle vehicle = GameUnitManager.instance.totalUnits.Search(uid) as NormalVehicle;
_vehicle = vehicle;
if (isOnFight)
{

View File

@ -30,7 +30,7 @@ public class UICharacterStateBar: UIUnitStateBar
return;
}
GameUnit character = GameUnitMapper.Inst.GetUnitById(uid);
GameUnit character = GameUnitManager.instance.infightUnits.Search(uid);
// if (m_totalHP <= 0)
// {

View File

@ -92,7 +92,7 @@ public class UIFightSceneController : UIWindow{
var go = item.Value;
uint uid = item.Key;
//Character character = LevelManager.Instance.CurrentLevel.CharacterManager.Get(uid);
GameUnit character = GameUnitMapper.Inst.GetUnitById(uid);
GameUnit character = GameUnitManager.instance.infightUnits.Search(uid);
if (character != null)
{
SetBloodPos(go, character);
@ -140,7 +140,7 @@ public class UIFightSceneController : UIWindow{
async void AddBloodGo(uint uid)
{
var unit = GameUnitMapper.Inst.GetUnitById(uid);
var unit = GameUnitManager.instance.infightUnits.Search(uid);
if (unit != null)
{
if (unit.statusData.isOnVehicle)
@ -169,7 +169,7 @@ public class UIFightSceneController : UIWindow{
var go = Instantiate(prefab, GoBloods.transform);
var comp = go.GetComponent<UIUnitStateBar>();
comp.SetUid(uid);
GameUnit character = GameUnitMapper.Inst.GetUnitById(uid);
GameUnit character = GameUnitManager.instance.infightUnits.Search(uid);
if (character != null)
{
SetBloodPos(go, character);
@ -179,7 +179,7 @@ public class UIFightSceneController : UIWindow{
void AddActionStateImg(uint uid)
{
var unit = GameUnitMapper.Inst.GetUnitById(uid);
var unit = GameUnitManager.instance.infightUnits.Search(uid);
if (unit == null)
{
return;
@ -194,7 +194,7 @@ public class UIFightSceneController : UIWindow{
return;
}
if(GameUnitMapper.Inst.GetUnitById(uid).gameunitType == EGameUnitType.Character)
if(GameUnitManager.instance.infightUnits.Search(uid).gameunitType == EGameUnitType.Character)
{
Character character = GameUnitManager.instance.characterManager.Get(uid);
if (character != null)
@ -211,7 +211,7 @@ public class UIFightSceneController : UIWindow{
void AddDamageGo(uint uid)
{
var unit = GameUnitMapper.Inst.GetUnitById(uid);
var unit = GameUnitManager.instance.infightUnits.Search(uid);
if (unit != null)
{
if (unit.statusData.isOnVehicle)
@ -301,7 +301,7 @@ public class UIFightSceneController : UIWindow{
{
uint uid = damageData.owner.GetID();
//Character character = GameUnitManager.instance.characterManager.Get(uid);
GameUnit character = GameUnitMapper.Inst.GetUnitById(uid);
GameUnit character = GameUnitManager.instance.infightUnits.Search(uid);
if (!m_goNumbersMap.ContainsKey(uid))
{

View File

@ -30,7 +30,7 @@ public class UIVehicleStateBar : UIUnitStateBar
return;
}
GameUnit character = GameUnitMapper.Inst.GetUnitById(uid);
GameUnit character = GameUnitManager.instance.infightUnits.Search(uid);
// else
// {
// character = unit as NormalVehicle;
@ -57,7 +57,7 @@ public class UIVehicleStateBar : UIUnitStateBar
public override void SetUid(uint inputUid)
{
uid = inputUid;
NormalVehicle character = (NormalVehicle)GameUnitMapper.Inst.GetUnitById(inputUid);
NormalVehicle character = (NormalVehicle)GameUnitManager.instance.infightUnits.Search(inputUid);
if (character != null)
{
m_totalHP = character.aliveData.maxHp + character.aliveData.maxShield;

View File

@ -217,7 +217,7 @@ namespace Gameplay.Unit
prepareUnits.Remove(unit);
infightUnits.Add(unit);
DebugUtil.LogG($"单位:{unit.GetID()} 已进入战斗");
DebugUtil.LogG($"单位:{unit.GetID()} 已进入战斗序列");
}
public void EnterBattle()

View File

@ -1,108 +0,0 @@
using System;
using System.Collections.Generic;
using Framework;
namespace Gameplay.Unit
{
public class GameUnitMapper
{
private static GameUnitMapper _instance;
public static GameUnitMapper Inst
{
get
{
return _instance;
}
}
public static GameUnitMapper CreateInstance()
{
if (_instance != null)
{
DebugUtil.LogError("请勿重复创建: GameUnitMapper");
return _instance;
}
_instance = new GameUnitMapper();
return _instance;
}
private readonly Dictionary<uint, GameUnit> _gameUnitDict;
private readonly List<GameUnit> _unitList;
public List<GameUnit> unitList
{
get
{
return _unitList;
}
}
private GameUnitMapper()
{
_unitList = new List<GameUnit>();
_gameUnitDict = new Dictionary<uint, GameUnit>();
}
public GameUnit GetUnitById(uint uId)
{
if (_gameUnitDict.TryGetValue(uId, out var unit))
{
return unit;
}
DebugUtil.Log("不存在的UnitId: {0}", uId);
return null;
}
public void RemoveUnitById(uint uId)
{
if (_gameUnitDict.TryGetValue(uId, out var unit))
{
_gameUnitDict.Remove(uId);
_unitList.Remove(unit);
}
else
{
DebugUtil.Log("不存在的UnitId: {0}", uId);
}
}
public void Init()
{
EventManager.Instance.Register(EventManager.EventName.UnitCreate, (Action<GameUnit>)_AddUnit);
EventManager.Instance.Register(EventManager.EventName.UnitDispose, (Action<uint>)_RemoveUnit);
}
public void Dispose()
{
EventManager.Instance.Unregister(EventManager.EventName.UnitCreate, (Action<GameUnit>)_AddUnit);
EventManager.Instance.Unregister(EventManager.EventName.UnitDispose, (Action<uint>)_RemoveUnit);
_gameUnitDict.Clear();
_unitList.Clear();
_instance = null;
}
private void _AddUnit(GameUnit unit)
{
if (_gameUnitDict.ContainsKey(unit.GetID()))
{
DebugUtil.LogError("重复的UnitId: {0}",unit.GetID());
return;
}
_unitList.Add(unit);
_gameUnitDict.Add(unit.GetID(), unit);
}
private void _RemoveUnit(uint id)
{
if (!_gameUnitDict.ContainsKey(id))
{
DebugUtil.LogError("不存在的UnitId: {0}", id);
return;
}
_unitList.Remove(_gameUnitDict[id]);
_gameUnitDict.Remove(id);
}
}
}

View File

@ -1,3 +0,0 @@
fileFormatVersion: 2
guid: 710714b25b53475db5ad7048a3a05a39
timeCreated: 1691740613

View File

@ -128,10 +128,10 @@ namespace Gameplay.Vehicle.Impl
//
// }
var allUnits = GameUnitMapper.Inst.unitList;
for (var i = 0; i < allUnits.Count; ++i)
var allUnits = GameUnitManager.instance.infightUnits;
for (var i = 0; i < allUnits.count; ++i)
{
var enemy = allUnits[i];
var enemy = allUnits.GetByIndex(i);
if (enemy == null) continue;
if (!enemy.statusData.CheckCanBeTarget()) continue;
if (!statusData.isChaos)

View File

@ -33,12 +33,12 @@ namespace FightDebug
return;
}
var units = GameUnitMapper.Inst.unitList;
var units = GameUnitManager.instance.infightUnits;
_dragScrollPos = GUILayout.BeginScrollView(_dragScrollPos);
GUILayout.BeginHorizontal();
for (int i = 0; i < units.Count; i++)
for (int i = 0; i < units.count; i++)
{
var unit = units[i];
var unit = units.GetByIndex(i);
GUILayout.BeginVertical();
_DisplayUnit(unit);
GUILayout.EndVertical();