wangguan
2020-12-08 3d13f2e8a23602aedb8adf5d2d02e377a330a61b
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
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
using System.Collections.Generic;
using UnityEngine;
using TowerDefense.Towers.Placement;
using TowerDefense.Towers;
using TowerDefense.UI.HUD;
 
/**
 * 禁锢泡泡
 * @Author: chenxin
 * @Date: 2020-12-03 10:54:12
 */
namespace KTGMGemClient
{
    public class BossSkillBondageBubble : EndlessBossSkill
    {
        public BossSkillBondageBubble(boss_skill param) : base(param) { }
 
        /// <summary>
        /// 禁锢警告时间
        /// </summary>
        private float BondageTime = 1f;
 
        public override void Init()
        {
            base.Init();
            Debug.Log("--------------------- 禁锢泡泡技能初始化 ---------------------");
        }
 
        /// <summary>
        /// 释放技能
        /// </summary>
        public override void ReleaseSkill()
        {
            base.ReleaseSkill();
 
            switch ((EndlessBossSkillUseTarget)SkillData.target[0])
            {
                case EndlessBossSkillUseTarget.Tower:
                    switch ((EndlessBossSkillTowerType)SkillData.target[1])
                    {
                        case EndlessBossSkillTowerType.All:
                            ReleaseAll();
                            break;
                        case EndlessBossSkillTowerType.Single:
                            ReleaseSingle();
                            break;
                        case EndlessBossSkillTowerType.Random:
                            ReleaseRandom();
                            break;
                        case EndlessBossSkillTowerType.MaxAttack:
                            ReleaseMaxAttack();
                            break;
                        default:
                            Debug.LogWarning($"---- 禁锢泡泡技能,目标参数不正确 Target[{SkillData.target[0]}, {SkillData.target[1]}] ----");
                            break;
                    }
                    break;
                default:
                    Debug.LogWarning("---- 禁锢泡泡技能只支持作用在精灵塔上 ----");
                    break;
            }
        }
 
        private void ReleaseAll()
        {
            List<int> tunelIdList = GetTunelList();
            int dy = TowerPlacementGridEndless.instance.dimensions.y;
            int attackRows = TowerPlacementGridEndless.instance.AttackRowNumbers;
 
            for (int i = 0; i < tunelIdList.Count; ++i)
            {
                for (int j = dy - attackRows; j < dy; ++j)
                {
                    Tower tower = EndlessGameUI.instance.FindTowerWithGridIdx(tunelIdList[i] - 1, j);
 
                    if (tower != null && !tower.IsBondage)
                    {
                        tower.IsBondage = true;
                        tower.IsStartBondage = true;
                        tower.BondageTime = SkillData.effect[0];
                        tower.BondageClickDecreaseTime = SkillData.effect[1];
                        tower.BondageWarningTime = BondageTime;
                        tower.BondageWarning();
                    }
                }
            }
        }
 
        private void ReleaseSingle()
        {
            List<int> tunelIdList = GetTunelList();
            int dy = TowerPlacementGridEndless.instance.dimensions.y;
            int attackRows = TowerPlacementGridEndless.instance.AttackRowNumbers;
 
            for (int i = 0; i < tunelIdList.Count; ++i)
            {
                // 只作用于第一排的塔
                Tower tower = EndlessGameUI.instance.FindTowerWithGridIdx(tunelIdList[i] - 1, 3);
 
                if (tower != null)
                {
                    tower.IsBondage = true;
                    tower.IsStartBondage = true;
                    tower.BondageTime = SkillData.effect[0];
                    tower.BondageClickDecreaseTime = SkillData.effect[1];
                    tower.BondageWarningTime = BondageTime;
                    tower.BondageWarning();
                    break;
                }
            }
        }
 
        private void ReleaseRandom()
        {
            List<int> tunelIdList = GetTunelList();
            int dy = TowerPlacementGridEndless.instance.dimensions.y;
            int attackRows = TowerPlacementGridEndless.instance.AttackRowNumbers;
 
            for (int i = 0; i < tunelIdList.Count; ++i)
            {
                List<Tower> towerList = new List<Tower>();
 
                for (int j = dy - 1; j >= dy - attackRows; --j)
                {
                    Tower tower = EndlessGameUI.instance.FindTowerWithGridIdx(tunelIdList[i] - 1, j);
 
                    if (tower != null && !tower.IsBondage)
                        towerList.Add(tower);
                }
 
                if (towerList.Count > 0)
                {
                    // 现在只作用于第一排的塔
                    // int random = UnityEngine.Random.Range(0, towerList.Count);
                    int random = 0;
                    towerList[random].IsBondage = true;
                    towerList[random].IsStartBondage = true;
                    towerList[random].BondageTime = SkillData.effect[0];
                    towerList[random].BondageClickDecreaseTime = SkillData.effect[1];
                    towerList[random].BondageWarningTime = BondageTime;
                    towerList[random].BondageWarning();
                }
            }
        }
 
        private void ReleaseMaxAttack()
        {
            List<int> tunelIdList = GetTunelList();
            int dy = TowerPlacementGridEndless.instance.dimensions.y;
            int attackRows = TowerPlacementGridEndless.instance.AttackRowNumbers;
 
            for (int i = 0; i < tunelIdList.Count; ++i)
            {
                Tower tower = null;
 
                for (int j = dy - 1; j >= dy - attackRows; --j)
                {
                    Tower tmp = EndlessGameUI.instance.FindTowerWithGridIdx(tunelIdList[i] - 1, j);
 
                    if (tmp != null && !tmp.IsBondage)
                    {
                        if (tower == null)
                            tower = tmp;
                        else
                        {
                            float tmpDamage = GetTowerDamage(tmp);
                            float towerDamage = GetTowerDamage(tower);
 
                            if (tmpDamage > towerDamage)
                                tower = tmp;
                        }
                    }
                }
 
                if (tower != null)
                {
                    tower.IsBondage = true;
                    tower.IsStartBondage = true;
                    tower.BondageTime = SkillData.effect[0];
                    tower.BondageClickDecreaseTime = SkillData.effect[1];
                    tower.BondageWarningTime = BondageTime;
                    tower.BondageWarning();
                }
            }
        }
 
        /// <summary>
        /// 计算塔的攻击力
        /// </summary>
        /// <param name="tower"></param>
        /// <returns></returns>
        private float GetTowerDamage(Tower tower)
        {
            if (tower == null) return 0;
 
            // 基础伤害 = elf_info 基础攻击力 * elf_upgrade 攻击比率 / 1000f
            float basicDamage = ElfInfoData.GetBasicDamage(tower.ElfId, tower.currentLevel);
 
            // 处理PVE无尽模式,buff增加的伤害
            if (EndlessBuffManager.instanceExists)
                basicDamage += EndlessBuffManager.instance.ProcessEndlessBuffAttack(basicDamage, tower.ElfId);
 
            return basicDamage;
        }
    }
}