-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFightGroupOverlay.cpp
94 lines (76 loc) · 2.42 KB
/
FightGroupOverlay.cpp
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
#include "FightGroupOverlay.h"
FightGroupOverlay::FightGroupOverlay(PlayerNum aiPlayerNum, int humanPlayerCount) :
aiPlayerNum(aiPlayerNum), humanPlayerCount(humanPlayerCount) {}
void FightGroupOverlay::Initialize(MAP_RECT guardedRect, std::vector<Unit> vehicleFactories)
{
this->vehicleFactories = vehicleFactories;
this->guardedRect = guardedRect;
fightGroup = CreateFightGroup(Player[aiPlayerNum]);
fightGroup.DoGuardRect();
fightGroup.SetRect(guardedRect);
fightGroup.AddGuardedRect(guardedRect);
if (buildingGroup.IsInitialized()) {
buildingGroup.Destroy();
}
buildingGroup = CreateBuildingGroup(Player[aiPlayerNum]);
buildingGroup.RecordVehReinforceGroup(fightGroup, 1);
for (Unit& vehicleFactory : vehicleFactories) {
if (vehicleFactory.IsLive()) {
buildingGroup.TakeUnit(vehicleFactory);
}
}
}
void FightGroupOverlay::SetTankCounts(const std::vector<TargetTankCount>& targetTankCounts)
{
targetCount = 0;
for (const auto& targetTankCount : targetTankCounts) {
targetCount += targetTankCount.count;
fightGroup.SetTargCount(targetTankCount.tankType, targetTankCount.weaponType, targetTankCount.count);
}
}
void FightGroupOverlay::AddTank(map_id tankType, map_id weapon)
{
int direction = TethysGame::GetRand(8);
Unit unit;
TethysGame::CreateUnit(unit, tankType, GetGuardedRect().RandPt(), aiPlayerNum, weapon, direction);
unit.DoSetLights(true);
fightGroup.TakeUnit(unit);
}
void FightGroupOverlay::ClearTargetCount()
{
fightGroup.ClearTargCount();
}
void FightGroupOverlay::SetLynxCount(map_id weaponType, int targetCount)
{
fightGroup.SetTargCount(map_id::mapLynx, weaponType, targetCount);
}
void FightGroupOverlay::SetPantherCount(map_id weaponType, int targetCount)
{
fightGroup.SetTargCount(map_id::mapPanther, weaponType, targetCount);
}
void FightGroupOverlay::SetTigerCount(map_id weaponType, int targetCount)
{
fightGroup.SetTargCount(map_id::mapTiger, weaponType, targetCount);
}
void FightGroupOverlay::SetScorpionCount(int targetCount)
{
fightGroup.SetTargCount(map_id::mapScorpion, map_id::mapEnergyCannon, targetCount);
}
MAP_RECT FightGroupOverlay::GetGuardedRect()
{
return guardedRect;
}
void FightGroupOverlay::BasicAttack() {
fightGroup.DoAttackEnemy();
}
FightGroup FightGroupOverlay::GetFightGroup() {
return fightGroup;
}
bool FightGroupOverlay::IsFull()
{
return GetFightGroupCount() == targetCount;
}
int FightGroupOverlay::GetFightGroupCount()
{
return fightGroup.TotalUnitCount();
}