Repository navigation
Expand file tree
/
Copy pathCoatingUnion.cpp
More file actions
98 lines (85 loc) · 2.05 KB
/
Copy pathCoatingUnion.cpp
File metadata and controls
98 lines (85 loc) · 2.05 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
94
95
96
97
98
#include "AllRtmClasses.h"
rtm::CoatingUnion::CoatingUnion()
: type_{ NoCoatingUnion }
, column_{ 0 }
, row_{ 0 }
, width_{ 0 }
, height_{ 0 }
, objects_{}
{}
rtm::CoatingUnion::CoatingUnion(CoatingUnionType type, int column, int row, CoatingMatrix&& objects)
: type_{ type }
, column_{ column }
, row_{ row }
, width_{ 0 }
, height_{ 0 }
, objects_{ std::move(objects) }
{
if (!objects_.empty()) {
if (!objects_[0].empty()) {
width_ = objects_.size();
height_ = objects_[0].size();
}
}
}
rtm::CoatingUnionType rtm::CoatingUnion::GetType() const
{
return type_;
}
size_t rtm::CoatingUnion::GetWidth() const
{
return width_;
}
size_t rtm::CoatingUnion::GetHeight() const
{
return height_;
}
rtm::CoatingUnique const& rtm::CoatingUnion::GetCoatingObject(int column, int row) const
{
return objects_[column - column_][row - row_];
}
float rtm::CoatingUnion::GetLength() const
{
return 1.0f;
}
bool rtm::CoatingUnion::IsCorrectColumn(int column) const
{
return column >= column_ && column < static_cast<int>(column_ + width_);
}
bool rtm::CoatingUnion::IsCorrectRow(int row) const
{
return row >= row_ && row < static_cast<int>(row_ + height_);
}
void rtm::CoatingUnion::ShowSprites(cocos2d::Layer* const layer)
{
for (auto& col : objects_) {
for (auto& elem : col) {
if (elem) {
if (elem->GetSprite() != nullptr) {
layer->addChild(elem->GetSprite(), COATING_OBJECT_Z_ORDER);
}
}
}
}
}
void rtm::CoatingUnion::ReleaseSprites(cocos2d::Layer* const layer)
{
for (auto& col : objects_) {
for (auto& elem : col) {
if (elem) {
if (elem->GetSprite() != nullptr) {
layer->removeChild(elem->GetSprite());
}
elem.reset();
}
}
}
}
int rtm::CoatingUnion::GetColumn_() const
{
return column_;
}
int rtm::CoatingUnion::GetRow_() const
{
return row_;
}