|   | 
| using UnityEngine; | 
| using System; | 
| using System.Collections; | 
| using System.Collections.Generic; | 
|   | 
| // 自己推进战斗的 Editor下使用就好 | 
| public class AIOperationAgent : IOperationAgent | 
| { | 
|   | 
|     protected List<BattleObject> attackList = new List<BattleObject>(); | 
|   | 
|     public AIOperationAgent(BattleField _battleField) : base (_battleField) | 
|     { | 
|          | 
|     } | 
|   | 
|     public override void Run() | 
|     { | 
|         base.Run(); | 
|   | 
|         bool isBattleBegin = battleField.round == 0 && attackList.Count <= 0; | 
|   | 
|         bool isRoundBegin = attackList.Count <= 0; | 
|   | 
|         if (attackList.Count <= 0 && !battleField.recordPlayer.IsPlaying()) | 
|         { | 
|   | 
|             // 战斗开始前,根据各自上阵武将战力之和决定谁为先攻方,战力之和高的为先攻主,先攻方优先攻击,确定先攻方后开始战斗。 | 
|   | 
|   | 
|             attackList.AddRange(battleField.battleObjMgr.redCampList); | 
|             attackList.AddRange(battleField.battleObjMgr.blueCampList); | 
|   | 
|             // //    排序 战斗力高的靠前 | 
|             // attackList.Sort((a, b) => { | 
|             //     int power1 = a.teamHero.GetPower(); | 
|             //     int power2 = b.teamHero.GetPower(); | 
|             //     return power2.CompareTo(power1); | 
|             // }); | 
|   | 
|             battleField.round++; | 
|         } | 
|   | 
|         if (!battleField.recordPlayer.IsPlaying() && attackList.Count > 0) | 
|         { | 
|             List<RecordAction> playList = new List<RecordAction>(); | 
|             if (isBattleBegin) | 
|             { | 
|                 playList.AddRange(CreateBattleBeginActionList()); | 
|             } | 
|             else | 
|             { | 
|                 if (isRoundBegin) | 
|                 { | 
|                     playList.AddRange(CreateRoundBeginActionList()); | 
|                 } | 
|                 else | 
|                 { | 
|                     playList.AddRange(CreateActions(attackList[0])); | 
|                     attackList.RemoveAt(0); | 
|                 } | 
|             } | 
|   | 
|             battleField.recordPlayer.PlayRecord(playList); | 
|         } | 
|     } | 
|   | 
|     protected List<RecordAction> CreateBattleBeginActionList() | 
|     { | 
|         //    战斗开始前的轮次的操作 | 
|         List<RecordAction> returnList = new List<RecordAction>(); | 
|         // attackList | 
|         return returnList; | 
|     } | 
|   | 
|     protected List<RecordAction> CreateRoundBeginActionList() | 
|     { | 
|         //    每轮开始前的操作 | 
|         List<RecordAction> returnList = new List<RecordAction>(); | 
|         // attackList | 
|         return returnList; | 
|     } | 
|   | 
|     protected List<RecordAction> CreateActions(BattleObject _battleObj) | 
|     { | 
|         List<RecordAction> returnList = new List<RecordAction>(); | 
|   | 
|         List<RecordAction> beforeActionList = CreateBeforeActionActionList(_battleObj); | 
|         List<RecordAction> actionList = CreateActionList(_battleObj); | 
|         List<RecordAction> afterActionList = CreateAfterActionList(_battleObj); | 
|         List<RecordAction> afterDeathActionList = CreateAfterDeathActionList(_battleObj); | 
|   | 
|         returnList.AddRange(beforeActionList); | 
|         returnList.AddRange(actionList); | 
|         returnList.AddRange(afterActionList); | 
|         returnList.AddRange(afterDeathActionList); | 
|   | 
|         return returnList; | 
|     } | 
|   | 
|     protected List<RecordAction> CreateBeforeActionActionList(BattleObject _battleObj) | 
|     { | 
|         // 解异常 加减buff  | 
|         List<RecordAction> returnList = new List<RecordAction>(); | 
|         return returnList; | 
|     } | 
|   | 
|     protected List<RecordAction> CreateActionList(BattleObject _battleObj) | 
|     { | 
|         //    放技能 或者被眩晕 | 
|         List<RecordAction> returnList = new List<RecordAction>(); | 
|   | 
|   | 
|         // //    能行动 | 
|         // if (_battleObj.IsCanDoActions()) | 
|         // { | 
|         //     //    能放技能 | 
|         //     if (_battleObj.IsCanCastSkill()) | 
|         //     { | 
|         //         SkillRecordAction action = new SkillRecordAction(_battleObj.teamHero.heroInfo.heroConfig.AngerSkillID,  | 
|         //             battleField, _battleObj); | 
|   | 
|         //         // 在这里主动做一下伤害计算 正常都是服务器给的 | 
|   | 
|   | 
|         //         returnList.Add(action); | 
|         //     } | 
|         //     else | 
|         //     { | 
|         //         //普攻 | 
|         //     } | 
|         // } | 
|         // else | 
|         // { | 
|         //     //    不能行动 飘字 过 | 
|   | 
|         // } | 
|   | 
|         return returnList; | 
|     } | 
|   | 
|     protected List<RecordAction> CreateAfterActionList(BattleObject _battleObj) | 
|     { | 
|         //    其他角色可能有连携攻击 有可能每回合buff有个dot | 
|         List<RecordAction> returnList = new List<RecordAction>(); | 
|         return returnList; | 
|     } | 
|   | 
|     protected List<RecordAction> CreateAfterDeathActionList(BattleObject _battleObj) | 
|     { | 
|         //    复活 给其他角色加buff之类的操作 | 
|         List<RecordAction> returnList = new List<RecordAction>(); | 
|         return returnList; | 
|     } | 
|   | 
|     protected void OnHeroDeath(BattleObject _battleObj) | 
|     { | 
|   | 
|     } | 
|   | 
|     protected void OnReviveHero(BattleObject _battleObj) | 
|     { | 
|   | 
|     } | 
|   | 
|     public override void DoNext() | 
|     { | 
|         base.DoNext(); | 
|     } | 
| } |