yyl
2 天以前 5d3366f2e0f687995eb7ad2107c4379fe7acd4e8
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
 
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();
    }
}