123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182 |
- #pragma once
- #include <QObject>
- #include <QGraphicsItem>
- #include <queue>
- #include <vector>
- #include <memory>
- #include <iostream>
- #include <list>
- class Unit;
- class EffectsForCell;
- class Cell : public QGraphicsItem {
- private:
-
- Cell* leftUp_;
- Cell* left_;
- Cell* leftDown_;
- Cell* rightUp_;
- Cell* right_;
- Cell* rightDown_;
-
- std::shared_ptr<Unit> character_;
-
- std::vector<EffectsForCell*> effects_list_;
-
- bool isMoveAble_;
- bool isMeleeAttackAble_;
- bool isRangeAttackAble_;
-
- int distance_barrier_;
- int distance_through_;
- QPolygon polygon;
- public:
- QRectF boundingRect() const override;
- void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) override;
- virtual bool contains(const QPointF &point) const override;
- bool isHovered();
- void setHovered(bool hovered);
- void hoverEnterEvent(QGraphicsSceneHoverEvent *event) override;
- void hoverLeaveEvent(QGraphicsSceneHoverEvent *event) override;
- private:
-
- bool AddedToQuery_;
- int col_, row_;
- double coor_x_;
- double coor_y_;
- bool hovered_;
- void clearTable_();
- void clearCell_();
- void recalcAttackable_(Cell*, bool);
- void recalcMoveable_(Cell*, bool);
-
- void updateMoveableCells_(std::queue<Cell *> &Q);
-
- void updateUnMovealeCells_(std::queue<Cell *> &Q);
- public:
- explicit Cell(QGraphicsItem* parent = nullptr);
-
- Cell* getleftUp();
- void setleftUp(Cell*);
- Cell* getleft();
- void setleft(Cell*);
- Cell* getleftDown();
- void setleftDown(Cell*);
- Cell* getrightUp();
- void setrightUp(Cell*);
- Cell* getright();
- void setright(Cell*);
- Cell* getrightDown();
- void setrightDown(Cell *);
- std::shared_ptr<Unit> getCharacter();
- void setCharacter(std::shared_ptr<Unit>);
- double getXCoordinate();
- void setXCoordinate(double coordinate);
- double getYCoordinate();
- void setYCoordinate(double coordinate);
-
- int getdistance_barrier();
- void setdistance_barrier(int);
- int getdistance_through();
- void setdistance_through(int);
-
- bool getisMoveAble();
- void setisMoveAble(bool);
- bool getisMeleeAttackAble();
- void setisMeleeAttackAble(bool);
- bool getisRangeAttackAble();
- void setisRangeAttackAble(bool);
-
- bool isEmpty();
-
- void recalculateAllEffectsList();
- void add(EffectsForCell*);
- void remove(std::vector<EffectsForCell*>::iterator);
- void remove(EffectsForCell*);
- std::vector<EffectsForCell*>::iterator beginIteratorEffectsList();
- std::vector<EffectsForCell*>::iterator endIteratorEffectsList();
-
- void RecalculateTableWithCenterThisPoint();
-
- std::vector <Cell*> actualPath(Cell*);
-
- std::vector<std::pair<int, int> > getPoints(double, double);
- Cell* getRealShootTarget(Cell*);
- };
|