1
This commit is contained in:
parent
899a79c08e
commit
6a18bf87a5
@ -105,3 +105,5 @@ const int GUN_SLOT2 = 2;
|
|||||||
const int FRAG_SLOT = 3;
|
const int FRAG_SLOT = 3;
|
||||||
const int SMOKE_SLOT = 4;
|
const int SMOKE_SLOT = 4;
|
||||||
|
|
||||||
|
const int MAP_HEIGHT = 8192;
|
||||||
|
const int MAP_WIDTH = 8192;
|
||||||
|
@ -166,14 +166,14 @@ bool Human::IsCollision()
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
int right_x = pos.x + meta->i->radius();
|
int right_x = pos.x + meta->i->radius();
|
||||||
if (right_x > room->map_meta->i->width()) {
|
if (right_x > MAP_WIDTH) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//检查y轴
|
//检查y轴
|
||||||
{
|
{
|
||||||
int up_y = pos.y + meta->i->radius();
|
int up_y = pos.y + meta->i->radius();
|
||||||
if (up_y > room->map_meta->i->height()) {
|
if (up_y > MAP_HEIGHT) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
int down_y = pos.y - meta->i->radius();
|
int down_y = pos.y - meta->i->radius();
|
||||||
|
@ -5,6 +5,39 @@
|
|||||||
namespace MetaData
|
namespace MetaData
|
||||||
{
|
{
|
||||||
|
|
||||||
|
void Map::Init()
|
||||||
|
{
|
||||||
|
rand_space = 0;
|
||||||
|
{
|
||||||
|
std::vector<std::string> strings;
|
||||||
|
a8::Split(i->template_list(), strings, '|');
|
||||||
|
for (auto& str : strings) {
|
||||||
|
std::vector<std::string> strings2;
|
||||||
|
a8::Split(str, strings2, ':');
|
||||||
|
assert(strings2.size() == 2);
|
||||||
|
rand_space += a8::XValue(strings[1]).GetInt();
|
||||||
|
template_list.push_back(std::make_tuple(
|
||||||
|
strings[0],
|
||||||
|
rand_space
|
||||||
|
));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string Map::RandTemplate()
|
||||||
|
{
|
||||||
|
if (rand_space > 0) {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
int rnd = rand() % rand_space;
|
||||||
|
for (auto& tpl : template_list) {
|
||||||
|
if (rnd <= std::get<1>(tpl)) {
|
||||||
|
return std::get<0>(tpl);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
void Drop::Init()
|
void Drop::Init()
|
||||||
{
|
{
|
||||||
std::vector<std::string> item_list;
|
std::vector<std::string> item_list;
|
||||||
|
@ -13,6 +13,12 @@ namespace MetaData
|
|||||||
struct Map
|
struct Map
|
||||||
{
|
{
|
||||||
const metatable::Map* i = nullptr;
|
const metatable::Map* i = nullptr;
|
||||||
|
|
||||||
|
std::vector<std::tuple<std::string, int>> template_list;
|
||||||
|
int rand_space = 0;
|
||||||
|
|
||||||
|
void Init();
|
||||||
|
std::string RandTemplate();
|
||||||
};
|
};
|
||||||
|
|
||||||
struct MapThing
|
struct MapThing
|
||||||
|
@ -24,7 +24,6 @@ void Obstacle::Initialize()
|
|||||||
|
|
||||||
void Obstacle::RecalcSelfCollider()
|
void Obstacle::RecalcSelfCollider()
|
||||||
{
|
{
|
||||||
#if 1
|
|
||||||
if (is_door) {
|
if (is_door) {
|
||||||
//门
|
//门
|
||||||
if (!self_collider2_) {
|
if (!self_collider2_) {
|
||||||
@ -61,71 +60,12 @@ void Obstacle::RecalcSelfCollider()
|
|||||||
self_collider2_->owner = this;
|
self_collider2_->owner = this;
|
||||||
colliders.push_back(self_collider2_);
|
colliders.push_back(self_collider2_);
|
||||||
}
|
}
|
||||||
self_collider2_->_min = Vector2D(meta->i->height() / -2.0f, meta->i->width() / -2.0f);
|
self_collider2_->_min = Vector2D(meta->i->width() / -2.0f, meta->i->height() / -2.0f);
|
||||||
self_collider2_->_max = Vector2D(meta->i->height() / 2.0f, meta->i->width() / 2.0f);
|
self_collider2_->_max = Vector2D(meta->i->width() / 2.0f, meta->i->height() / 2.0f);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#else
|
|
||||||
switch (meta->i->thing_id()) {
|
|
||||||
case 61101:
|
|
||||||
{
|
|
||||||
if (!self_collider2_) {
|
|
||||||
self_collider2_ = new AabbCollider();
|
|
||||||
self_collider2_->owner = this;
|
|
||||||
colliders.push_back(self_collider2_);
|
|
||||||
}
|
|
||||||
self_collider2_->_min = Vector2D(-16.0f, -16.0f);
|
|
||||||
self_collider2_->_max = Vector2D(16.0f, 16.0f);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case 61017:
|
|
||||||
{
|
|
||||||
//玻璃32 * 12
|
|
||||||
if (!self_collider2_) {
|
|
||||||
self_collider2_ = new AabbCollider();
|
|
||||||
self_collider2_->owner = this;
|
|
||||||
colliders.push_back(self_collider2_);
|
|
||||||
}
|
|
||||||
self_collider2_->_min = Vector2D(-16.0f, -16.0f);
|
|
||||||
self_collider2_->_max = Vector2D(6.0f, 6.0f);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case 61401:
|
|
||||||
{
|
|
||||||
if (!self_collider_) {
|
|
||||||
self_collider_ = new CircleCollider();
|
|
||||||
self_collider_->owner = this;
|
|
||||||
colliders.push_back(self_collider_);
|
|
||||||
}
|
|
||||||
self_collider_->pos = Vector2D();
|
|
||||||
self_collider_->rad = 32 / 2.0;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case 61018:
|
|
||||||
{
|
|
||||||
if (is_door) {
|
|
||||||
//门
|
|
||||||
if (!self_collider2_) {
|
|
||||||
self_collider2_ = new AabbCollider();
|
|
||||||
self_collider2_->owner = this;
|
|
||||||
colliders.push_back(self_collider2_);
|
|
||||||
}
|
|
||||||
if (door_state == DoorStateClose) {
|
|
||||||
self_collider2_->_min = Vector2D(0.0f - door_state0->width() / 2.0f,
|
|
||||||
0.0f - door_state0->height() / 2.0f);
|
|
||||||
self_collider2_->_max = Vector2D(door_state0->width() / 2.0f, door_state0->height() / 2.0f);
|
|
||||||
} else {
|
|
||||||
self_collider2_->_min = Vector2D(0.0f - door_state1->width() / 2.0f,
|
|
||||||
0.0f - door_state1->height() / 2.0f);
|
|
||||||
self_collider2_->_max = Vector2D(door_state1->width(), door_state1->height());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Obstacle::FillMFObjectPart(cs::MFObjectPart* part_data)
|
void Obstacle::FillMFObjectPart(cs::MFObjectPart* part_data)
|
||||||
|
@ -470,8 +470,8 @@ void Room::UpdateGas()
|
|||||||
gas_data.new_area_meta = MetaMgr::Instance()->GetSafeArea(30002);
|
gas_data.new_area_meta = MetaMgr::Instance()->GetSafeArea(30002);
|
||||||
gas_data.gas_progress = gas_data.old_area_meta->i->rad();
|
gas_data.gas_progress = gas_data.old_area_meta->i->rad();
|
||||||
gas_data.gas_start_frameno = frame_no;
|
gas_data.gas_start_frameno = frame_no;
|
||||||
gas_data.pos_old = Vector2D(map_meta->i->width() / 2.0f,
|
gas_data.pos_old = Vector2D(MAP_WIDTH / 2.0f,
|
||||||
map_meta->i->height() / 2.0f);
|
MAP_HEIGHT / 2.0f);
|
||||||
gas_data.pos_old_bk = gas_data.pos_old;
|
gas_data.pos_old_bk = gas_data.pos_old;
|
||||||
{
|
{
|
||||||
bool gen_ok = GenSmallCircle(gas_data.pos_old,
|
bool gen_ok = GenSmallCircle(gas_data.pos_old,
|
||||||
|
@ -64,8 +64,6 @@ void RoomMgr::_CMJoin(f8::MsgHdr& hdr, const cs::CMJoin& msg)
|
|||||||
{
|
{
|
||||||
cs::SMMapInfo notifymsg;
|
cs::SMMapInfo notifymsg;
|
||||||
notifymsg.set_map_id(room->map_meta->i->map_id());
|
notifymsg.set_map_id(room->map_meta->i->map_id());
|
||||||
notifymsg.set_width(room->map_meta->i->width());
|
|
||||||
notifymsg.set_height(room->map_meta->i->height());
|
|
||||||
GGListener::Instance()->SendToClient(hdr.socket_handle, hdr.seqid, notifymsg);
|
GGListener::Instance()->SendToClient(hdr.socket_handle, hdr.seqid, notifymsg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -591,8 +591,6 @@ message SMJoinedNotify
|
|||||||
message SMMapInfo
|
message SMMapInfo
|
||||||
{
|
{
|
||||||
optional int32 map_id = 1; //地图id
|
optional int32 map_id = 1; //地图id
|
||||||
optional int32 width = 2; //地图宽度
|
|
||||||
optional int32 height = 3; //地图高度
|
|
||||||
repeated MFMapObject objects = 6; //地图对象
|
repeated MFMapObject objects = 6; //地图对象
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -9,8 +9,7 @@ message Parameter
|
|||||||
message Map
|
message Map
|
||||||
{
|
{
|
||||||
optional int32 map_id = 1; //地图id
|
optional int32 map_id = 1; //地图id
|
||||||
optional int32 width = 2; //地图宽度
|
optional string template_list = 2; //模板列表
|
||||||
optional int32 height = 3; //地图高度
|
|
||||||
}
|
}
|
||||||
|
|
||||||
message MapThing
|
message MapThing
|
||||||
@ -134,3 +133,13 @@ message BuildingJson
|
|||||||
|
|
||||||
optional int32 _building_id = 20;
|
optional int32 _building_id = 20;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
message MapTplThingJson
|
||||||
|
{
|
||||||
|
optional string layer_name = 1;
|
||||||
|
optional string name = 2;
|
||||||
|
optional string things = 3;
|
||||||
|
optional int32 weight = 4;
|
||||||
|
optional float x = 5;
|
||||||
|
optional float y = 6;
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user