添加地图读表功能

This commit is contained in:
aozhiwei 2019-09-07 21:30:37 +08:00
parent ab50308220
commit 24b37d8d32
3 changed files with 23 additions and 17 deletions

View File

@ -192,11 +192,6 @@ const int GUN_SLOT2 = 2;
const int FRAG_SLOT = 3;
const int SMOKE_SLOT = 4;
const int MAP_HEIGHT = 8192;
const int MAP_WIDTH = 8192;
const int MAP_CELL_WIDTH = 64 * 8;
const int MAP_GRID_WIDTH = 64;
const int DOOR_THING_ID = 61701;
const int FIGHTING_MODE_BULLET_NUM = 10000 * 10000;

View File

@ -39,6 +39,15 @@ Room::~Room()
void Room::Init()
{
const int MAP_HEIGHT = 8192;
const int MAP_WIDTH = 8192;
const int MAP_CELL_WIDTH = 64 * 8;
const int MAP_GRID_WIDTH = 64;
#if 1
((metatable::Map*)map_meta->i)->set_map_width(MAP_WIDTH);
((metatable::Map*)map_meta->i)->set_map_height(MAP_HEIGHT);
#endif
xtimer.Init(RoomXGetTickCount, this, 100, 100);
xtimer_attacher.xtimer = &xtimer;
grid_service.Init(MAP_WIDTH, MAP_HEIGHT, MAP_CELL_WIDTH);
@ -518,14 +527,14 @@ int Room::CreateLoot(int equip_id, a8::Vec2 pos, int count, int equip_lv)
entity->pos = pos;
#if 1
{
if (entity->pos.x >= MAP_WIDTH) {
entity->pos.x = MAP_WIDTH - 1;
if (entity->pos.x >= map_meta->i->map_width()) {
entity->pos.x = map_meta->i->map_width() - 1;
}
if (entity->pos.x < 1.0f) {
entity->pos.x = 1.0f;
}
if (entity->pos.y >= MAP_HEIGHT) {
entity->pos.y = MAP_HEIGHT - 1;
if (entity->pos.y >= map_meta->i->map_height()) {
entity->pos.y = map_meta->i->map_height() - 1;
}
if (entity->pos.y < 1.0f) {
entity->pos.y = 1.0f;
@ -646,14 +655,14 @@ bool Room::OverBorder(const a8::Vec2 pos, float radius)
return true;
}
int right_x = pos.x + radius;
if (right_x > MAP_WIDTH) {
if (right_x > map_meta->i->map_width()) {
return true;
}
}
//检查y轴
{
int up_y = pos.y + radius;
if (up_y > MAP_HEIGHT) {
if (up_y > map_meta->i->map_height()) {
return true;
}
int down_y = pos.y - radius;
@ -980,8 +989,8 @@ void Room::UpdateGas()
gas_data.new_area_meta = MetaMgr::Instance()->GetSafeArea(30002);
gas_data.gas_progress = gas_data.old_area_meta->i->rad();
gas_data.gas_start_frameno = frame_no;
gas_data.pos_old = a8::Vec2(MAP_WIDTH / 2.0f,
MAP_HEIGHT / 2.0f);
gas_data.pos_old = a8::Vec2(map_meta->i->map_width() / 2.0f,
map_meta->i->map_height() / 2.0f);
gas_data.pos_old_bk = gas_data.pos_old;
{
bool gen_ok = GenSmallCircle(gas_data.pos_old,
@ -1253,14 +1262,14 @@ void Room::AirDrop(int appear_time, int box_id)
if (box_pos.x < 1.0f) {
box_pos.x = 1.0f;
}
if (box_pos.x >= MAP_WIDTH) {
box_pos.x = MAP_WIDTH - 1;
if (box_pos.x >= map_meta->i->map_width()) {
box_pos.x = map_meta->i->map_width() - 1;
}
if (box_pos.y < 1.0f) {
box_pos.y = 1.0f;
}
if (box_pos.y >= MAP_HEIGHT) {
box_pos.y = MAP_HEIGHT - 1;
if (box_pos.y >= map_meta->i->map_height()) {
box_pos.y = map_meta->i->map_height() - 1;
}
AabbCollider air_drop_aabb_box;
{

View File

@ -17,6 +17,8 @@ message Map
optional int32 map_id = 1; //id
optional string template_list = 2; //
optional string map_name = 3; //
optional float map_width = 4;
optional float map_height = 5;
}
message MapThing