diff --git a/include/Map/Map.hpp b/include/Map/Map.hpp index 2022d493..0bb97b6a 100644 --- a/include/Map/Map.hpp +++ b/include/Map/Map.hpp @@ -54,6 +54,7 @@ class MapClass : public Core::Drawable { void InitGrid(); private: + const glm::vec2 m_MapTransShift = {10, -10}; std::vector> m_Images; std::unordered_map> m_Tiles; unsigned int m_MapWdith = 0; diff --git a/include/Map/Tile.hpp b/include/Map/Tile.hpp index 23d1cc60..5c833e4a 100644 --- a/include/Map/Tile.hpp +++ b/include/Map/Tile.hpp @@ -68,19 +68,20 @@ class TileClass { } void removeAvatar(std::shared_ptr avatar) { - for (auto i : m_Avatars) { - if (i == avatar) { - std::remove(m_Avatars.begin(), m_Avatars.end(), i); + for (int i = 0; i < m_Avatars.size(); i++) { + if (m_Avatars[i] == avatar) { + auto it = m_Avatars.begin() + i; + m_Avatars.erase(it); + i--; + if (m_Avatars.size() < 4) { setWalkable(true); } if (m_Avatars.size() == 0) { setBuildable(true); } - return; } } - LOG_DEBUG("Remove Avatar Failed"); } void removeStructure() { diff --git a/src/Avatar/Avatar.cpp b/src/Avatar/Avatar.cpp index a58620f7..fbce6255 100644 --- a/src/Avatar/Avatar.cpp +++ b/src/Avatar/Avatar.cpp @@ -49,7 +49,8 @@ void Avatar::spawnedUpdate() { void Avatar::moveUpdate() { if (ifArrivedAtNextCell()) { - if (m_MovePath.size() >= 1) { + m_PrevCell = getCurrentCell(); + if (!m_MovePath.empty()) { m_CurrentDir = m_MovePath.front(); m_MovePath.pop_front(); } else { diff --git a/src/Map/Map.cpp b/src/Map/Map.cpp index 00e6cd1f..9d8097cf 100644 --- a/src/Map/Map.cpp +++ b/src/Map/Map.cpp @@ -38,21 +38,22 @@ std::shared_ptr MapClass::getTileByCellPosition(glm::vec2 position) { if (position.x > m_MapWdith - 1 || position.y > m_MapHeight - 1 || position.x < 0 || position.y < 0) { - LOG_DEBUG("False Position Getting"); - return std::make_shared(UnitType::null, 0, 0, 0, ""); + std::cerr << "False Position Getting" << position.x << position.y + << std::endl; + return nullptr; } return m_Map[position.x][position.y]; } void MapClass::Draw(const Util::Transform &trans, const float zindex) { + auto maptrans = trans; + maptrans.translation.x += m_MapTransShift.x; + maptrans.translation.y += m_MapTransShift.y; - Util::Transform mapTrans; - - mapTrans.translation = m_MapPosition; for (auto i : m_Images) { - i->DrawUsingCamera(mapTrans, 1); + i->DrawUsingCamera(maptrans, zindex); } - m_Grid.DrawUsingCamera(mapTrans, zindex); + m_Grid.DrawUsingCamera(trans, zindex - 0.2); } void MapClass::Init(std::vector>> map, diff --git a/src/Mechanics/AvatarNavigator.cpp b/src/Mechanics/AvatarNavigator.cpp index 65c2f502..81dd25e3 100644 --- a/src/Mechanics/AvatarNavigator.cpp +++ b/src/Mechanics/AvatarNavigator.cpp @@ -282,7 +282,7 @@ bool AvatarNavigator::canResumeWalkingStraight(glm::vec2 currentcell, glm::vec2 destinationcell) { std::vector path; auto arrived = findStraightPath(currentcell, destinationcell, &path); - if (arrived || !path.empty()) { + if (arrived) { return true; } return false; diff --git a/src/Scene/MapScene.cpp b/src/Scene/MapScene.cpp index 30d3cbbc..fd024a0e 100644 --- a/src/Scene/MapScene.cpp +++ b/src/Scene/MapScene.cpp @@ -17,5 +17,5 @@ void MapScene::Update() { Util::Transform trans; trans.scale = {1, 1}; trans.translation = {0, 0}; - m_Map->Draw(trans, 0); + m_Map->Draw(trans, -0.1); }