示例#1
0
 //结束当前回合
 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);
 }
示例#2
0
        //开始
        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();
            }
        }
示例#3
0
        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;
            }
        }
示例#4
0
 protected override void OnBattleUnLoad()
 {
     base.OnBattleUnLoad();
     _flagPause.Reset();
     CurOperatingUnit = null;
     BattleCoroutine.Kill(OnInEndTurnCoroutine);
     BattleCoroutine.Kill(OnInPostEndTurnCoroutine);
 }
示例#5
0
 //停止所有的临时剧情
 void StopAllTempPlot()
 {
     TempPlotFlag.Clear();
     foreach (var item in TempPlotCoroutines)
     {
         BattleCoroutine.Kill(item);
     }
     TempPlotCoroutines.Clear();
 }
示例#6
0
 // 停止一段剧情
 public virtual void Stop()
 {
     StopAllTempPlot();
     BattleCoroutine.Kill(StartPlotCoroutine);
     BattleCoroutine.Kill(MainPlotCoroutine);
     if (CurData == null)
     {
         return;
     }
     CurData.OnBeRemoved();
     CurData = null;
 }
示例#7
0
 void RecreateAlerts()
 {
     foreach (var alert in ActiveItems)
     {
         GOPool.Despawn(alert.gameObject);
     }
     ActiveItems.Clear();
     if (delayCallTask != null)
     {
         BattleCoroutine.Kill(delayCallTask);
     }
     delayCallTask = BattleCoroutine.Run(AddInitAlerts());
 }
示例#8
0
        //操作回合:回调函数
        #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();
        }
示例#9
0
        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());
            }
        }
示例#10
0
        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);
            }
        }
示例#11
0
 public void RunMain()
 {
     BattleCoroutine.Kill(MainPlotCoroutine);
     MainPlotCoroutine = BattleCoroutine.Run(EnumMain());
 }
示例#12
0
 void RunStart()
 {
     BattleCoroutine.Kill(StartPlotCoroutine);
     StartPlotCoroutine = BattleCoroutine.Run(CurData.OnPlotStart());
 }
示例#13
0
 // 卸载战斗场景
 protected void UnLoadBattle(Callback onDone = null)
 {
     BattleCoroutine.Kill();
     MainUICoroutine.Run(_unLoadBattle(onDone));
 }