-
Notifications
You must be signed in to change notification settings - Fork 0
/
FieldBackCoal.cpp
67 lines (56 loc) · 1.14 KB
/
FieldBackCoal.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
#include "FieldBackCoal.h"
#include "main.h"
#include "InventoryCoal.h"
FieldBackCoal::FieldBackCoal(void)
{
}
FieldBackCoal::~FieldBackCoal(void)
{
}
void FieldBackCoal::init(const int32_t &x, const int32_t &y)
{
FieldBack::init(x, y);
switch (myRand(x ^ (y<<2)) % 6)
{
case 0:
image = load_image("Background/Erze/Kohle/Kohle01.png");
break;
case 1:
image = load_image("Background/Erze/Kohle/Kohle02.png");
break;
case 2:
image = load_image("Background/Erze/Kohle/Kohle03.png");
break;
case 3:
image = load_image("Background/Erze/Kohle/Kohle04.png");
break;
case 4:
image = load_image("Background/Erze/Kohle/Kohle05.png");
break;
case 5:
image = load_image("Background/Erze/Kohle/Kohle06.png");
break;
}
}
void FieldBackCoal::myUpdate()
{
}
void FieldBackCoal::onUsed(const ToolTypes &toolType, const int32_t &toolLevel)
{
if (toolType == appropriateTool)
{
health -= 2*toolLevel*deltaTime;
}
else
{
health -= toolLevel*deltaTime;
}
if (health <= 0)
{
InventoryObject* inventoryObject = new InventoryCoal(1);
world.player.inventory.add(inventoryObject);
removeFromMap();
delete this;
return;
}
}