-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathbuilding.cpp
More file actions
93 lines (74 loc) · 1.91 KB
/
Copy pathbuilding.cpp
File metadata and controls
93 lines (74 loc) · 1.91 KB
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
#include "building.h"
#include <cstdlib>
#include <cmath>
#include "iostream"
#include "map.h"
Building::Building()
{
}
Barracks::Barracks(Position pos, int team) : Building("Barracks", pos, team, 0, 1500)
{
}
void Barracks::produce(vector<Unit *> &VUnit_)
{
Map* map = Map::get();
Position newPos = map->findPositionAvailable(pos_);
if(newPos.getX() != -1) //Si la position est bien disponible
{
setWaiting(125);
Marine * newMarine = new Marine(newPos, team_);
map->add(newMarine->getName()[0], newPos);
VUnit_.push_back(newMarine);
}
}
Gateway::Gateway(Position pos, int team) : Building("Gateway", pos, team, 0, 2000)
{
}
void Gateway::produce(vector<Unit *> &VUnit_)
{
Map* map = Map::get();
Position newPos = map->findPositionAvailable(pos_);
if(newPos.getX() != -1)
{
setWaiting(190);
Zealot * newZealot = new Zealot(newPos, team_);
Map* map = Map::get();
map->add(newZealot->getName()[0], newPos);
VUnit_.push_back(newZealot);
}
}
Hatchery::Hatchery(Position pos, int team) : Building("Hatchery", pos, team, 0, 1500)
{
}
void Hatchery::produce(vector<Unit *> &VUnit_)
{
Map* map = Map::get();
for(int i = 0; i < 2; i++)
{
Position newPos = map->findPositionAvailable(pos_);
if(newPos.getX() != -1)
{
setWaiting(120);
Ling * newLing1 = new Ling(newPos, team_);
map->add(newLing1->getName()[0], newPos);
VUnit_.push_back(newLing1);
}
}
}
Building * BuildingFactory::create(char race, Position pos, int team)
{
Building * bat = nullptr;
if (race == 'T' || race == 't')
{
bat = new Barracks(pos, team);
}
if (race == 'P' || race == 'p')
{
bat = new Gateway(pos, team);
}
if (race == 'Z' || race == 'z')
{
bat = new Hatchery(pos, team);
}
return bat;
}