51 lines
1.3 KiB
C++
51 lines
1.3 KiB
C++
#include "GameMapLayer.h"
|
||
#include "EngineCore/Game.h"
|
||
|
||
void GameMapLayer::Render()
|
||
{
|
||
Actor::Render();
|
||
// 自身坐标
|
||
glm::vec2 Pos = this->ConvertToWorld({0, 0});
|
||
// 可行区域
|
||
for (auto &info : this->FeasibleAreaInfoList)
|
||
{
|
||
SDL_Rect buf;
|
||
buf.x = info.x + Pos.x;
|
||
buf.y = info.y + Pos.y;
|
||
buf.w = info.w;
|
||
buf.h = info.h;
|
||
glm::vec4 red = {1.0f, 0.0f, 0.0f, 0.4f}; // RGBA:红色,不透明基础色
|
||
Game::GetInstance().GetRenderer()->DrawRect(&buf, red);
|
||
}
|
||
// 移动区域
|
||
for (auto &info : this->MoveAreaInfoList)
|
||
{
|
||
SDL_Rect buf;
|
||
buf.x = info.x + Pos.x;
|
||
buf.y = info.y + Pos.y;
|
||
buf.w = info.w;
|
||
buf.h = info.h;
|
||
glm::vec4 red = {0.0f, 0.0f, 1.0f, 0.4f}; // RGBA:红色,不透明基础色
|
||
Game::GetInstance().GetRenderer()->DrawRect(&buf, red);
|
||
}
|
||
}
|
||
|
||
void GameMapLayer::AddDebugFeasibleAreaInfo(Vec2 pos, VecSize size, int Type)
|
||
{
|
||
SDL_Rect info;
|
||
info.x = pos.x;
|
||
info.y = pos.y;
|
||
info.w = size.width;
|
||
info.h = size.height;
|
||
|
||
if (Type == 0)
|
||
this->FeasibleAreaInfoList.push_back(info);
|
||
else if (Type == 1)
|
||
this->MoveAreaInfoList.push_back(info);
|
||
}
|
||
|
||
void GameMapLayer::AddObject(RefPtr<Actor> obj)
|
||
{
|
||
this->AddChild(obj);
|
||
}
|