|
@@ -8,6 +8,7 @@
|
|
#include <vector>
|
|
#include <vector>
|
|
#include <map>
|
|
#include <map>
|
|
#include <iostream>
|
|
#include <iostream>
|
|
|
|
+#include <cmath>
|
|
|
|
|
|
class EffectsForCell{
|
|
class EffectsForCell{
|
|
public:
|
|
public:
|
|
@@ -22,7 +23,7 @@ Cell::Cell()
|
|
clearCell_();
|
|
clearCell_();
|
|
AddedToQuery_ = true;
|
|
AddedToQuery_ = true;
|
|
col_ = row_ = 0;
|
|
col_ = row_ = 0;
|
|
- coor_x_ = coor_y_ = 0;
|
|
|
|
|
|
+ coor_x_ = coor_y_ = -1;
|
|
}
|
|
}
|
|
|
|
|
|
Cell * Cell::getleftUp() {
|
|
Cell * Cell::getleftUp() {
|
|
@@ -61,10 +62,10 @@ Cell * Cell::getrightDown() {
|
|
void Cell::setrightDown(Cell * t) {
|
|
void Cell::setrightDown(Cell * t) {
|
|
rightDown_ = t;
|
|
rightDown_ = t;
|
|
}
|
|
}
|
|
-Unit * Cell::getCharacter() {
|
|
|
|
|
|
+std::shared_ptr<Unit> Cell::getCharacter() {
|
|
return character_;
|
|
return character_;
|
|
}
|
|
}
|
|
-void Cell::setCharacter(Unit * t) {
|
|
|
|
|
|
+void Cell::setCharacter(std::shared_ptr<Unit> t) {
|
|
character_ = t;
|
|
character_ = t;
|
|
}
|
|
}
|
|
|
|
|
|
@@ -82,8 +83,7 @@ double Cell::getYCoordinate() {
|
|
return coor_y_;
|
|
return coor_y_;
|
|
}
|
|
}
|
|
|
|
|
|
-void Cell::setXCoordinate(double coordinate)
|
|
|
|
-{
|
|
|
|
|
|
+void Cell::setYCoordinate(double coordinate) {
|
|
coor_y_ = coordinate;
|
|
coor_y_ = coordinate;
|
|
}
|
|
}
|
|
|
|
|
|
@@ -224,7 +224,7 @@ void Cell::clearTable_() {
|
|
}
|
|
}
|
|
|
|
|
|
void Cell::recalcAttackable_(Cell * Now,bool isReached){
|
|
void Cell::recalcAttackable_(Cell * Now,bool isReached){
|
|
- /* if(Now == nullptr)return;
|
|
|
|
|
|
+ if(Now == nullptr)return;
|
|
if (!isEmpty() && !Now->isEmpty() &&
|
|
if (!isEmpty() && !Now->isEmpty() &&
|
|
getCharacter()->canAttackForDistance("Melee", Now->getdistance_barrier())
|
|
getCharacter()->canAttackForDistance("Melee", Now->getdistance_barrier())
|
|
) {
|
|
) {
|
|
@@ -234,7 +234,7 @@ void Cell::recalcAttackable_(Cell * Now,bool isReached){
|
|
getCharacter()->canAttackForDistance("Range", Now->getdistance_barrier())
|
|
getCharacter()->canAttackForDistance("Range", Now->getdistance_barrier())
|
|
) {
|
|
) {
|
|
Now->setisRangeAttackAble(true);
|
|
Now->setisRangeAttackAble(true);
|
|
- }*/
|
|
|
|
|
|
+ }
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
|
|
|
|
@@ -281,6 +281,7 @@ void Cell::updateMoveableCells_(std::queue<Cell*> & Q) {
|
|
void Cell::updateUnMovealeCells_(std::queue<Cell*> & Q) {
|
|
void Cell::updateUnMovealeCells_(std::queue<Cell*> & Q) {
|
|
auto f = [&Q](Cell * t, Cell * parent) {
|
|
auto f = [&Q](Cell * t, Cell * parent) {
|
|
if (t && !t->AddedToQuery_) {
|
|
if (t && !t->AddedToQuery_) {
|
|
|
|
+ parent->getCharacter();
|
|
t->AddedToQuery_ = true;
|
|
t->AddedToQuery_ = true;
|
|
Q.push(t);
|
|
Q.push(t);
|
|
}
|
|
}
|
|
@@ -350,7 +351,15 @@ Cell* Cell::getRealShootTarget(Cell* next){
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
-void Cell::print(){
|
|
|
|
- return;
|
|
|
|
- //do nothing, need content
|
|
|
|
|
|
+std::vector<std::pair<double, double> > Cell::getPoints(double radius, double start_angle) {
|
|
|
|
+ const double delta_radians = acos(-1) / 180.0;
|
|
|
|
+ std::vector<std::pair<double, double> > res;
|
|
|
|
+ std::vector<double> angles = {0, 60, 120, 180, 240, 300};
|
|
|
|
+ for(size_t i = 0;i < angles.size();++i){
|
|
|
|
+ angles[i] += start_angle;
|
|
|
|
+ res.push_back({coor_x_ + radius * std::cos(angles[i] * delta_radians),
|
|
|
|
+ coor_y_ + radius * std::sin(angles[i] * delta_radians)});
|
|
|
|
+ }
|
|
|
|
+ return res;
|
|
}
|
|
}
|
|
|
|
+
|