Files
DNF_DEV/source_game/Actor/Map/Tile.cpp

49 lines
1.1 KiB
C++

#include "Tile.h"
#include "Tool/Tool_String.h"
#include "EngineCore/Game.h"
Tile::Tile()
{
}
Tile::Tile(std::string Path) : Sprite()
{
InitInfo(Path);
if (std::get<std::string>(m_data["path"]) == "")
m_data["path"] = "sprite/character/common/circlecooltime.img";
m_texture = new Texture();
m_texture->Init(std::get<std::string>(m_data["path"]), std::get<int>(m_data["idx"]));
Sprite::Init();
this->imgPath = Path;
}
Tile::~Tile()
{
}
void Tile::SetPos(Vec2 pos)
{
pos.y += std::get<int>(m_data["pos"]);
Sprite::SetPos(pos);
}
void Tile::InitInfo(std::string Path)
{
ScriptData Data = AssetManager::GetInstance().GetScriptInfo(Path);
m_data["pos"] = 0;
while (!Data.IsEnd())
{
std::string Segment = Data.Get();
if (Segment == "[IMAGE]")
{
std::string PathBuf = Tool_toLowerCase(Data.Get());
m_data["path"] = "sprite/" + PathBuf;
m_data["idx"] = std::stoi(Data.Get());
}
else if (Segment == "[img pos]")
{
m_data["pos"] = std::stoi(Data.Get());
}
}
}