//结束当前回合 public bool EndTurn(T endUnit = null) { if (IsPause || IsInEndTurn) { return(false); } if (SubBattleMgr.IsInBattle) { CLog.Error("错误!试图在SubBattle阶段结束回合"); return(false); } if (endUnit == null) { endUnit = Player as T; } OnPreEndTurn(endUnit); if (!IsCanEndTurn(endUnit)) { OnCantEndTurn(endUnit); return(false); } _isInEndTurnFlag = true; BattleCoroutine.Kill(OnInEndTurnCoroutine); OnInEndTurnCoroutine = BattleCoroutine.Run(OnInEndTurn(endUnit)); return(true); }
//开始 void StartTurn(bool isForce = false) { if (IsPause && !isForce) { return; } _isInEndTurnFlag = false; BattleCoroutine.Kill(OnInEndTurnCoroutine); BattleCoroutine.Kill(OnInPostEndTurnCoroutine); //新的一回合开始 if (CurTurnIndex == 0) { AllUnits = CalcAllUnits().OrderByDescending(x => x.IsPlayerCtrl()).ToList(); OnTurnAllStart(); } if (AllUnits.Count <= 0) { CLog.Error("AllUnits人数太少"); return; } var unit = AllUnits[CurTurnIndex]; CurOperatingUnit = unit; OnSetMustProcess(unit); Callback_OnStartTurn?.Invoke(unit, isForce); OnTurnStart(unit, isForce); if (unit.IsPlayer()) { OnTurnPlayerStart(); Callback_OnStartPlayerTurn?.Invoke(); } }
void ReCreateAlerts() { foreach (var alert in ActiveItems) { GOPool.Despawn(alert.gameObject); } ActiveItems.Clear(); if (delayCallTask != null) { BattleCoroutine.Kill(delayCallTask); } delayCallTask = BattleCoroutine.Run(AddInitAlerts()); IEnumerator <float> AddInitAlerts() { if (AlertMgr != null) { for (int i = 0; i < AlertMgr.Data.Count; ++i) { if (i >= AlertMgr.Data.Count) { yield break; } yield return(Timing.WaitForSeconds(0.1f)); AddAlert(AlertMgr.Data[i]); } } yield break; } }
protected override void OnBattleUnLoad() { base.OnBattleUnLoad(); _flagPause.Reset(); CurOperatingUnit = null; BattleCoroutine.Kill(OnInEndTurnCoroutine); BattleCoroutine.Kill(OnInPostEndTurnCoroutine); }
//停止所有的临时剧情 void StopAllTempPlot() { TempPlotFlag.Clear(); foreach (var item in TempPlotCoroutines) { BattleCoroutine.Kill(item); } TempPlotCoroutines.Clear(); }
// 停止一段剧情 public virtual void Stop() { StopAllTempPlot(); BattleCoroutine.Kill(StartPlotCoroutine); BattleCoroutine.Kill(MainPlotCoroutine); if (CurData == null) { return; } CurData.OnBeRemoved(); CurData = null; }
void RecreateAlerts() { foreach (var alert in ActiveItems) { GOPool.Despawn(alert.gameObject); } ActiveItems.Clear(); if (delayCallTask != null) { BattleCoroutine.Kill(delayCallTask); } delayCallTask = BattleCoroutine.Run(AddInitAlerts()); }
//操作回合:回调函数 #endregion #region IEnumerator IEnumerator <float> OnInEndTurn(T endUnit) { //触发本地玩家事件 if (endUnit.IsPlayer()) { OnTurnPlayerEnd(); Callback_OnEndPlayerTurn?.Invoke(); } //回合后期处理 BattleCoroutine.Kill(OnInPostEndTurnCoroutine); OnInPostEndTurnCoroutine = BattleCoroutine.Run(OnInPostEndTurn(endUnit)); yield return(Timing.WaitUntilDone(OnInPostEndTurnCoroutine)); while (IsPause) { yield return(Timing.WaitForOneFrame); } //触发本地玩家事件 if (endUnit.IsPlayer()) { OnTurnPlayerPostEnd(); Callback_OnEndPlayerPostTurn?.Invoke(); } if (AllUnits.Count <= 0) { CLog.Error("AllUnits人数太少"); } if (CurOperatingUnit != endUnit) { CLog.Error("错误:当前回合单位不一致"); } OperatedUnits.Add(endUnit); Callback_OnEndTurn?.Invoke(endUnit); OnTurnEnd(endUnit); //开启下一个回合 if (CurTurnIndex >= AllUnits.Count - 1) { CurTurnIndex = 0; OnTurnAllEnd(); } //下一个单位 else { CurTurnIndex++; } StartTurn(); }
protected virtual void OnMoveStart() { BaseAStarMgr.GlobalMoveState.Add(); StateMachine.CurStateData?.OnMoveStart(); ClearNode(); ClearBlock(); GrabNewQuateration(); Callback_OnMoveStart?.Invoke(); if (UseFollowCoroutine) { BattleCoroutine.Kill(FollowPathCoroutine); FollowPathCoroutine = BattleCoroutine.Run(OnFollowPathCoroutine()); } }
protected virtual void OnMoveEnd() { BaseAStarMgr.GlobalMoveState.Remove(); BaseAStarMgr.SpeedUp(1.0f); StateMachine.CurStateData?.OnMoveEnd(); CalcCurNode(); CalcCurBlock(); GrabNewQuateration(); ChangeToEndState(); if (MoveTarget_IsInTarget()) { CancleMoveTarget(); } Callback_OnMoveEnd?.Invoke(); if (UseFollowCoroutine) { BattleCoroutine.Kill(FollowPathCoroutine); } }
public void RunMain() { BattleCoroutine.Kill(MainPlotCoroutine); MainPlotCoroutine = BattleCoroutine.Run(EnumMain()); }
void RunStart() { BattleCoroutine.Kill(StartPlotCoroutine); StartPlotCoroutine = BattleCoroutine.Run(CurData.OnPlotStart()); }
// 卸载战斗场景 protected void UnLoadBattle(Callback onDone = null) { BattleCoroutine.Kill(); MainUICoroutine.Run(_unLoadBattle(onDone)); }