-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgoldmine.cpp
52 lines (47 loc) · 1.59 KB
/
goldmine.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
#include "goldmine.h"
#include "sound.h"
#include <sstream>
Goldmine::Goldmine(sf::RenderWindow* hutrieApplication, const std::vector<Unit*> &unitsFromGame)
: GoodsBuilding(hutrieApplication, unitsFromGame)
{
title.text.setString("Goldmine:");
goodReady.text.setString("Gold ready");
textureBasic.loadFromFile(Textures::goldmineBasic);
textureWithProduct.loadFromFile(Textures::goldmineWithProduct);
buildingConstructed = false;
leftConstructionTime = 0;
doorIndex = 3;
constructionTime = GameBalance::goldmineConstructionTime;
requiredForConstructionGoods = GameBalance::goldmineCost;
}
void Goldmine::createProduct()
{
myProducts.setProduct(4, 1);
}
void Goldmine::setConstructedBuildingSound()
{
sound.pause();
sound.openFromFile(Sound::goldmine);
if (isHighlighted())
{
sound.play();
}
}
void Goldmine::updateStatus()
{
if (buildingConstructed)
{
std::ostringstream desc;
desc << "Workers: " << myWorkers.size() << "/" << capacity << "\nCarriers: " <<
myCarriers.size() << "\nProducts in store: " << myProducts.getGold() << "/" << productsCapacity;
description.text.setString(desc.str());
}
else
{
std::ostringstream desc;
desc << "Construction finish in " << ceil(leftConstructionTime) << " sec.\n\n"
<< "\tWood: " << constructionGoods.getWood() << "/" << GameBalance::goldmineCost.getWood()
<< "\n\tStone: " << constructionGoods.getStone() << "/" << GameBalance::goldmineCost.getStone();
description.text.setString(desc.str());
}
}