Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void StateSearchAround::Update(double dt)
- {
- PostOffice::GetInstance()->Send("Scene", new MessageWRU(m_go, MessageWRU::NEAREST_PLAYER, SceneData::GetInstance()->GetGridSize() * 10));
- if (m_go->nearest != NULL)
- {
- MazePt target;
- target.x = m_go->nearest->pos.x;
- target.y = m_go->nearest->pos.y;
- PostOffice::GetInstance()->Send("Scene", new MessageBFSLimit(m_go, target, 10));
- //set previous state number to know what previous state ai was in during next state
- SceneData::GetInstance()->SetMpreviousState(2);
- std::cout << "Found Player" << std::endl;
- if (!m_go->path.empty())
- {
- m_go->sm->SetNextState("Chase");
- }
- }
- else
- {
- //Random a point
- MazePt rand;
- int x, y;
- do
- {
- x = Math::RandIntMinMax(0, SceneData::GetInstance()->GetNoGrid() - 1);
- y = Math::RandIntMinMax(0, SceneData::GetInstance()->GetNoGrid() - 1);
- } while (SceneData::GetInstance()->Getmaze().See(MazePt(x, y)) != Maze::TILE_EMPTY);
- rand.x = x;
- rand.y = y;
- PostOffice::GetInstance()->Send("Scene", new MessageBFSLimit(m_go, rand, 10));
- if (!m_go->path.empty())
- {
- m_go->sm->SetNextState("Movearound");
- //std::cout << "Path: ";
- //for (auto pt : m_go->path)
- // {
- // std::cout << "(" << pt.x << "," << pt.y << ")->";
- // }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement