建档
This commit is contained in:
45
source_game/Actor/Map/Tile.cpp
Normal file
45
source_game/Actor/Map/Tile.cpp
Normal file
@@ -0,0 +1,45 @@
|
||||
#include "Tile.h"
|
||||
#include "Tool/Tool_String.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(std::get<std::string>(m_data["path"]), std::get<int>(m_data["idx"]));
|
||||
Sprite::Init();
|
||||
}
|
||||
|
||||
Tile::~Tile()
|
||||
{
|
||||
}
|
||||
|
||||
void Tile::SetPos(VecFPos 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());
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user