using UnityEngine; using System; using System.Collections; using System.Collections.Generic; // 自己推进战斗的 Editor下使用就好 public class AIOperationAgent : IOperationAgent { protected List attackList = new List(); 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 playList = new List(); 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 CreateBattleBeginActionList() { // 战斗开始前的轮次的操作 List returnList = new List(); // attackList return returnList; } protected List CreateRoundBeginActionList() { // 每轮开始前的操作 List returnList = new List(); // attackList return returnList; } protected List CreateActions(BattleObject _battleObj) { List returnList = new List(); List beforeActionList = CreateBeforeActionActionList(_battleObj); List actionList = CreateActionList(_battleObj); List afterActionList = CreateAfterActionList(_battleObj); List afterDeathActionList = CreateAfterDeathActionList(_battleObj); returnList.AddRange(beforeActionList); returnList.AddRange(actionList); returnList.AddRange(afterActionList); returnList.AddRange(afterDeathActionList); return returnList; } protected List CreateBeforeActionActionList(BattleObject _battleObj) { // 解异常 加减buff List returnList = new List(); return returnList; } protected List CreateActionList(BattleObject _battleObj) { // 放技能 或者被眩晕 List returnList = new List(); // // 能行动 // 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 CreateAfterActionList(BattleObject _battleObj) { // 其他角色可能有连携攻击 有可能每回合buff有个dot List returnList = new List(); return returnList; } protected List CreateAfterDeathActionList(BattleObject _battleObj) { // 复活 给其他角色加buff之类的操作 List returnList = new List(); return returnList; } protected void OnHeroDeath(BattleObject _battleObj) { } protected void OnReviveHero(BattleObject _battleObj) { } public override void DoNext() { base.DoNext(); } }