1
This commit is contained in:
parent
841fdde99e
commit
8e58095243
@ -278,62 +278,66 @@ bool TiledMap::CalcCurrPos(std::vector<int>& path_points, int old_pos_x, int old
|
|||||||
if (path_points.size() < 2) {
|
if (path_points.size() < 2) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
std::string path_point;
|
|
||||||
std::vector<std::string> stage_path_list;
|
std::vector<std::string> stage_path_list;
|
||||||
bool path_start = true;
|
{
|
||||||
std::vector<GridCell*> grid_all_list;
|
std::string path_point;
|
||||||
for (auto& point : path_points) {
|
bool path_start = true;
|
||||||
if (path_start) {
|
for (auto& point : path_points) {
|
||||||
path_point = a8::XValue(point).GetString();
|
if (path_start) {
|
||||||
path_start = !path_start;
|
path_point = a8::XValue(point).GetString();
|
||||||
} else {
|
path_start = !path_start;
|
||||||
std::string point_str = a8::XValue(point).GetString();
|
} else {
|
||||||
path_point += "-" + point_str;
|
std::string point_str = a8::XValue(point).GetString();
|
||||||
stage_path_list.push_back(path_point);
|
path_point += "-" + point_str;
|
||||||
path_point = point_str;
|
stage_path_list.push_back(path_point);
|
||||||
}
|
path_point = point_str;
|
||||||
}
|
|
||||||
|
|
||||||
bool exc_once = true;
|
|
||||||
for (auto& stage_path : stage_path_list) {
|
|
||||||
std::vector<GridCell*>* grid_list = nullptr;
|
|
||||||
|
|
||||||
std::string stage_path_reverse;
|
|
||||||
std::vector<std::string> split_list;
|
|
||||||
a8::Split(stage_path,split_list,'-');
|
|
||||||
if (split_list.size() != 2) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
StagePoint* sp = GetStageObject(a8::XValue(split_list.at(0)));
|
|
||||||
if (sp == nullptr) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
grid_list = GetStagePath(stage_path);
|
|
||||||
if (grid_list == nullptr) {
|
|
||||||
stage_path_reverse = split_list[1] + "-" + split_list[0];
|
|
||||||
grid_list = GetStagePath(stage_path_reverse);
|
|
||||||
if (grid_list == nullptr) {
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
std::vector<GridCell*> grid_all_list;
|
||||||
|
{
|
||||||
|
bool exc_once = true;
|
||||||
|
for (auto& stage_path : stage_path_list) {
|
||||||
|
std::vector<GridCell*>* grid_list = nullptr;
|
||||||
|
|
||||||
std::vector<GridCell*> grid_sort_list = SortGridList(grid_list,sp);
|
std::string stage_path_reverse;
|
||||||
if (grid_sort_list.empty()){
|
std::vector<std::string> split_list;
|
||||||
return false;
|
a8::Split(stage_path,split_list,'-');
|
||||||
}
|
if (split_list.size() != 2) {
|
||||||
if (exc_once) {
|
return false;
|
||||||
grid_all_list.insert(grid_all_list.end(),grid_sort_list.begin(),grid_sort_list.end());
|
}
|
||||||
exc_once = false;
|
StagePoint* sp = GetStageObject(a8::XValue(split_list.at(0)));
|
||||||
} else {
|
if (sp == nullptr) {
|
||||||
grid_all_list.insert(grid_all_list.end(),grid_sort_list.begin()+1,grid_sort_list.end());
|
return false;
|
||||||
|
}
|
||||||
|
grid_list = GetStagePath(stage_path);
|
||||||
|
if (grid_list == nullptr) {
|
||||||
|
stage_path_reverse = split_list[1] + "-" + split_list[0];
|
||||||
|
grid_list = GetStagePath(stage_path_reverse);
|
||||||
|
if (grid_list == nullptr) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
std::vector<GridCell*> grid_sort_list = SortGridList(grid_list,sp);
|
||||||
|
if (grid_sort_list.empty()){
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (exc_once) {
|
||||||
|
grid_all_list.insert(grid_all_list.end(),grid_sort_list.begin(),grid_sort_list.end());
|
||||||
|
exc_once = false;
|
||||||
|
} else {
|
||||||
|
grid_all_list.insert(grid_all_list.end(),grid_sort_list.begin()+1,grid_sort_list.end());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (grid_all_list.empty()) {
|
if (grid_all_list.empty()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
int grid_all_count = grid_all_list.size();
|
{
|
||||||
for (int i = 0; i < grid_all_count-1; ++i) {
|
int grid_all_count = grid_all_list.size();
|
||||||
|
for (int i = 0; i < grid_all_count-1; ++i) {
|
||||||
GridCell* gc_first = grid_all_list[i];
|
GridCell* gc_first = grid_all_list[i];
|
||||||
GridCell* gc_second = grid_all_list[i+1];
|
GridCell* gc_second = grid_all_list[i+1];
|
||||||
int speed = gc_first->speed;
|
int speed = gc_first->speed;
|
||||||
@ -354,6 +358,7 @@ bool TiledMap::CalcCurrPos(std::vector<int>& path_points, int old_pos_x, int old
|
|||||||
if (time_ms < 0) {
|
if (time_ms < 0) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (time_ms > 0) {
|
if (time_ms > 0) {
|
||||||
return true;
|
return true;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user