821 lines
22 KiB
C#
821 lines
22 KiB
C#
using System;
|
||
using System.Collections.Generic;
|
||
using cfg.VehicleCfg;
|
||
using Cysharp.Threading.Tasks;
|
||
using UnityEngine;
|
||
using Framework;
|
||
using Gameplay;
|
||
using Gameplay.Common;
|
||
using Gameplay.Level;
|
||
using Gameplay.Vehicle;
|
||
using Gameplay.Vehicle.Impl;
|
||
using PhxhSDK;
|
||
using Constants = Framework.Constants;
|
||
using EventManager = Framework.EventManager;
|
||
|
||
//队伍管理器
|
||
public class TeamManager
|
||
{
|
||
private static TeamManager m_instance;
|
||
private TeamManager()
|
||
{
|
||
//测试数据
|
||
//AllCharacterInfo allChaInfo = AllCharacterInfo.Instance;
|
||
|
||
var useFullCharacters = SROptions.Current.UseFullCharacters;
|
||
|
||
if (useFullCharacters)
|
||
{
|
||
CharacterDataInfoManager.Instance.AddAllCfgCharacter();
|
||
}
|
||
//var cInfos = CharacterDataInfoManager.Instance.DataList;
|
||
TeamEditManager.Instance.RefreshTeams();
|
||
var defaultTeam = TeamEditManager.Instance.GetSelectTeam();
|
||
var cIDs = defaultTeam.GetCharacterIDs();
|
||
if (useFullCharacters)
|
||
{
|
||
cIDs = CharacterDataInfoManager.Instance.DataList.ConvertAll((info) => info.ID).ToArray();
|
||
}
|
||
var vInfos = VehicleCultivateDataManager.Instance.DataList;
|
||
|
||
List<SingleTeamCharacterInfo> selectList = new List<SingleTeamCharacterInfo>();
|
||
int allCount = cIDs.Length + vInfos.Count;
|
||
var count = allCount > WAIT_LIMIT ? WAIT_LIMIT : allCount;
|
||
|
||
//Test
|
||
for (int i = 0; i < cIDs.Length; i++)
|
||
{
|
||
if (i < cIDs.Length)
|
||
{
|
||
var id = cIDs[i];
|
||
if (id > 0)
|
||
{
|
||
SingleTeamCharacterInfo singleInfo;
|
||
singleInfo = new SingleTeamCharacterInfo(CharacterDataInfoManager.Instance.DataDic[id]);
|
||
selectList.Add(singleInfo);
|
||
}
|
||
}
|
||
}
|
||
|
||
for (int i = 0; i < 1; i++)
|
||
{
|
||
if (i < vInfos.Count)
|
||
{
|
||
SingleTeamCharacterInfo singleInfo;
|
||
VehicleInfo v = new VehicleInfo(vInfos[i].nID,
|
||
TableManager.Instance.Tables.VehicleConfig.Get((int)vInfos[i].nID), vInfos[i]);
|
||
singleInfo = new SingleTeamCharacterInfo(vInfos[i].nID, v);
|
||
|
||
selectList.Add(singleInfo);
|
||
}
|
||
}
|
||
|
||
m_allIDList = new List<uint>();
|
||
m_waitFightIDList = new List<uint>();
|
||
m_allCharactersMap = new Dictionary<uint, SingleTeamCharacterInfo>();
|
||
m_onFightIDList = new List<uint>();
|
||
m_deadIDList = new List<uint>();
|
||
m_enemyIDList = new List<uint>();
|
||
_inVehicleIDList = new List<uint>();
|
||
for (int i = 0; i < selectList.Count; i++)
|
||
{
|
||
uint uid = selectList[i].Uid;
|
||
m_allIDList.Add(uid);
|
||
m_allCharactersMap.Add(uid, selectList[i]);
|
||
if (selectList[i].IsVehicle())
|
||
{
|
||
m_waitFightIDList.Insert(0, uid);
|
||
}
|
||
else
|
||
{
|
||
m_waitFightIDList.Add(uid);
|
||
}
|
||
}
|
||
|
||
}
|
||
|
||
private const int FIGHT_LIMIT = 5;
|
||
private const int VEHICLE_FIGHT_LIMIT = 1;
|
||
private const int WAIT_LIMIT = 7;
|
||
|
||
//进入时初始队列,队伍信息池
|
||
private Dictionary<uint, SingleTeamCharacterInfo> m_allCharactersMap;
|
||
private List<uint> m_allIDList;
|
||
//上阵角色ID队列
|
||
private List<uint> m_onFightIDList;
|
||
//下阵角色ID队列
|
||
private List<uint> m_waitFightIDList;
|
||
//死亡角色ID队列
|
||
private List<uint> m_deadIDList;
|
||
//敌方NPCID列表
|
||
private List<uint> m_enemyIDList;
|
||
//载具上的成员
|
||
private List<uint> _inVehicleIDList;
|
||
|
||
//当前选择ID
|
||
private uint m_selectID= Constants.INVALID_UINT_ID;
|
||
//战斗进行时间,战斗开始时开始计时
|
||
private float m_fightPastTimeCount = 0;
|
||
|
||
private bool _isChanging = false;
|
||
|
||
public uint SelectID
|
||
{
|
||
get { return m_selectID; }
|
||
}
|
||
|
||
public static TeamManager Instance
|
||
{
|
||
get {
|
||
if (m_instance == null)
|
||
{
|
||
m_instance = new TeamManager();
|
||
}
|
||
return m_instance;
|
||
}
|
||
}
|
||
|
||
private void InitData()
|
||
{
|
||
Release();
|
||
}
|
||
|
||
bool IsDead(uint uid)
|
||
{
|
||
if (!m_allCharactersMap.ContainsKey(uid))
|
||
{
|
||
DebugUtil.LogError("传入ID有误!!!");
|
||
return false;
|
||
}
|
||
return m_allCharactersMap[uid].GetIsDead();
|
||
}
|
||
|
||
//战前上阵队列变化
|
||
void SendWaitToFightBefore(uint toFightUId)
|
||
{
|
||
foreach (var uid in m_waitFightIDList)
|
||
{
|
||
if (toFightUId == uid)
|
||
{
|
||
if (GetCharacterDataInfo(uid).IsVehicle())
|
||
{
|
||
m_onFightIDList.Insert(0, uid);
|
||
}
|
||
else
|
||
{
|
||
m_onFightIDList.Add(toFightUId);
|
||
}
|
||
m_waitFightIDList.Remove(toFightUId);
|
||
EventManager.Instance.Send(EventManager.EventName.LevelFightStartChange);
|
||
return;
|
||
}
|
||
}
|
||
}
|
||
|
||
//战斗中上阵
|
||
void SendWaitToFightFighting(uint toFightUId)
|
||
{
|
||
if (IsDead(toFightUId))
|
||
{
|
||
return;
|
||
}
|
||
|
||
foreach (var uid in m_waitFightIDList)
|
||
{
|
||
if (toFightUId == uid)
|
||
{
|
||
if (GetCharacterDataInfo(uid).IsVehicle())
|
||
{
|
||
m_onFightIDList.Insert(0, uid);
|
||
}
|
||
else
|
||
{
|
||
m_onFightIDList.Add(toFightUId);
|
||
}
|
||
m_waitFightIDList.Remove(toFightUId);
|
||
//EventSystem.Instance.Send(EventSystem.EventName.LevelFightStartChange);
|
||
return;
|
||
}
|
||
}
|
||
}
|
||
|
||
//战前下阵队列变化
|
||
void SendFightToWaitBefore(uint toWaitUid)
|
||
{
|
||
foreach (var uid in m_onFightIDList)
|
||
{
|
||
if (toWaitUid == uid)
|
||
{
|
||
if (GetCharacterDataInfo(uid).IsVehicle())
|
||
{
|
||
m_waitFightIDList.Insert(0, uid);
|
||
}
|
||
else
|
||
{
|
||
m_waitFightIDList.Add(toWaitUid);
|
||
}
|
||
m_onFightIDList.Remove(toWaitUid);
|
||
EventManager.Instance.Send(EventManager.EventName.LevelFightStartChange);
|
||
|
||
if (GetUnitType(toWaitUid) == SingleTeamCharacterInfo.CharacType.Vehicle)
|
||
{
|
||
var vehicle = GameUnitMapper.Inst.GetUnitById(toWaitUid);
|
||
if (vehicle != null)
|
||
{
|
||
VehicleManager.Inst.RemoveVehicleForPreview((PreviewVehicle)vehicle);
|
||
}
|
||
}
|
||
else
|
||
{
|
||
LevelManager.Instance.CurrentLevel.CharacterManager.Remove(toWaitUid);
|
||
}
|
||
|
||
return;
|
||
}
|
||
}
|
||
}
|
||
|
||
//战斗中下阵
|
||
void SendFightToWaitFighting(uint toWaitUid)
|
||
{
|
||
//LevelManager.Instance.CurrentLevel.CharacterManager.Remove(toWaitUid);
|
||
|
||
bool isDead = false;
|
||
if (IsDead(toWaitUid) && !m_deadIDList.Contains(toWaitUid))
|
||
{
|
||
if (GetCharacterDataInfo(toWaitUid).IsVehicle())
|
||
{
|
||
m_deadIDList.Insert(0, toWaitUid);
|
||
}
|
||
else
|
||
{
|
||
m_deadIDList.Add(toWaitUid);
|
||
}
|
||
|
||
isDead = true;
|
||
}
|
||
|
||
List<uint> tempList = new List<uint>();
|
||
foreach (var id in m_onFightIDList)
|
||
{
|
||
if (!m_deadIDList.Contains(id))
|
||
{
|
||
tempList.Add(id);
|
||
}
|
||
}
|
||
|
||
int idx = m_onFightIDList.FindIndex((id) =>
|
||
{
|
||
if (m_deadIDList.Count > 0)
|
||
{
|
||
return m_deadIDList[0] == id;
|
||
}
|
||
return false;
|
||
});
|
||
idx = idx < 0 ? m_waitFightIDList.Count - m_deadIDList.Count : idx;
|
||
|
||
if (isDead)
|
||
{
|
||
if (m_deadIDList.Count > 0)
|
||
{
|
||
if (m_allCharactersMap[toWaitUid].IsVehicle())
|
||
{
|
||
m_waitFightIDList.Insert(idx, toWaitUid);
|
||
m_onFightIDList.Remove(toWaitUid);
|
||
return;
|
||
}
|
||
}
|
||
m_waitFightIDList.Add(toWaitUid);
|
||
}
|
||
else
|
||
{
|
||
m_waitFightIDList.Insert(idx, toWaitUid);
|
||
}
|
||
|
||
m_onFightIDList.Remove(toWaitUid);
|
||
}
|
||
|
||
public void Release()
|
||
{
|
||
m_allIDList.Clear();
|
||
m_onFightIDList.Clear();
|
||
m_waitFightIDList.Clear();
|
||
m_allCharactersMap.Clear();
|
||
_inVehicleIDList.Clear();
|
||
if (m_deadIDList != null)
|
||
{
|
||
m_deadIDList.Clear();
|
||
}
|
||
m_instance = null;
|
||
}
|
||
|
||
public async UniTask TeamUIInit()
|
||
{
|
||
if(LevelManager.Instance.CurrentLevel.IsPreparing())
|
||
{
|
||
await UIManager.Instance.LoadWindow(UINameConst.UIFightScene);
|
||
await UIManager.Instance.LoadWindow(UINameConst.UI_StartBtn_CMSBtn);
|
||
await UIManager.Instance.LoadWindow(UINameConst.UITeamFight);
|
||
await UIManager.Instance.LoadWindow(UINameConst.UIFightClock);
|
||
|
||
AssetManager.Instance.PostPreload(string.Format(UIManager.UI_PREFAB_PATH, UINameConst.UICharacterStateBar));
|
||
AssetManager.Instance.PostPreload(string.Format(UIManager.UI_PREFAB_PATH, UINameConst.UIVehicleStateBar));
|
||
AssetManager.Instance.PostPreload(string.Format(UIManager.UI_PREFAB_PATH, UINameConst.UIEnemyStateBar));
|
||
AssetManager.Instance.PostPreload(string.Format(UIManager.UI_PREFAB_PATH, UINameConst.UICharacterDamage));
|
||
|
||
//预加载士气值图片
|
||
AssetManager.Instance.PostPreload<Sprite>(LevelUIManager.GetMoralePic(true));
|
||
AssetManager.Instance.PostPreload<Sprite>(LevelUIManager.GetMoralePic(false));
|
||
//预加载数字图片
|
||
for (int i = 0; i < 10; i++)
|
||
{
|
||
AssetManager.Instance.PostPreload<Sprite>(LevelUIManager.GetNumberImage(i));
|
||
}
|
||
|
||
var posterL = LevelUIManager.PaintingList;
|
||
for (int i = 0; i < posterL.Length; i++)
|
||
{
|
||
AssetManager.Instance.PostPreload<Sprite>(posterL[i]);
|
||
}
|
||
//预加载状态图片
|
||
AssetManager.Instance.PostPreload<Sprite>(Constants.UI_RETREATE_STATE);
|
||
AssetManager.Instance.PostPreload<Sprite>(Constants.UI_SUPPRESS_STATE);
|
||
AssetManager.Instance.PostPreload<Sprite>(Constants.UI_RETREATE_STATE_MAP);
|
||
AssetManager.Instance.PostPreload<Sprite>(Constants.UI_SUPPRESS_STATE_MAP);
|
||
AssetManager.Instance.PostPreload<Sprite>(Constants.UI_INVEHICLE_STATE);
|
||
|
||
await AssetManager.Instance.WaitAllPreloads();
|
||
}
|
||
}
|
||
|
||
public void TeamUIOpen()
|
||
{
|
||
UIManager.Instance.OpenLoadedNormalUI(UINameConst.UI_StartBtn_CMSBtn);
|
||
UIManager.Instance.OpenLoadedNormalUI(UINameConst.UITeamFight);
|
||
UIManager.Instance.OpenLoadedNormalUI(UINameConst.UIFightClock);
|
||
UIManager.Instance.OpenLoadedNormalUI(UINameConst.UIFightScene);
|
||
}
|
||
|
||
public void SetSelectID(uint uid = Constants.INVALID_UINT_ID )
|
||
{
|
||
m_selectID = uid;
|
||
|
||
bool isNeedShow = ValueValidator.IsIdValid(m_selectID);
|
||
if (LevelManager.Instance.CurrentLevel.IsPreparing())
|
||
{
|
||
LevelManager.Instance.CurrentLevel.ShowPreparingRegion(isNeedShow);
|
||
}
|
||
else if(LevelManager.Instance.CurrentLevel.IsInBattle())
|
||
{
|
||
if (m_waitFightIDList.Contains(uid))
|
||
{
|
||
LevelManager.Instance.CurrentLevel.ShowPreparingRegion(isNeedShow);
|
||
}
|
||
}
|
||
LevelManager.Instance.CurrentLevel.Map.ShowInfo(Map.InfoMask.ShowCells, isNeedShow);
|
||
|
||
}
|
||
|
||
//获取某一个角色的信息
|
||
public SingleTeamCharacterInfo GetCharacterDataInfo(uint uid)
|
||
{
|
||
return m_allCharactersMap[uid];
|
||
}
|
||
|
||
//获取各个队列
|
||
public List<uint> GetWaitList()
|
||
{
|
||
return m_waitFightIDList;
|
||
}
|
||
|
||
public List<uint> GetFightList()
|
||
{
|
||
return m_onFightIDList;
|
||
}
|
||
|
||
public List<uint> GetDeadList()
|
||
{
|
||
return m_deadIDList;
|
||
}
|
||
|
||
public List<uint> GetInVehicleList()
|
||
{
|
||
return _inVehicleIDList;
|
||
}
|
||
|
||
public List<uint> GetEnemyList()
|
||
{
|
||
return m_enemyIDList;
|
||
}
|
||
|
||
public void AddEnemyID(uint uid)
|
||
{
|
||
m_enemyIDList.Add(uid);
|
||
}
|
||
|
||
public void ClearEnemyID(uint uid)
|
||
{
|
||
m_enemyIDList.Remove(uid);
|
||
}
|
||
|
||
public SingleTeamCharacterInfo GetSingleCharacByUid(uint uid)
|
||
{
|
||
return m_allCharactersMap[uid];
|
||
}
|
||
|
||
//上下载具
|
||
public void InVehicleAdd(uint id)
|
||
{
|
||
_inVehicleIDList.Add(id);
|
||
}
|
||
|
||
public void InVehicleRemove(uint id)
|
||
{
|
||
_inVehicleIDList.Remove(id);
|
||
}
|
||
|
||
//选中一个准备上阵
|
||
public void SelectToFight(uint selectUid = Constants.INVALID_UINT_ID)
|
||
{
|
||
SetSelectID(selectUid);
|
||
}
|
||
|
||
//从Level中选择的传入到UI层
|
||
public void SelectToWait(uint selectUid = Constants.INVALID_UINT_ID)
|
||
{
|
||
SetSelectID(selectUid);
|
||
}
|
||
|
||
//上阵成功
|
||
public void SendToFight(uint toFightUId)
|
||
{
|
||
if (LevelManager.Instance.CurrentLevel.IsPreparing())
|
||
{
|
||
SendWaitToFightBefore(toFightUId);
|
||
return;
|
||
}
|
||
|
||
SendWaitToFightFighting(toFightUId);
|
||
}
|
||
|
||
//下阵成功
|
||
public void SendToWait(uint toWaitUid)
|
||
{
|
||
if (LevelManager.Instance.CurrentLevel.IsPreparing())
|
||
{
|
||
SendFightToWaitBefore(toWaitUid);
|
||
return;
|
||
}
|
||
|
||
// if (LevelManager.Instance.CurrentLevel.IsInBattle())
|
||
// {
|
||
SendFightToWaitFighting(toWaitUid);
|
||
// }
|
||
}
|
||
|
||
//战斗时选中已上阵
|
||
public void SelectCharacterFighting(int uid)
|
||
{
|
||
|
||
}
|
||
|
||
//记录战斗开始时间
|
||
public void StartFightTime()
|
||
{
|
||
//InitFightTime();
|
||
//MonoHelper.instance.AddAction(EActionType.UPDATE, FightPassAddDeltaTime);
|
||
}
|
||
|
||
void FightPassAddDeltaTime()
|
||
{
|
||
bool isPause = LevelManager.Instance.CurrentLevel.IsPause();
|
||
if (!isPause)
|
||
{
|
||
FightPastTimeAddSecond(Time.deltaTime);
|
||
}
|
||
}
|
||
|
||
public void InitFightTime()
|
||
{
|
||
m_fightPastTimeCount = 0;
|
||
}
|
||
|
||
public void SetFightPastTime(float time)
|
||
{
|
||
m_fightPastTimeCount = time;
|
||
}
|
||
|
||
void FightPastTimeAddMs(float ms)
|
||
{
|
||
m_fightPastTimeCount += ms / 1000f;
|
||
}
|
||
|
||
void FightPastTimeAddSecond(float second)
|
||
{
|
||
m_fightPastTimeCount += second;
|
||
}
|
||
|
||
public float GetFightPastTime()
|
||
{
|
||
return m_fightPastTimeCount;
|
||
}
|
||
|
||
public int GetFightPastHour()
|
||
{
|
||
var time = LevelManager.Instance.CurrentLevel.LevelTime;
|
||
int curTimeSecond = Convert.ToInt32(Math.Floor(time));
|
||
int hour = Convert.ToInt32(Math.Floor(curTimeSecond / 3600f));
|
||
|
||
return hour;
|
||
}
|
||
|
||
public int GetFightPastMinute()
|
||
{
|
||
var time = LevelManager.Instance.CurrentLevel.LevelTime;
|
||
int curTimeSecond = Convert.ToInt32(Math.Floor(time));
|
||
int hour = GetFightPastHour();
|
||
int min = Convert.ToInt32(Math.Floor(curTimeSecond / 60f - hour * 60f));
|
||
|
||
return min;
|
||
}
|
||
|
||
public int GetFightPastSecond()
|
||
{
|
||
var time = LevelManager.Instance.CurrentLevel.LevelTime;
|
||
int curTimeSecond = Convert.ToInt32(Math.Floor(time));
|
||
int hour = GetFightPastHour();
|
||
int min = GetFightPastMinute();
|
||
int sec = (curTimeSecond - min * 60 - hour * 3600);
|
||
|
||
return sec;
|
||
}
|
||
|
||
public SingleTeamCharacterInfo.CharacType GetUnitType(uint uid)
|
||
{
|
||
if (m_allCharactersMap.ContainsKey(uid))
|
||
{
|
||
return m_allCharactersMap[uid].Type;
|
||
}
|
||
|
||
DebugUtil.LogError("请检查传入对象的类型(载具/角色)!!!uid = {0}", uid);
|
||
return SingleTeamCharacterInfo.CharacType.Hero;
|
||
}
|
||
|
||
public bool IsCharacter(uint uid)
|
||
{
|
||
if (LevelManager.Instance.CurrentLevel.IsInBattle())
|
||
{
|
||
if (IsInLevel(uid) || !m_allCharactersMap.ContainsKey(uid))
|
||
{
|
||
return GameUnitMapper.Inst.GetUnitById(uid).gameunitType == EGameUnitType.Character;
|
||
}
|
||
}
|
||
return GetUnitType(uid) == SingleTeamCharacterInfo.CharacType.Hero;
|
||
}
|
||
|
||
public bool IsVehicle(uint uid)
|
||
{
|
||
if (LevelManager.Instance.CurrentLevel.IsInBattle())
|
||
{
|
||
return GameUnitMapper.Inst.GetUnitById(uid).gameunitType == EGameUnitType.Vehicle;
|
||
}
|
||
return GetUnitType(uid) == SingleTeamCharacterInfo.CharacType.Vehicle;
|
||
}
|
||
|
||
public bool GetIsChanging()
|
||
{
|
||
return _isChanging;
|
||
}
|
||
|
||
public void SetIsChanging(bool state)
|
||
{
|
||
_isChanging = state;
|
||
}
|
||
|
||
public void BornInLevel(uint uid)
|
||
{
|
||
if (!m_allCharactersMap.ContainsKey(uid))
|
||
{
|
||
return;
|
||
}
|
||
m_allCharactersMap[uid].IsInLevel = true;
|
||
}
|
||
|
||
public void RemoveInLevel(uint uid)
|
||
{
|
||
if (!m_allCharactersMap.ContainsKey(uid))
|
||
{
|
||
return;
|
||
}
|
||
m_allCharactersMap[uid].IsInLevel = false;
|
||
}
|
||
|
||
public bool IsInLevel(uint uid)
|
||
{
|
||
if (!m_allCharactersMap.ContainsKey(uid))
|
||
{
|
||
return false;
|
||
}
|
||
|
||
return m_allCharactersMap[uid].IsInLevel;
|
||
}
|
||
|
||
public List<uint> GetAllIDList()
|
||
{
|
||
return m_allIDList;
|
||
}
|
||
|
||
public bool IsFightListLimit(uint uid)
|
||
{
|
||
int totalNum = 0;
|
||
int vehicleNum = 0;
|
||
if (LevelManager.Instance.CurrentLevel.IsInBattle())
|
||
{
|
||
for (int i = 0; i < m_waitFightIDList.Count; i++)
|
||
{
|
||
if (IsInLevel(m_waitFightIDList[i]))
|
||
{
|
||
var unit = GameUnitMapper.Inst.GetUnitById(m_waitFightIDList[i]);
|
||
if (unit.statusData.isOnVehicle)
|
||
{
|
||
++totalNum;
|
||
}
|
||
else if(unit.statusData.isDead)
|
||
{
|
||
if (unit.gameunitType == EGameUnitType.Vehicle)
|
||
{
|
||
++vehicleNum;
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
for (int i = 0; i < m_onFightIDList.Count; i++)
|
||
{
|
||
var unit = GameUnitMapper.Inst.GetUnitById(m_onFightIDList[i]);
|
||
if (unit.gameunitType == EGameUnitType.Character)
|
||
{
|
||
++totalNum;
|
||
}
|
||
else if(unit.gameunitType == EGameUnitType.Vehicle)
|
||
{
|
||
++vehicleNum;
|
||
}
|
||
}
|
||
//totalNum += m_onFightIDList.Count;
|
||
if (IsCharacter(uid))
|
||
{
|
||
return totalNum >= FIGHT_LIMIT;
|
||
}
|
||
|
||
return vehicleNum >= VEHICLE_FIGHT_LIMIT;
|
||
}
|
||
|
||
totalNum = 0;
|
||
vehicleNum = 0;
|
||
for (int i = 0; i < m_onFightIDList.Count; i++)
|
||
{
|
||
var type = GetUnitType(m_onFightIDList[i]);
|
||
if (type == SingleTeamCharacterInfo.CharacType.Vehicle)
|
||
{
|
||
++vehicleNum;
|
||
}
|
||
else if (type == SingleTeamCharacterInfo.CharacType.Hero)
|
||
{
|
||
++totalNum;
|
||
}
|
||
}
|
||
if (IsCharacter(uid))
|
||
{
|
||
return m_onFightIDList != null && totalNum >= FIGHT_LIMIT;
|
||
}
|
||
|
||
return m_onFightIDList != null && vehicleNum >= VEHICLE_FIGHT_LIMIT;
|
||
}
|
||
}
|
||
|
||
//测试用,暂存一个载具信息类
|
||
public class VehicleInfo
|
||
{
|
||
private VehicleCultivateData _vehicleData;
|
||
private DataVehicle _cfg;
|
||
private uint _uid;
|
||
|
||
public DataVehicle Cfg
|
||
{
|
||
get => _cfg;
|
||
}
|
||
|
||
public uint ID
|
||
{
|
||
get => _uid;
|
||
}
|
||
|
||
public VehicleCultivateData VehicleData => _vehicleData;
|
||
|
||
public VehicleInfo(uint id, DataVehicle cfg, VehicleCultivateData VehicleData)
|
||
{
|
||
_cfg = cfg;
|
||
_uid = id;
|
||
}
|
||
}
|
||
|
||
//单个队列中的角色信息
|
||
public class SingleTeamCharacterInfo
|
||
{
|
||
private CharacterDataInfo _characterData;
|
||
private VehicleInfo _vConfigData;
|
||
|
||
private float m_leftBlood;
|
||
private bool m_isDead;
|
||
private bool _isInLevel = false; //是否被创建到战场中,没有的话不能取到各种值
|
||
|
||
//测试数据
|
||
private uint m_uid;
|
||
private CharacType m_type;
|
||
|
||
public enum CharacType
|
||
{
|
||
Hero,
|
||
Vehicle
|
||
}
|
||
|
||
public bool IsInLevel
|
||
{
|
||
get => _isInLevel;
|
||
set => _isInLevel = value;
|
||
}
|
||
|
||
public SingleTeamCharacterInfo(CharacterDataInfo configData, CharacType type = CharacType.Hero)
|
||
{
|
||
_characterData = configData;
|
||
m_uid = configData.ID;
|
||
m_type = type;
|
||
}
|
||
|
||
public SingleTeamCharacterInfo(uint uid, VehicleInfo configData, CharacType type = CharacType.Vehicle)
|
||
{
|
||
_vConfigData = configData;
|
||
//m_leftBlood = configData.Blood();
|
||
m_uid = uid;
|
||
m_type = type;
|
||
}
|
||
|
||
|
||
public uint Uid
|
||
{
|
||
get { return m_uid; } //return m_configData.mID; }
|
||
}
|
||
|
||
public CharacType Type
|
||
{
|
||
get { return m_type; }
|
||
}
|
||
|
||
public bool IsVehicle()
|
||
{
|
||
return m_type == CharacType.Vehicle;
|
||
}
|
||
|
||
public int GetTid()
|
||
{
|
||
return _characterData.Cfg.RoleID;
|
||
}
|
||
|
||
public CharacterDataInfo GetConfigInfo()
|
||
{
|
||
return _characterData;
|
||
}
|
||
|
||
public VehicleInfo GetVehicleInfo()
|
||
{
|
||
return _vConfigData;
|
||
}
|
||
|
||
public void SetType(CharacType type)
|
||
{
|
||
m_type = type;
|
||
}
|
||
|
||
//获取剩余血量
|
||
public float GetLeftBlood()
|
||
{
|
||
return m_leftBlood;
|
||
}
|
||
|
||
public bool GetIsDead()
|
||
{
|
||
return m_isDead;
|
||
}
|
||
|
||
public void SetIsDead(bool state = false)
|
||
{
|
||
m_isDead = state;
|
||
}
|
||
|
||
//设置剩余血量
|
||
public void SetLeftBlood(float left)
|
||
{
|
||
m_leftBlood = left > 0 ? left : 0;
|
||
}
|
||
} |