-
Notifications
You must be signed in to change notification settings - Fork 2
/
building.cpp
131 lines (119 loc) · 4.01 KB
/
building.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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
#include "stdafx.h"
#include "building.h"
void building::render(HDC hdc)
{
if ((float)currentHp / maxHp <= 0.8f) {
_hpBar.setGauge(maxHp, currentHp, CAMERA->GetRelativeX(rc.left), CAMERA->GetRelativeY(rc.bottom));
_hpBar.render(hdc);
}
RECT temp = { CAMERA->GetRelativeX(this->rc.left), CAMERA->GetRelativeY(this->rc.top) , CAMERA->GetRelativeX(this->rc.right) , CAMERA->GetRelativeY(this->rc.bottom) };
if (PtInRect(&temp, UNITMANAGER->GetPlayerFootPt()) && CAMERA->movelimit) {
IMAGEMANAGER->alphaRender(objKey + "design", hdc, CAMERA->GetRelativeX(rc.left), CAMERA->GetRelativeY(rc.bottom - IMAGEMANAGER->findImage(objKey)->getHeight()), 150, CAMERA->GetZoom());
}
else {
IMAGEMANAGER->frameRender(objKey, hdc, CAMERA->GetRelativeX(rc.left), CAMERA->GetRelativeY(rc.bottom - IMAGEMANAGER->findImage(objKey)->getFrameHeight()), objFrameX, objFrameY, CAMERA->GetZoom());
}
if (objKey == "goddess") {
if (CAMERA->GetZoom() >= 0.7f) {
TEXTMANAGER->ShowText(hdc, true, "여신의 우물 Lv." + to_string(level), { (rc.left + 15), (rc.bottom - IMAGEMANAGER->findImage(objKey)->getHeight()) }, 30, 0, RGB(255, 255, 255), true);
}
}
if (objKey == "elvenstatue") {
if (CAMERA->GetZoom() >= 0.7f) {
TEXTMANAGER->ShowText(hdc, true, "요정의 나무 Lv." + to_string(level), { (rc.left + 15), (rc.bottom - IMAGEMANAGER->findImage(objKey)->getHeight()) }, 30, 0, RGB(255, 255, 255), true);
}
}
if (objKey == "tombCenter") {
if (CAMERA->GetZoom() >= 0.7f) {
TEXTMANAGER->ShowText(hdc, true, "산신령의 묘석 Lv." + to_string(level), { (rc.left + 15), (rc.bottom - IMAGEMANAGER->findImage(objKey)->getHeight()) }, 30, 0, RGB(255, 255, 255), true);
}
}
}
void building::setBuilding(string buildingName, tile* _tile, int tileindex)
{
_tiles.push_back(_tile);
RECT temp = _tile->rc;
this->rc = temp;
this->layer = LAYER::OBJECT;
this->objMaxFrameX = 2;
this->objMaxFrameY = 0;
if (buildingName == "bridge") {
_tile->canPass = true;
this->layer = LAYER::TERRAIN;
this->objMaxFrameX = 3;
}
this->tag = TAG::BUILDING;
this->objFrameX = 0;
this->objFrameY = 0;
this->currentCount = 0;
this->nextCount = 2;
this->objKey = buildingName;
this->dropItem.itemKey = "treeDrop";
this->maxHp = BUILDINGHP;
this->exp = 0;
this->tileIndex = tileindex;
currentHp = maxHp;
_hpBar.init("hpBar", "hpBarBG");
}
void building::setBuilding(string buildingName, vector<tile*> tiles, int tileindex)
{
_tiles = tiles;
RECT temp = { _tiles[0]->rc.left, _tiles[0]->rc.top, _tiles[tiles.size()-1]->rc.right, _tiles[tiles.size() - 1]->rc.bottom };
this->rc = temp;
this->layer = LAYER::OBJECT;
this->tag = TAG::BUILDING;
this->objFrameX = 0;
this->objFrameY = 0;
this->objMaxFrameX = 2;
this->objMaxFrameY = 0;
this->currentCount = 0;
this->nextCount = 2;
this->objKey = buildingName;
this->dropItem.itemKey = "treeDrop";
this->maxHp = BUILDINGHP;
this->exp = 0;
this->tileIndex = tileindex;
currentHp = maxHp;
_hpBar.init("hpBar", "hpBarBG");
}
void building::setSpecialBuilding(string buildingName, vector<tile*> tiles, int tileindex)
{
_tiles = tiles;
RECT temp = { _tiles[0]->rc.left, _tiles[0]->rc.top, _tiles[tiles.size() - 1]->rc.right, _tiles[tiles.size() - 1]->rc.bottom };
this->rc = temp;
this->layer = LAYER::OBJECT;
this->tag = TAG::BUILDING;
this->objFrameX = 0;
this->objFrameY = 0;
this->objMaxFrameX = 2;
this->objMaxFrameY = 0;
this->currentCount = 0;
this->nextCount = 2;
this->objKey = buildingName;
this->dropItem.itemKey = "treeDrop";
this->maxHp = BUILDINGHP;
this->exp = 0;
this->tileIndex = tileindex;
currentHp = 9999;
level = 1;
_hpBar.init("hpBar", "hpBarBG");
}
void building::dead()
{
// 파괴되면 필드아이템 생성
UNITMANAGER->AddUnits(dropItem.itemKey, { GetCenterX(), GetCenterY() - 25 });
for (int i = 0; i < _tiles.size(); i++) {
_tiles[i]->hasUnit = false;
_tiles[i]->canPass = (objKey == "bridge") ? false : true;
}
}
void building::hurt(int damage, bool onlyEffect)
{
SOUNDMANAGER->play("바위타격");
isHit = true;
if (onlyEffect)
return;
currentHp -= damage;
if (currentHp <= 0)
dead();
}