mirror of
https://github.com/Karaka-Management/phpOMS.git
synced 2026-02-10 22:18:40 +00:00
Update Grid.php
This commit is contained in:
parent
095fd15607
commit
6efc4e157b
|
|
@ -51,7 +51,7 @@ class Grid
|
||||||
$x = $node->getX();
|
$x = $node->getX();
|
||||||
$y = $node->getY();
|
$y = $node->getY();
|
||||||
|
|
||||||
$neighbours = [];
|
$neighbors = [];
|
||||||
$s0 = false;
|
$s0 = false;
|
||||||
$s1 = false;
|
$s1 = false;
|
||||||
$s2 = false;
|
$s2 = false;
|
||||||
|
|
@ -61,30 +61,28 @@ class Grid
|
||||||
$d2 = false;
|
$d2 = false;
|
||||||
$d3 = false;
|
$d3 = false;
|
||||||
|
|
||||||
$nodes = $this->nodes;
|
|
||||||
|
|
||||||
if ($this->getNode($x, $y - 1)->isWalkable()) {
|
if ($this->getNode($x, $y - 1)->isWalkable()) {
|
||||||
$neighbours[$x][$y - 1];
|
$neighbors[$x][$y - 1];
|
||||||
$s0 = true;
|
$s0 = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($this->getNode($x + 1, $y)->isWalkable()) {
|
if ($this->getNode($x + 1, $y)->isWalkable()) {
|
||||||
$neighbours[$x + 1][$y];
|
$neighbors[$x + 1][$y];
|
||||||
$s1 = true;
|
$s1 = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($this->getNode($x, $y + 1)->isWalkable()) {
|
if ($this->getNode($x, $y + 1)->isWalkable()) {
|
||||||
$neighbours[$x][$y + 1];
|
$neighbors[$x][$y + 1];
|
||||||
$s2 = true;
|
$s2 = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($this->getNode($x - 1, $y)->isWalkable()) {
|
if ($this->getNode($x - 1, $y)->isWalkable()) {
|
||||||
$neighbours[$x - 1][$y];
|
$neighbors[$x - 1][$y];
|
||||||
$s3 = true;
|
$s3 = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($movement === MovementType::STRAIGHT) {
|
if ($movement === MovementType::STRAIGHT) {
|
||||||
return $neighbours;
|
return $neighbors;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($movement === MovementType::DIAGONAL_NO_OBSTACLE) {
|
if ($movement === MovementType::DIAGONAL_NO_OBSTACLE) {
|
||||||
|
|
@ -103,5 +101,23 @@ class Grid
|
||||||
$d2 = true;
|
$d2 = true;
|
||||||
$d3 = true;
|
$d3 = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($d0 && $this->getNode($x - 1, $y - 1)->isWalkable()) {
|
||||||
|
$neighbors[] = $this->getNode($x - 1, $y - 1]);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($d1 && $this->getNode($x + 1, $y - 1)->isWalkable()) {
|
||||||
|
$neighbors[] = $this->getNode($x + 1, $y - 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($d2 && $this->getNode($x + 1, $y + 1)->isWalkable()) {
|
||||||
|
$neighbors[] = $this->getNode($x + 1, $y + 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($d3 && $this->getNode($x - 1, $y + 1)->isWalkable()) {
|
||||||
|
$neighbors[] = $this->getNode($x - 1, $y + 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $neighbors;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user