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
|
void loadData(castle &al3a, queue &q, float &c1, float &c2, float &c3)
{
int i = 0;
ifstream myfile;
int n = 0;
myfile.open("data.txt");
if (myfile.fail())
{
cout << "Error" << endl;
myfile.close();
}
else {
string line;
while (!myfile.eof())
{
n++;
getline(myfile, line);
}
}
myfile.close();
string line2;
int T_Health;
int T_Attack_N_Enemies;
int T_Fire_Power;
myfile.open("data.txt");
myfile >> T_Health >> T_Attack_N_Enemies >> T_Fire_Power;
getline(myfile, line2);
myfile >> c1 >> c2 >> c3;
getline(myfile, line2);
int a,b,c,d,e,f;
char g;
enemy x;
for (int i = 0; i < n - 3; i++)
{
myfile >> a >> b >> c >> d >> e >> f >> g;
x.ID = a;
x.type = static_cast<Type>(b);
x.time_step = c;
x.Health = d;
x.fire_power = e;
x.reload_power = f;
x.region = static_cast<Region>(g);
enqueue(q, x);
getline(myfile, line2);
}
for (int i = 0; i < 4; i++)
{
al3a.towers[i].Health = T_Health;
al3a.towers[i].attackEnemies = T_Attack_N_Enemies;
al3a.towers[i].firePower = T_Fire_Power;
al3a.towers[i].Tregion = (Region)i;
}
}
|