| | |
| | | |
| | | public class BattleField |
| | | { |
| | | public Action<int, int> OnRoundChange; |
| | | public Action<bool> OnBattlePause; |
| | | |
| | | public Action<float> OnSpeedRatioChange; // 添加战斗速度变化的回调 |
| | | |
| | | public Action OnBattleRun; // 添加战斗运行时的回调 |
| | | |
| | | public BattleObjMgr battleObjMgr; |
| | | |
| | | public BattleEffectMgr battleEffectMgr; |
| | | |
| | | public BattleTweenMgr battleTweenMgr; |
| | | |
| | | public RecordPlayer recordPlayer; |
| | | |
| | | public IOperationAgent operationAgent; |
| | | |
| | | public byte turnMax; |
| | | public int round = 0; |
| | | |
| | | public string guid = string.Empty;//等于string.Empty的时候代表是StoryBattleField 是主线副本 |
| | | |
| | | public string guid = string.Empty; |
| | | public int MapID = 0; |
| | | |
| | | public int FuncLineID = 0; |
| | | |
| | | public float speedRatio = 1.1f; |
| | | |
| | | public JsonData extendData; |
| | | |
| | | public bool IsBattleFinish |
| | | { |
| | | get; |
| | | protected set; |
| | | } |
| | | public bool IsBattleFinish { get; protected set; } |
| | | public bool rejectNewPackage = false; |
| | | |
| | | private bool m_IsPause = false; |
| | | |
| | | public bool IsPause |
| | | { |
| | | get |
| | | { |
| | | return m_IsPause; |
| | | } |
| | | get { return m_IsPause; } |
| | | set |
| | | { |
| | | m_IsPause = value; |
| | | |
| | | if (m_IsPause) |
| | | if (value) |
| | | { |
| | | m_IsPause = value; |
| | | PauseGame(); |
| | | OnBattlePause?.Invoke(m_IsPause); |
| | | } |
| | | else |
| | | { |
| | | ResumeGame(); |
| | | if (CanResumeGame()) |
| | | { |
| | | m_IsPause = value; |
| | | ResumeGame(); |
| | | OnBattlePause?.Invoke(m_IsPause); |
| | | } |
| | | } |
| | | |
| | | OnBattlePause?.Invoke(m_IsPause); |
| | | } |
| | | } |
| | | |
| | | public BattleRootNode battleRootNode; |
| | | |
| | | private BattleMode battleMode; |
| | | public event Action<BattleMode> ChangeBattleModeEvent; |
| | | |
| | | public Action<bool> OnBattlePause; |
| | | |
| | | protected List<TeamBase> redTeamList = null; |
| | | |
| | | protected List<TeamBase> blueTeamList = null; |
| | | |
| | | protected int redTeamIndex = 0; |
| | | |
| | | protected int blueTeamIndex = 0; |
| | | |
| | | public BattleField(string _guid) |
| | |
| | | } |
| | | |
| | | public virtual void Init(int _MapID, int _FuncLineID, JsonData _extendData, |
| | | List<TeamBase> _redTeamList, List<TeamBase> _blueTeamList) |
| | | List<TeamBase> _redTeamList, List<TeamBase> _blueTeamList, byte turnMax) |
| | | { |
| | | MapID = _MapID; |
| | | redTeamList = _redTeamList; |
| | | blueTeamList = _blueTeamList; |
| | | FuncLineID = _FuncLineID; |
| | | extendData = _extendData; |
| | | IsBattleFinish = false; |
| | | round = 0; |
| | | this.turnMax = turnMax; |
| | | |
| | | redTeamIndex = 0; |
| | | blueTeamIndex = 0; |
| | |
| | | battleObjMgr.Init(this, redTeamList[redTeamIndex], blueTeamList[blueTeamIndex]); |
| | | } |
| | | |
| | | battleRootNode.SetBackground(ResManager.Instance.LoadAsset<Texture>("Texture/FullScreenBg", "mainui_img_277")); |
| | | LoadMap(MapID); |
| | | |
| | | // battleRootNode.SetBackground(ResManager.Instance.LoadAsset<Texture>("Texture/FullScreenBg", "mainui_img_277")); |
| | | |
| | | SetBattleStartState(); |
| | | SetSpeedRatio(BattleManager.Instance.speedGear[BattleManager.Instance.speedIndex]); |
| | | if (MapID == 1) |
| | | { |
| | | SetSpeedRatio(BattleManager.Instance.speedGear[AutoFightModel.Instance.fightSpeed - 1]); |
| | | } |
| | | else |
| | | { |
| | | SetSpeedRatio(BattleManager.Instance.speedGear[BattleManager.Instance.speedIndex]); |
| | | } |
| | | SetRootNodePosition(); |
| | | rejectNewPackage = false; |
| | | OnRoundChange?.Invoke(round, turnMax); |
| | | } |
| | | |
| | | protected virtual void LoadMap(int mapID) |
| | | { |
| | | BattleMapConfig battleMapConfig = BattleMapConfig.Get(mapID); |
| | | if (battleMapConfig != null) |
| | | { |
| | | Texture texture = ResManager.Instance.LoadAsset<Texture>("Texture/FullScreenBg", battleMapConfig.MapBg); |
| | | battleRootNode.SetBackground(texture); |
| | | } |
| | | } |
| | | |
| | | public void SetSpeedRatio(float ratio) |
| | | { |
| | | bool isChange = speedRatio != ratio; |
| | | speedRatio = ratio; |
| | | battleObjMgr.SetSpeedRatio(ratio); |
| | | recordPlayer.SetSpeedRatio(ratio); |
| | | battleEffectMgr.SetSpeedRatio(ratio); |
| | | battleTweenMgr.SetSpeedRatio(ratio); |
| | | |
| | | if (isChange) |
| | | { |
| | | OnSpeedRatioChange?.Invoke(ratio); |
| | | } |
| | | } |
| | | |
| | | protected virtual void SetBattleStartState() |
| | |
| | | } |
| | | if (recordPlayer == null || battleObjMgr == null) |
| | | return; |
| | | |
| | | recordPlayer.Run(); |
| | | battleObjMgr.Run(); |
| | | battleEffectMgr.Run(); |
| | | |
| | | if (operationAgent == null) |
| | | { |
| | |
| | | } |
| | | |
| | | operationAgent.Run(); |
| | | |
| | | // 触发 UI 层的更新回调 |
| | | OnBattleRun?.Invoke(); |
| | | } |
| | | |
| | | |
| | |
| | | uint FuncLineID, JsonData extendData) |
| | | { |
| | | round = TurnNum; |
| | | OnRoundChange?.Invoke(round, turnMax); |
| | | } |
| | | |
| | | public virtual void OnTurnFightObjAction(int turnNum, int ObjID) |
| | | { |
| | | |
| | | round = turnNum; |
| | | OnRoundChange?.Invoke(round, turnMax); |
| | | } |
| | | |
| | | public virtual void OnTurnFightState(int turnNum, int State, int FuncLineID, JsonData turnFightStateData) |
| | |
| | | { |
| | | //已经结束并结算 |
| | | Debug.Log("战斗结束"); |
| | | rejectNewPackage = true; |
| | | OnBattleEnd(turnFightStateData); |
| | | return; |
| | | } |
| | |
| | | { |
| | | obj.layerMgr.UpdateLayer(); |
| | | } |
| | | |
| | | |
| | | battleRootNode.SetSortingOrder(); |
| | | // RendererAdjuster[] adjusters = battleRootNode.GetComponentsInChildren<RendererAdjuster>(true); |
| | | // if (null != adjusters) |
| | | // { |
| | |
| | | |
| | | public void ForceFinish() |
| | | { |
| | | recordPlayer.HaveRest(); |
| | | recordPlayer.ForceFinish(); |
| | | } |
| | | |
| | | |
| | | //暂停的原因有很多,需要检查各种状态 |
| | | protected virtual bool CanResumeGame() |
| | | { |
| | | return true; |
| | | } |
| | | |
| | | public void OnBuffDel(HB429_tagSCBuffDel vNetData) |
| | | { |
| | | BattleObject battleObj = battleObjMgr.GetBattleObject((int)vNetData.ObjID); |
| | | if (null != battleObj) |
| | | { |
| | | battleObj.buffMgr.RemoveBuff(vNetData); |
| | | } |
| | | } |
| | | |
| | | public virtual void ShowWindow(HB424_tagSCTurnFightInit vNetData) |
| | | { |
| | | |
| | | } |
| | | |
| | | public virtual BattleObject FindBoss() |
| | | { |
| | | return null; |
| | | } |
| | | } |