mirror of
https://github.com/DerTyp7/grow-ai-unity.git
synced 2025-10-30 12:57:09 +01:00
better pathfinding
This commit is contained in:
@@ -105,17 +105,17 @@ public class Pathfinding {
|
|||||||
// Left
|
// Left
|
||||||
neighbourList.Add(GetNode(currentNode.x - 1, currentNode.y));
|
neighbourList.Add(GetNode(currentNode.x - 1, currentNode.y));
|
||||||
// Left Down
|
// Left Down
|
||||||
if (currentNode.y - 1 >= 0) neighbourList.Add(GetNode(currentNode.x - 1, currentNode.y - 1));
|
// if (currentNode.y - 1 >= 0) neighbourList.Add(GetNode(currentNode.x - 1, currentNode.y - 1));
|
||||||
// Left Up
|
// Left Up
|
||||||
if (currentNode.y + 1 < grid.GetHeight()) neighbourList.Add(GetNode(currentNode.x - 1, currentNode.y + 1));
|
// if (currentNode.y + 1 < grid.GetHeight()) neighbourList.Add(GetNode(currentNode.x - 1, currentNode.y + 1));
|
||||||
}
|
}
|
||||||
if (currentNode.x + 1 < grid.GetWidth()) {
|
if (currentNode.x + 1 < grid.GetWidth()) {
|
||||||
// Right
|
// Right
|
||||||
neighbourList.Add(GetNode(currentNode.x + 1, currentNode.y));
|
neighbourList.Add(GetNode(currentNode.x + 1, currentNode.y));
|
||||||
// Right Down
|
// Right Down
|
||||||
if (currentNode.y - 1 >= 0) neighbourList.Add(GetNode(currentNode.x + 1, currentNode.y - 1));
|
// if (currentNode.y - 1 >= 0) neighbourList.Add(GetNode(currentNode.x + 1, currentNode.y - 1));
|
||||||
// Right Up
|
// Right Up
|
||||||
if (currentNode.y + 1 < grid.GetHeight()) neighbourList.Add(GetNode(currentNode.x + 1, currentNode.y + 1));
|
// if (currentNode.y + 1 < grid.GetHeight()) neighbourList.Add(GetNode(currentNode.x + 1, currentNode.y + 1));
|
||||||
}
|
}
|
||||||
// Down
|
// Down
|
||||||
if (currentNode.y - 1 >= 0) neighbourList.Add(GetNode(currentNode.x, currentNode.y - 1));
|
if (currentNode.y - 1 >= 0) neighbourList.Add(GetNode(currentNode.x, currentNode.y - 1));
|
||||||
|
|||||||
@@ -145,15 +145,20 @@ public class Person : MonoBehaviour
|
|||||||
|
|
||||||
void Work()
|
void Work()
|
||||||
{
|
{
|
||||||
|
if (status != PersonStatus.WORK)
|
||||||
|
movement.SetTarget(workplace.transform.position);
|
||||||
status = PersonStatus.WORK;
|
status = PersonStatus.WORK;
|
||||||
movement.SetTarget(workplace.transform.position);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Sleep()
|
void Sleep()
|
||||||
{
|
{
|
||||||
|
if(status != PersonStatus.SLEEP)
|
||||||
|
movement.SetTarget(house.transform.position);
|
||||||
|
|
||||||
status = PersonStatus.SLEEP;
|
status = PersonStatus.SLEEP;
|
||||||
Debug.Log(house.transform.position);
|
Debug.Log(house.transform.position);
|
||||||
movement.SetTarget(house.transform.position);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void SetBehaivorDateTimes()
|
void SetBehaivorDateTimes()
|
||||||
|
|||||||
Reference in New Issue
Block a user