| | |
| | | battleState = StoryBattleState.Battle; |
| | | } |
| | | |
| | | LoadBattleMode(); |
| | | // LoadBattleMode(); |
| | | |
| | | chapter = FuncLineID / 10000; |
| | | wave = MapID == 1 ? FuncLineID % 100 : 1;//第几波怪 |
| | |
| | | |
| | | protected void LoadBattleMode() |
| | | { |
| | | string savedStr = LocalSave.GetString("StoryBattleFieldBattleMode"); |
| | | if (string.IsNullOrEmpty(savedStr)) |
| | | //主线模式:stop休息 无怪;Hand/Auto 有怪 等待指令 |
| | | BattleMode mode = BattleMode.Hand; |
| | | if (AutoFightModel.Instance.isAutoAttackSet) |
| | | { |
| | | savedStr = "Hand"; |
| | | mode = BattleMode.Auto; |
| | | } |
| | | SetBattleMode((BattleMode)Enum.Parse(typeof(BattleMode), savedStr)); |
| | | if (GetBattleMode() == mode) |
| | | return; |
| | | |
| | | SetBattleMode(mode); |
| | | } |
| | | |
| | | public override void AutoSetBattleMode() |
| | | { |
| | | LoadBattleMode(); |
| | | } |
| | | |
| | | |
| | | public override void TurnFightState(int TurnNum, int State, |
| | | uint FuncLineID, JsonData extendData) |
| | |
| | | // // HaveRest(); |
| | | // } |
| | | |
| | | // public override void Run() |
| | | // { |
| | | // // 一定要记住这个 |
| | | // if (IsPause) |
| | | // return; |
| | | |
| | | // base.Run(); |
| | | // } |
| | | public override void Run() |
| | | { |
| | | if (operationAgent == null) |
| | | { |
| | | //防范异常 |
| | | HaveRest(); |
| | | return; |
| | | } |
| | | base.Run(); |
| | | } |
| | | |
| | | public override void DistributeNextPackage() |
| | | { |
| | | // 不要调用base的函数 |
| | | BattleManager.Instance.DistributeNextPackage(); |
| | | } |
| | | |
| | | |
| | | //请求单次战斗 |
| | | public void RequestFight() |
| | | { |
| | | if (IsPause) |
| | | { |
| | | //还需考虑其他不可战斗状况,主线的BOSS战斗也是另外一个场景且不能切出来 等跳过或者结束 |
| | | //外部统一控制 IsPause |
| | | return; |
| | | } |
| | | if (BattleManager.Instance.isWaitServerStory) |
| | | return; |
| | | |
| | | // 当前没有在播放战斗录像 |
| | | if (!recordPlayer.IsPlaying()) |
| | | { |
| | | BattleDebug.LogError("HandModeOperationAgent DoNext 1"); |
| | | // 没有下一个包可以发了 |
| | | if (!BattleManager.Instance.DistributeNextPackage()) |
| | | { |
| | | |
| | | BattleDebug.LogError("HandModeOperationAgent DoNext 2"); |
| | | |
| | | // 检查一下锤子的消耗 |
| | | if (!ItemLogicUtility.CheckCurrencyCount(41, PlayerDatas.Instance.baseData.UseHarmerCount, 2)) |
| | | { |
| | | //多次防范 |
| | | if (GetBattleMode() != BattleMode.Stop) |
| | | HaveRest(); |
| | | return; |
| | | } |
| | | |
| | | // 请求下一个战斗包 或者检查战斗是否结束 |
| | | // ReqType; // 0-停止战斗回城;1-设置消耗倍值;2-挑战关卡小怪;3-挑战关卡boss;4-继续战斗; |
| | | // 如果在战斗 战斗是否结束/战斗持续中 结束应该是挑战下一关 持续应该是继续战斗 |
| | | |
| | | BattleDebug.LogError("HandModeOperationAgent DoNext 3"); |
| | | byte reqType; |
| | | |
| | | if (battleState == StoryBattleState.Break) |
| | | { |
| | | reqType = 2; |
| | | } |
| | | else if (battleState == StoryBattleState.Battle) |
| | | { |
| | | if (IsBattleEnd()) |
| | | { |
| | | reqType = 2; // 继续挑战小怪 |
| | | } |
| | | else |
| | | { |
| | | reqType = 4; // 继续战斗 |
| | | } |
| | | } |
| | | else |
| | | { |
| | | BattleDebug.LogError("unknown battle state"); |
| | | return; |
| | | } |
| | | |
| | | BattleDebug.LogError("HandModeOperationAgent DoNext 4 reqType is " + reqType); |
| | | |
| | | |
| | | // 如果请求的是2 说明要初始化一下战场 |
| | | BattleManager.Instance.MainFightRequest(reqType); |
| | | |
| | | // 初始化战场后本来不会自动打 那么就需要再请求一次4继续战斗 来开始战斗 |
| | | if (reqType == 2) |
| | | { |
| | | BattleManager.Instance.MainFightRequest(4); |
| | | } |
| | | } |
| | | } |
| | | // else |
| | | // { |
| | | // BattleDebug.LogError("action doesnt finish, wait a moment please"); |
| | | // } |
| | | } |
| | | } |