#ifndef ROOM_H_ #define ROOM_H_ #include "Polygon.h" #include "LevelObject.h" #include "VertexProvider.h" #include "LevelVertex.h" #include class Room : public Polygon, public LevelObject, public VertexProvider { private: std::string name; float height; public: Room() {height = 10;} Room(std::string name) {this->name = name; height = 10;} std::string &getName() {return name;} const std::string &getName() const {return name;} void setName(const std::string &name) {this->name = name;} float getHeight() const {return height;} void setHeight(float height) {this->height = height;} virtual bool hit(const Vertex &v, float scale) const {return contains(v);} virtual int getPriority() const {return 0;} virtual std::vector > getChildren() { std::vector > children; for(size_t i = 0; i < size(); i++) children.push_back(SharedPtr(new LevelVertex(this, i))); return children; } virtual const char* getType() const { return "Room"; } virtual void move(float x, float y) { Vertex m(x, y); for(iterator v = begin(); v != end(); v++) *v += m; } virtual void rotate(float a) { Vertex z = getCenter(); float s = sinf(a); float c = cosf(a); for(iterator v = begin(); v != end(); v++) { *v -= z; v->setLocation(c*v->getX() - s*v->getY(), c*v->getY() + s*v->getX()); *v += z; } } virtual Vertex getCenter() const { Vertex ret; for(const_iterator v = begin(); v != end(); v++) ret += *v; return ret / size(); } virtual const Vertex* getVertex(size_t id) const { return &at(id); } virtual size_t getVertexCount() const { return size(); } virtual void moveVertex(size_t id, float x, float y) { at(id) += Vertex(x, y); } virtual void rotateVertex(size_t id, float a) { Vertex z = at(id); float s = sinf(a); float c = cosf(a); for(iterator v = begin(); v != end(); v++) { *v -= z; v->setLocation(c*v->getX() - s*v->getY(), c*v->getY() + s*v->getX()); *v += z; } } }; #endif /*ROOM_H_*/