1
This commit is contained in:
parent
397388b577
commit
605f8b0d38
@ -0,0 +1,249 @@
|
|||||||
|
#include "precompile.h"
|
||||||
|
|
||||||
|
#include <f8/utils.h>
|
||||||
|
|
||||||
|
#include "airdrop.h"
|
||||||
|
#include "room.h"
|
||||||
|
|
||||||
|
#include "mt/AirDrop.h"
|
||||||
|
|
||||||
|
AirDrop::AirDrop(Room* room)
|
||||||
|
{
|
||||||
|
room_ = room;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void AirDrop::Init()
|
||||||
|
{
|
||||||
|
mt::AirDrop::Traverse
|
||||||
|
(
|
||||||
|
[this] (const mt::AirDrop* air_drop_meta, bool& stop)
|
||||||
|
{
|
||||||
|
if (air_drop_meta->id() >= 1 && air_drop_meta->id() <= 6) {
|
||||||
|
room_->xtimer.SetTimeoutEx
|
||||||
|
(SERVER_FRAME_RATE * air_drop_meta->time(),
|
||||||
|
[this, air_drop_meta] (int event, const a8::Args* args) mutable
|
||||||
|
{
|
||||||
|
if (a8::TIMER_EXEC_EVENT == event) {
|
||||||
|
if (!room_->IsGameOver()) {
|
||||||
|
Exec(
|
||||||
|
air_drop_meta->appear_time(),
|
||||||
|
air_drop_meta->RandDrop(),
|
||||||
|
air_drop_meta->id()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
&room_->xtimer_attacher_);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
void AirDrop::Exec(int appear_time, int box_id, int airdrop_id)
|
||||||
|
{
|
||||||
|
#ifdef DEBUG
|
||||||
|
if (!f8::IsTestEnv()) {
|
||||||
|
a8::XPrintf("AirDrop appear_time:%d box_id:%d airdrop_id:%d\n",
|
||||||
|
{
|
||||||
|
appear_time,
|
||||||
|
box_id,
|
||||||
|
airdrop_id
|
||||||
|
});
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
// 888
|
||||||
|
#if 0
|
||||||
|
const mt::MapThing* thing_meta = MetaMgr::Instance()->GetMapThing(box_id);
|
||||||
|
if (thing_meta && thing_meta->type() == 2) {
|
||||||
|
a8::Vec2 dir = a8::Vec2::UP;
|
||||||
|
dir.Rotate(a8::RandAngle());
|
||||||
|
a8::Vec2 box_pos = gas_data_.pos_new + dir * (500 + rand() % 300);
|
||||||
|
if (box_pos.x < 1.0f) {
|
||||||
|
box_pos.x = 1.0f;
|
||||||
|
}
|
||||||
|
if (box_pos.x >= map_meta_->map_width()) {
|
||||||
|
box_pos.x = map_meta_->map_width() - 1;
|
||||||
|
}
|
||||||
|
if (box_pos.y < 1.0f) {
|
||||||
|
box_pos.y = 1.0f;
|
||||||
|
}
|
||||||
|
if (box_pos.y >= map_meta_->map_height()) {
|
||||||
|
box_pos.y = map_meta_->map_height() - 1;
|
||||||
|
}
|
||||||
|
Position final_box_pos;
|
||||||
|
final_box_pos.x = box_pos.x;
|
||||||
|
final_box_pos.y = box_pos.y;
|
||||||
|
AdjustAirDropPos(thing_meta, final_box_pos);
|
||||||
|
AabbCollider air_drop_aabb_box;
|
||||||
|
{
|
||||||
|
air_drop_aabb_box._min.x = 0 - thing_meta->width()/2.0f;
|
||||||
|
air_drop_aabb_box._min.y = 0 - thing_meta->height()/2.0f;
|
||||||
|
air_drop_aabb_box._max.x = 0 + thing_meta->width()/2.0f;
|
||||||
|
air_drop_aabb_box._max.y = 0 + thing_meta->height()/2.0f;
|
||||||
|
}
|
||||||
|
ColliderComponent* pickup_collider = nullptr;
|
||||||
|
{
|
||||||
|
bool through_wall = false;
|
||||||
|
bool is_collision = map_service->CollisionDetectionAndGetCollider
|
||||||
|
(
|
||||||
|
this,
|
||||||
|
through_wall,
|
||||||
|
final_box_pos,
|
||||||
|
&air_drop_aabb_box,
|
||||||
|
&pickup_collider
|
||||||
|
);
|
||||||
|
if (is_collision) {
|
||||||
|
if (!pickup_collider) {
|
||||||
|
A8_ABORT();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (pickup_collider) {
|
||||||
|
float new_x = box_pos.x;
|
||||||
|
float new_y = box_pos.y;
|
||||||
|
// 888
|
||||||
|
#if 0
|
||||||
|
FindLocationWithAabb(pickup_collider, box_pos, &air_drop_aabb_box, new_x, new_y);
|
||||||
|
#endif
|
||||||
|
box_pos.x = new_x;
|
||||||
|
box_pos.y = new_y;
|
||||||
|
}
|
||||||
|
if (box_pos.x + thing_meta->width()/2 + 2 > map_meta_->map_width() ||
|
||||||
|
box_pos.x - thing_meta->width()/2 - 2 < 1 ||
|
||||||
|
box_pos.y + thing_meta->height()/2 + 2 > map_meta_->map_height() ||
|
||||||
|
box_pos.y - thing_meta->height()/2 - 2 < 1
|
||||||
|
) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
frame_event.AddAirDrop(appear_time, box_id, final_box_pos);
|
||||||
|
xtimer.SetTimeoutEx
|
||||||
|
(SERVER_FRAME_RATE * appear_time / 1000.f,
|
||||||
|
[this, box_pos, airdrop_id, box_id]
|
||||||
|
(int event, const a8::Args* args)
|
||||||
|
{
|
||||||
|
if (a8::TIMER_EXEC_EVENT == event) {
|
||||||
|
if (!IsGameOver()) {
|
||||||
|
RoomObstacle* obstacle = CreateObstacle
|
||||||
|
(
|
||||||
|
box_id,
|
||||||
|
box_pos.x,
|
||||||
|
box_pos.y
|
||||||
|
);
|
||||||
|
obstacle->PushCollisionObjects();
|
||||||
|
obstacle->is_treasure_box = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
&xtimer_attacher_);
|
||||||
|
++airdrop_times_;
|
||||||
|
#if 1
|
||||||
|
ShuaMon(box_pos,
|
||||||
|
thing_meta->airdrop_mon_list,
|
||||||
|
std::max(thing_meta->width(), thing_meta->height()));
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
#if 0
|
||||||
|
void Room::AdjustAirDropPos(const mt::MapThing* thing_meta, glm::vec3& box_pos)
|
||||||
|
{
|
||||||
|
AdjustPosInnerMap(box_pos, 100);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Room::ShuaMon(const glm::vec3& center, std::vector<int>& airdrop_mon_list, float radius)
|
||||||
|
{
|
||||||
|
int last_hero_idx = 0;
|
||||||
|
for (int hero_id : airdrop_mon_list) {
|
||||||
|
const mt::Hero* hero_meta = mt::Hero::GetById(hero_id);
|
||||||
|
if (hero_meta) {
|
||||||
|
int team_id = 666;
|
||||||
|
Creature* master = nullptr;
|
||||||
|
for (int i = 0; i < 10; ++i) {
|
||||||
|
glm::vec3 born_dir = center;
|
||||||
|
glm::vec3 born_offset(hero_meta->radius() + 1 + radius + (50 * i),
|
||||||
|
0.0f,
|
||||||
|
hero_meta->radius() + 1 + radius + (50 * i));
|
||||||
|
GlmHelper::RotateY(born_offset, GlmHelper::CalcAngle(born_dir, GlmHelper::UP));
|
||||||
|
GlmHelper::RotateY(born_offset, (last_hero_idx + i) * 0.5);
|
||||||
|
|
||||||
|
glm::vec3 hero_pos = center + born_offset;
|
||||||
|
glm::vec3 dir = born_offset;
|
||||||
|
GlmHelper::Normalize(dir);
|
||||||
|
|
||||||
|
Position pos;
|
||||||
|
pos.SetX(hero_pos.x);
|
||||||
|
pos.SetY(hero_pos.y);
|
||||||
|
|
||||||
|
// 888
|
||||||
|
#if 0
|
||||||
|
CircleCollider collider;
|
||||||
|
collider.pos = hero_pos;
|
||||||
|
collider.rad = hero_meta->radius();
|
||||||
|
if (!map_service->CollisionDetection
|
||||||
|
(
|
||||||
|
this,
|
||||||
|
false,
|
||||||
|
pos,
|
||||||
|
&collider
|
||||||
|
)) {
|
||||||
|
Hero* hero = CreateHero(master,
|
||||||
|
hero_meta,
|
||||||
|
pos,
|
||||||
|
dir,
|
||||||
|
team_id);
|
||||||
|
if (!hero) {
|
||||||
|
A8_ABORT();
|
||||||
|
}
|
||||||
|
last_hero_idx = i;
|
||||||
|
#ifdef DEBUG
|
||||||
|
BroadcastDebugMsg(a8::Format("ShuaMon pos:%d,%d hero_id:%d",
|
||||||
|
{
|
||||||
|
hero_pos.x,
|
||||||
|
hero_pos.y,
|
||||||
|
hero->meta->id()
|
||||||
|
}));
|
||||||
|
#endif
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
}//end for i
|
||||||
|
}//end if
|
||||||
|
}//end for hero_id
|
||||||
|
}
|
||||||
|
|
||||||
|
void Room::AdjustPosInnerMap(glm::vec3& pos, float radius)
|
||||||
|
{
|
||||||
|
//检查x轴
|
||||||
|
{
|
||||||
|
int left_x = pos.x - radius;
|
||||||
|
if (left_x < 0.001f) {
|
||||||
|
pos.x = radius + 10;
|
||||||
|
}
|
||||||
|
int right_x = pos.x + radius;
|
||||||
|
if (right_x > map_meta_->map_width()) {
|
||||||
|
pos.x = map_meta_->map_width() - radius - 10;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//检查y轴
|
||||||
|
{
|
||||||
|
int up_y = pos.y + radius;
|
||||||
|
if (up_y > map_meta_->map_height()) {
|
||||||
|
pos.y = map_meta_->map_height() - radius - 10;
|
||||||
|
}
|
||||||
|
int down_y = pos.y - radius;
|
||||||
|
if (down_y < 0.001f) {
|
||||||
|
pos.y = radius + 10;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (OverBorder(pos, radius)) {
|
||||||
|
// 999
|
||||||
|
pos.x = 800;
|
||||||
|
pos.y = 1800;
|
||||||
|
#ifdef DEBUG
|
||||||
|
A8_ABORT();
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
@ -0,0 +1,17 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
class Room;
|
||||||
|
class AirDrop
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
|
||||||
|
AirDrop(Room* room);
|
||||||
|
|
||||||
|
void Init();
|
||||||
|
|
||||||
|
private:
|
||||||
|
void Exec(int appear_time, int box_id, int airdrop_id);
|
||||||
|
|
||||||
|
private:
|
||||||
|
Room* room_ = nullptr;
|
||||||
|
};
|
@ -0,0 +1,128 @@
|
|||||||
|
#include "precompile.h"
|
||||||
|
|
||||||
|
#include "airraid.h"
|
||||||
|
#include "room.h"
|
||||||
|
#include "player.h"
|
||||||
|
#include "obstacle.h"
|
||||||
|
#include "roomobstacle.h"
|
||||||
|
|
||||||
|
#include "mt/AirRaid.h"
|
||||||
|
#include "mt/SafeArea.h"
|
||||||
|
|
||||||
|
AirRaid::AirRaid(Room* room)
|
||||||
|
{
|
||||||
|
room_ = room;
|
||||||
|
}
|
||||||
|
|
||||||
|
void AirRaid::Init()
|
||||||
|
{
|
||||||
|
mt::AirRaid::Traverse
|
||||||
|
(
|
||||||
|
[this] (const mt::AirRaid* air_raid, bool& stop)
|
||||||
|
{
|
||||||
|
room_->xtimer.SetTimeoutEx
|
||||||
|
(SERVER_FRAME_RATE * air_raid->time(),
|
||||||
|
[this, air_raid] (int event, const a8::Args* args)
|
||||||
|
{
|
||||||
|
if (a8::TIMER_EXEC_EVENT == event) {
|
||||||
|
if (!room_->IsGameOver()) {
|
||||||
|
Exec(air_raid->id());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
&room_->xtimer_attacher_);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
void AirRaid::Exec(int airraid_id)
|
||||||
|
{
|
||||||
|
const mt::AirRaid* raid_meta = mt::AirRaid::GetById(airraid_id);
|
||||||
|
if (!raid_meta) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
glm::vec3 dir = GlmHelper::UP;
|
||||||
|
GlmHelper::RotateY(dir, a8::RandAngle());
|
||||||
|
float rnd_rad = room_->GetGasData().new_area_meta->rad() > 0 ? rand() % room_->GetGasData().new_area_meta->rad() : 0;
|
||||||
|
glm::vec2 v2_center= room_->GetGasData().pos_new + glm::vec2(dir.x, dir.z) * (100.f + rnd_rad);
|
||||||
|
glm::vec3 center = glm::vec3(v2_center.x, 0.0f, v2_center.y);
|
||||||
|
{
|
||||||
|
std::vector<Player*> humans;
|
||||||
|
#if 0
|
||||||
|
room_->GetAlivePlayers(humans, room_->GetRoomMaxPlayerNum());
|
||||||
|
#endif
|
||||||
|
if (humans.size() > 3) {
|
||||||
|
std::random_shuffle(humans.begin(), humans.end());
|
||||||
|
for (Human* hum : humans) {
|
||||||
|
if (!hum->poisoning) {
|
||||||
|
// 99
|
||||||
|
#if 1
|
||||||
|
#else
|
||||||
|
center = hum->GetPos() + dir * (200 + rand() % 500);
|
||||||
|
#endif
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#ifdef DEBUG1
|
||||||
|
if (humans.size() > 0) {
|
||||||
|
center = humans[0]->GetPos();
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
room_->frame_event.AddAirRaid(raid_meta->appear_time(), center, raid_meta->rad());
|
||||||
|
|
||||||
|
auto raid_cb =
|
||||||
|
[this, raid_meta, center]
|
||||||
|
(int event, const a8::Args* args)
|
||||||
|
{
|
||||||
|
if (a8::TIMER_EXEC_EVENT != event) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (room_->IsGameOver()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
for (auto& tuple : raid_meta->_raid_waves) {
|
||||||
|
int num = std::get<0>(tuple);
|
||||||
|
int delay = std::get<1>(tuple);
|
||||||
|
glm::vec3 born_pos = center;
|
||||||
|
|
||||||
|
auto bomb_cb =
|
||||||
|
[this, raid_meta, num, delay, born_pos]
|
||||||
|
(int event, const a8::Args* args)
|
||||||
|
{
|
||||||
|
if (a8::TIMER_EXEC_EVENT == event) {
|
||||||
|
if (room_->IsGameOver()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
glm::vec3 dir = GlmHelper::UP;
|
||||||
|
GlmHelper::RotateY(dir, a8::RandAngle());
|
||||||
|
glm::vec3 pos = born_pos + dir * (50.0f + rand() % 100);
|
||||||
|
if (room_->grid_service->CanAdd(pos.x, pos.y)) {
|
||||||
|
for (auto bomb_id : raid_meta->_bomb_ids) {
|
||||||
|
RoomObstacle* obstacle = room_->CreateObstacle
|
||||||
|
(
|
||||||
|
bomb_id,
|
||||||
|
pos.x,
|
||||||
|
pos.y,
|
||||||
|
pos.z
|
||||||
|
);
|
||||||
|
obstacle->Active();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
for (int i = 0; i < num; ++i) {
|
||||||
|
room_->xtimer.SetTimeoutEx
|
||||||
|
(delay / FRAME_RATE_MS,
|
||||||
|
bomb_cb,
|
||||||
|
&room_->xtimer_attacher_);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
room_->xtimer.SetTimeoutEx
|
||||||
|
(SERVER_FRAME_RATE * raid_meta->appear_time() / 1000.f,
|
||||||
|
raid_cb,
|
||||||
|
&room_->xtimer_attacher_);
|
||||||
|
}
|
@ -0,0 +1,18 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
class Room;
|
||||||
|
class AirRaid
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
|
||||||
|
AirRaid(Room* room);
|
||||||
|
|
||||||
|
void Init();
|
||||||
|
|
||||||
|
private:
|
||||||
|
|
||||||
|
void Exec(int airraid_id);
|
||||||
|
|
||||||
|
private:
|
||||||
|
Room* room_ = nullptr;
|
||||||
|
};
|
@ -37,6 +37,8 @@
|
|||||||
#include "pbutils.h"
|
#include "pbutils.h"
|
||||||
#include "movement.h"
|
#include "movement.h"
|
||||||
#include "bornpoint.h"
|
#include "bornpoint.h"
|
||||||
|
#include "airdrop.h"
|
||||||
|
#include "airraid.h"
|
||||||
|
|
||||||
#include "mt/Param.h"
|
#include "mt/Param.h"
|
||||||
#include "mt/Hero.h"
|
#include "mt/Hero.h"
|
||||||
@ -56,9 +58,7 @@
|
|||||||
#include "mt/KillReward.h"
|
#include "mt/KillReward.h"
|
||||||
#include "mt/KillPoint.h"
|
#include "mt/KillPoint.h"
|
||||||
#include "mt/Drop.h"
|
#include "mt/Drop.h"
|
||||||
#include "mt/AirRaid.h"
|
|
||||||
#include "mt/AirLine.h"
|
#include "mt/AirLine.h"
|
||||||
#include "mt/AirDrop.h"
|
|
||||||
#include "mt/Robot.h"
|
#include "mt/Robot.h"
|
||||||
#include "mt/SafeAreaPos.h"
|
#include "mt/SafeAreaPos.h"
|
||||||
|
|
||||||
@ -104,6 +104,9 @@ void Room::Init()
|
|||||||
frame_event.room = this;
|
frame_event.room = this;
|
||||||
frame_event_data = new FrameEventData();
|
frame_event_data = new FrameEventData();
|
||||||
|
|
||||||
|
air_drop_ = std::make_shared<AirDrop>(this);
|
||||||
|
air_raid_ = std::make_shared<AirRaid>(this);
|
||||||
|
|
||||||
CreateSpawnPoints();
|
CreateSpawnPoints();
|
||||||
CreateWorldObjects();
|
CreateWorldObjects();
|
||||||
ShuaAndroid();
|
ShuaAndroid();
|
||||||
@ -828,40 +831,6 @@ bool Room::OverBorder(const glm::vec3& pos, float radius)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Room::AdjustPosInnerMap(glm::vec3& pos, float radius)
|
|
||||||
{
|
|
||||||
//检查x轴
|
|
||||||
{
|
|
||||||
int left_x = pos.x - radius;
|
|
||||||
if (left_x < 0.001f) {
|
|
||||||
pos.x = radius + 10;
|
|
||||||
}
|
|
||||||
int right_x = pos.x + radius;
|
|
||||||
if (right_x > map_meta_->map_width()) {
|
|
||||||
pos.x = map_meta_->map_width() - radius - 10;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
//检查y轴
|
|
||||||
{
|
|
||||||
int up_y = pos.y + radius;
|
|
||||||
if (up_y > map_meta_->map_height()) {
|
|
||||||
pos.y = map_meta_->map_height() - radius - 10;
|
|
||||||
}
|
|
||||||
int down_y = pos.y - radius;
|
|
||||||
if (down_y < 0.001f) {
|
|
||||||
pos.y = radius + 10;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (OverBorder(pos, radius)) {
|
|
||||||
// 999
|
|
||||||
pos.x = 800;
|
|
||||||
pos.y = 1800;
|
|
||||||
#ifdef DEBUG
|
|
||||||
A8_ABORT();
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Human* Room::GetWatchWarTarget(Human* hum)
|
Human* Room::GetWatchWarTarget(Human* hum)
|
||||||
{
|
{
|
||||||
if (!mt::Param::s().watchable) {
|
if (!mt::Param::s().watchable) {
|
||||||
@ -1430,12 +1399,10 @@ void Room::UpdateGasJump()
|
|||||||
if (!auto_jump_timer_.expired()) {
|
if (!auto_jump_timer_.expired()) {
|
||||||
xtimer.Delete(auto_jump_timer_);
|
xtimer.Delete(auto_jump_timer_);
|
||||||
}
|
}
|
||||||
|
air_drop_->Init();
|
||||||
|
air_raid_->Init();
|
||||||
NotifyGameStart();
|
NotifyGameStart();
|
||||||
NotifyUiUpdate();
|
NotifyUiUpdate();
|
||||||
if (room_type_ != RT_NewBrid) {
|
|
||||||
InitAirDrop();
|
|
||||||
InitAirRaid();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1709,142 +1676,6 @@ void Room::FillTeam()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Room::InitAirDrop()
|
|
||||||
{
|
|
||||||
mt::AirDrop::Traverse
|
|
||||||
(
|
|
||||||
[this] (const mt::AirDrop* air_drop_meta, bool& stop)
|
|
||||||
{
|
|
||||||
if (air_drop_meta->id() >= 1 && air_drop_meta->id() <= 6) {
|
|
||||||
xtimer.SetTimeoutEx
|
|
||||||
(SERVER_FRAME_RATE * air_drop_meta->time(),
|
|
||||||
[this, air_drop_meta] (int event, const a8::Args* args) mutable
|
|
||||||
{
|
|
||||||
if (a8::TIMER_EXEC_EVENT == event) {
|
|
||||||
if (!IsGameOver()) {
|
|
||||||
AirDrop(
|
|
||||||
air_drop_meta->appear_time(),
|
|
||||||
air_drop_meta->RandDrop(),
|
|
||||||
air_drop_meta->id());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
&xtimer_attacher_);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
void Room::AirDrop(int appear_time, int box_id, int airdrop_id)
|
|
||||||
{
|
|
||||||
#ifdef DEBUG
|
|
||||||
if (!f8::IsTestEnv()) {
|
|
||||||
a8::XPrintf("AirDrop appear_time:%d box_id:%d airdrop_id:%d\n",
|
|
||||||
{
|
|
||||||
appear_time,
|
|
||||||
box_id,
|
|
||||||
airdrop_id
|
|
||||||
});
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
// 888
|
|
||||||
#if 0
|
|
||||||
const mt::MapThing* thing_meta = MetaMgr::Instance()->GetMapThing(box_id);
|
|
||||||
if (thing_meta && thing_meta->type() == 2) {
|
|
||||||
a8::Vec2 dir = a8::Vec2::UP;
|
|
||||||
dir.Rotate(a8::RandAngle());
|
|
||||||
a8::Vec2 box_pos = gas_data_.pos_new + dir * (500 + rand() % 300);
|
|
||||||
if (box_pos.x < 1.0f) {
|
|
||||||
box_pos.x = 1.0f;
|
|
||||||
}
|
|
||||||
if (box_pos.x >= map_meta_->map_width()) {
|
|
||||||
box_pos.x = map_meta_->map_width() - 1;
|
|
||||||
}
|
|
||||||
if (box_pos.y < 1.0f) {
|
|
||||||
box_pos.y = 1.0f;
|
|
||||||
}
|
|
||||||
if (box_pos.y >= map_meta_->map_height()) {
|
|
||||||
box_pos.y = map_meta_->map_height() - 1;
|
|
||||||
}
|
|
||||||
Position final_box_pos;
|
|
||||||
final_box_pos.x = box_pos.x;
|
|
||||||
final_box_pos.y = box_pos.y;
|
|
||||||
AdjustAirDropPos(thing_meta, final_box_pos);
|
|
||||||
AabbCollider air_drop_aabb_box;
|
|
||||||
{
|
|
||||||
air_drop_aabb_box._min.x = 0 - thing_meta->width()/2.0f;
|
|
||||||
air_drop_aabb_box._min.y = 0 - thing_meta->height()/2.0f;
|
|
||||||
air_drop_aabb_box._max.x = 0 + thing_meta->width()/2.0f;
|
|
||||||
air_drop_aabb_box._max.y = 0 + thing_meta->height()/2.0f;
|
|
||||||
}
|
|
||||||
ColliderComponent* pickup_collider = nullptr;
|
|
||||||
{
|
|
||||||
bool through_wall = false;
|
|
||||||
bool is_collision = map_service->CollisionDetectionAndGetCollider
|
|
||||||
(
|
|
||||||
this,
|
|
||||||
through_wall,
|
|
||||||
final_box_pos,
|
|
||||||
&air_drop_aabb_box,
|
|
||||||
&pickup_collider
|
|
||||||
);
|
|
||||||
if (is_collision) {
|
|
||||||
if (!pickup_collider) {
|
|
||||||
A8_ABORT();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (pickup_collider) {
|
|
||||||
float new_x = box_pos.x;
|
|
||||||
float new_y = box_pos.y;
|
|
||||||
// 888
|
|
||||||
#if 0
|
|
||||||
FindLocationWithAabb(pickup_collider, box_pos, &air_drop_aabb_box, new_x, new_y);
|
|
||||||
#endif
|
|
||||||
box_pos.x = new_x;
|
|
||||||
box_pos.y = new_y;
|
|
||||||
}
|
|
||||||
if (box_pos.x + thing_meta->width()/2 + 2 > map_meta_->map_width() ||
|
|
||||||
box_pos.x - thing_meta->width()/2 - 2 < 1 ||
|
|
||||||
box_pos.y + thing_meta->height()/2 + 2 > map_meta_->map_height() ||
|
|
||||||
box_pos.y - thing_meta->height()/2 - 2 < 1
|
|
||||||
) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
frame_event.AddAirDrop(appear_time, box_id, final_box_pos);
|
|
||||||
xtimer.SetTimeoutEx
|
|
||||||
(SERVER_FRAME_RATE * appear_time / 1000.f,
|
|
||||||
[this, box_pos, airdrop_id, box_id]
|
|
||||||
(int event, const a8::Args* args)
|
|
||||||
{
|
|
||||||
if (a8::TIMER_EXEC_EVENT == event) {
|
|
||||||
if (!IsGameOver()) {
|
|
||||||
RoomObstacle* obstacle = CreateObstacle
|
|
||||||
(
|
|
||||||
box_id,
|
|
||||||
box_pos.x,
|
|
||||||
box_pos.y
|
|
||||||
);
|
|
||||||
obstacle->PushCollisionObjects();
|
|
||||||
obstacle->is_treasure_box = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
&xtimer_attacher_);
|
|
||||||
++airdrop_times_;
|
|
||||||
#if 1
|
|
||||||
ShuaMon(box_pos,
|
|
||||||
thing_meta->airdrop_mon_list,
|
|
||||||
std::max(thing_meta->width(), thing_meta->height()));
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
void Room::AdjustAirDropPos(const mt::MapThing* thing_meta, glm::vec3& box_pos)
|
|
||||||
{
|
|
||||||
AdjustPosInnerMap(box_pos, 100);
|
|
||||||
}
|
|
||||||
|
|
||||||
void Room::ShuaPlane()
|
void Room::ShuaPlane()
|
||||||
{
|
{
|
||||||
airline_ = mt::AirLine::RandAirLine(map_meta_->map_id());
|
airline_ = mt::AirLine::RandAirLine(map_meta_->map_id());
|
||||||
@ -3332,67 +3163,6 @@ void Room::ForwardGasRing(int n)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Room::ShuaMon(const glm::vec3& center, std::vector<int>& airdrop_mon_list, float radius)
|
|
||||||
{
|
|
||||||
int last_hero_idx = 0;
|
|
||||||
for (int hero_id : airdrop_mon_list) {
|
|
||||||
const mt::Hero* hero_meta = mt::Hero::GetById(hero_id);
|
|
||||||
if (hero_meta) {
|
|
||||||
int team_id = 666;
|
|
||||||
Creature* master = nullptr;
|
|
||||||
for (int i = 0; i < 10; ++i) {
|
|
||||||
glm::vec3 born_dir = center;
|
|
||||||
glm::vec3 born_offset(hero_meta->radius() + 1 + radius + (50 * i),
|
|
||||||
0.0f,
|
|
||||||
hero_meta->radius() + 1 + radius + (50 * i));
|
|
||||||
GlmHelper::RotateY(born_offset, GlmHelper::CalcAngle(born_dir, GlmHelper::UP));
|
|
||||||
GlmHelper::RotateY(born_offset, (last_hero_idx + i) * 0.5);
|
|
||||||
|
|
||||||
glm::vec3 hero_pos = center + born_offset;
|
|
||||||
glm::vec3 dir = born_offset;
|
|
||||||
GlmHelper::Normalize(dir);
|
|
||||||
|
|
||||||
Position pos;
|
|
||||||
pos.SetX(hero_pos.x);
|
|
||||||
pos.SetY(hero_pos.y);
|
|
||||||
|
|
||||||
// 888
|
|
||||||
#if 0
|
|
||||||
CircleCollider collider;
|
|
||||||
collider.pos = hero_pos;
|
|
||||||
collider.rad = hero_meta->radius();
|
|
||||||
if (!map_service->CollisionDetection
|
|
||||||
(
|
|
||||||
this,
|
|
||||||
false,
|
|
||||||
pos,
|
|
||||||
&collider
|
|
||||||
)) {
|
|
||||||
Hero* hero = CreateHero(master,
|
|
||||||
hero_meta,
|
|
||||||
pos,
|
|
||||||
dir,
|
|
||||||
team_id);
|
|
||||||
if (!hero) {
|
|
||||||
A8_ABORT();
|
|
||||||
}
|
|
||||||
last_hero_idx = i;
|
|
||||||
#ifdef DEBUG
|
|
||||||
BroadcastDebugMsg(a8::Format("ShuaMon pos:%d,%d hero_id:%d",
|
|
||||||
{
|
|
||||||
hero_pos.x,
|
|
||||||
hero_pos.y,
|
|
||||||
hero->meta->id()
|
|
||||||
}));
|
|
||||||
#endif
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
}//end for i
|
|
||||||
}//end if
|
|
||||||
}//end for hero_id
|
|
||||||
}
|
|
||||||
|
|
||||||
void Room::GetPartObjectWatchList(Entity* entity, std::vector<Human*>& watch_list)
|
void Room::GetPartObjectWatchList(Entity* entity, std::vector<Human*>& watch_list)
|
||||||
{
|
{
|
||||||
TraverseHumanList
|
TraverseHumanList
|
||||||
@ -3414,117 +3184,6 @@ void Room::SetInfiniteBulletMode()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Room::InitAirRaid()
|
|
||||||
{
|
|
||||||
mt::AirRaid::Traverse
|
|
||||||
(
|
|
||||||
[this] (const mt::AirRaid* air_raid, bool& stop)
|
|
||||||
{
|
|
||||||
xtimer.SetTimeoutEx
|
|
||||||
(SERVER_FRAME_RATE * air_raid->time(),
|
|
||||||
[this, air_raid] (int event, const a8::Args* args)
|
|
||||||
{
|
|
||||||
if (a8::TIMER_EXEC_EVENT == event) {
|
|
||||||
if (!IsGameOver()) {
|
|
||||||
AirRaid(air_raid->id());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
&xtimer_attacher_);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
void Room::AirRaid(int airraid_id)
|
|
||||||
{
|
|
||||||
const mt::AirRaid* raid_meta = mt::AirRaid::GetById(airraid_id);
|
|
||||||
if (!raid_meta) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
glm::vec3 dir = GlmHelper::UP;
|
|
||||||
GlmHelper::RotateY(dir, a8::RandAngle());
|
|
||||||
float rnd_rad = gas_data_.new_area_meta->rad() > 0 ? rand() % gas_data_.new_area_meta->rad() : 0;
|
|
||||||
glm::vec2 v2_center= gas_data_.pos_new + glm::vec2(dir.x, dir.z) * (100.f + rnd_rad);
|
|
||||||
glm::vec3 center = glm::vec3(v2_center.x, 0.0f, v2_center.y);
|
|
||||||
{
|
|
||||||
std::vector<Player*> humans;
|
|
||||||
GetAlivePlayers(humans, GetRoomMaxPlayerNum());
|
|
||||||
if (humans.size() > 3) {
|
|
||||||
std::random_shuffle(humans.begin(), humans.end());
|
|
||||||
for (Human* hum : humans) {
|
|
||||||
if (!hum->poisoning) {
|
|
||||||
// 99
|
|
||||||
#if 1
|
|
||||||
#else
|
|
||||||
center = hum->GetPos() + dir * (200 + rand() % 500);
|
|
||||||
#endif
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#ifdef DEBUG1
|
|
||||||
if (humans.size() > 0) {
|
|
||||||
center = humans[0]->GetPos();
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
frame_event.AddAirRaid(raid_meta->appear_time(), center, raid_meta->rad());
|
|
||||||
|
|
||||||
auto raid_cb =
|
|
||||||
[this, raid_meta, center]
|
|
||||||
(int event, const a8::Args* args)
|
|
||||||
{
|
|
||||||
if (a8::TIMER_EXEC_EVENT != event) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (IsGameOver()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
for (auto& tuple : raid_meta->_raid_waves) {
|
|
||||||
int num = std::get<0>(tuple);
|
|
||||||
int delay = std::get<1>(tuple);
|
|
||||||
glm::vec3 born_pos = center;
|
|
||||||
|
|
||||||
auto bomb_cb =
|
|
||||||
[this, raid_meta, num, delay, born_pos]
|
|
||||||
(int event, const a8::Args* args)
|
|
||||||
{
|
|
||||||
if (a8::TIMER_EXEC_EVENT == event) {
|
|
||||||
if (IsGameOver()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
glm::vec3 dir = GlmHelper::UP;
|
|
||||||
GlmHelper::RotateY(dir, a8::RandAngle());
|
|
||||||
glm::vec3 pos = born_pos + dir * (50.0f + rand() % 100);
|
|
||||||
if (grid_service->CanAdd(pos.x, pos.y)) {
|
|
||||||
for (auto bomb_id : raid_meta->_bomb_ids) {
|
|
||||||
RoomObstacle* obstacle = CreateObstacle
|
|
||||||
(
|
|
||||||
bomb_id,
|
|
||||||
pos.x,
|
|
||||||
pos.y,
|
|
||||||
pos.z
|
|
||||||
);
|
|
||||||
obstacle->Active();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
for (int i = 0; i < num; ++i) {
|
|
||||||
xtimer.SetTimeoutEx
|
|
||||||
(delay / FRAME_RATE_MS,
|
|
||||||
bomb_cb,
|
|
||||||
&xtimer_attacher_);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
xtimer.SetTimeoutEx
|
|
||||||
(SERVER_FRAME_RATE * raid_meta->appear_time() / 1000.f,
|
|
||||||
raid_cb,
|
|
||||||
&xtimer_attacher_);
|
|
||||||
}
|
|
||||||
|
|
||||||
void Room::AddToPostBattleAutoFreeList(a8::XTimerWp timer)
|
void Room::AddToPostBattleAutoFreeList(a8::XTimerWp timer)
|
||||||
{
|
{
|
||||||
if (BattleStarted()) {
|
if (BattleStarted()) {
|
||||||
|
@ -28,6 +28,8 @@ class Car;
|
|||||||
class Hero;
|
class Hero;
|
||||||
class Incubator;
|
class Incubator;
|
||||||
class Team;
|
class Team;
|
||||||
|
class AirDrop;
|
||||||
|
class AirRaid;
|
||||||
struct BornPoint;
|
struct BornPoint;
|
||||||
class MapInstance;
|
class MapInstance;
|
||||||
struct RoomInitInfo;
|
struct RoomInitInfo;
|
||||||
@ -186,8 +188,6 @@ public:
|
|||||||
int CreateAndTakeonCar(int car_id, glm::vec3 pos);
|
int CreateAndTakeonCar(int car_id, glm::vec3 pos);
|
||||||
bool HaveMyTeam(const std::string& team_uuid);
|
bool HaveMyTeam(const std::string& team_uuid);
|
||||||
long long GetGasInactiveTime();
|
long long GetGasInactiveTime();
|
||||||
void InitAirDrop();
|
|
||||||
void InitAirRaid();
|
|
||||||
void CheckPartObjects(Human* testa = nullptr, Human* testb = nullptr);
|
void CheckPartObjects(Human* testa = nullptr, Human* testb = nullptr);
|
||||||
bool RuningInTimer();
|
bool RuningInTimer();
|
||||||
Human* GetOneCanEnableAndroid();
|
Human* GetOneCanEnableAndroid();
|
||||||
@ -206,7 +206,6 @@ public:
|
|||||||
std::shared_ptr<a8::Args> init_args = nullptr);
|
std::shared_ptr<a8::Args> init_args = nullptr);
|
||||||
int AllocUniid();
|
int AllocUniid();
|
||||||
Incubator* GetIncubator() { return incubator_;};
|
Incubator* GetIncubator() { return incubator_;};
|
||||||
void ShuaMon(const glm::vec3& center, std::vector<int>& airdrop_mon_list, float radius);
|
|
||||||
void GetPartObjectWatchList(Entity* entity, std::vector<Human*>& watch_list);
|
void GetPartObjectWatchList(Entity* entity, std::vector<Human*>& watch_list);
|
||||||
void SetInfiniteBulletMode();
|
void SetInfiniteBulletMode();
|
||||||
bool IsInfiniteBulletMode() { return infinite_bullet_mode_; };
|
bool IsInfiniteBulletMode() { return infinite_bullet_mode_; };
|
||||||
@ -232,9 +231,6 @@ private:
|
|||||||
void MatchTeam(Human* hum);
|
void MatchTeam(Human* hum);
|
||||||
void CombineTeam();
|
void CombineTeam();
|
||||||
void FillTeam();
|
void FillTeam();
|
||||||
void AirDrop(int appear_time, int box_id, int airdrop_id);
|
|
||||||
void AdjustAirDropPos(const mt::MapThing* thing_meta, glm::vec3& box_pos);
|
|
||||||
void AirRaid(int airraid_id);
|
|
||||||
void ShuaPlane();
|
void ShuaPlane();
|
||||||
Team* NewTeam();
|
Team* NewTeam();
|
||||||
RoomObstacle* InternalCreateObstacle(int id, float x, float y, float z,
|
RoomObstacle* InternalCreateObstacle(int id, float x, float y, float z,
|
||||||
@ -325,8 +321,6 @@ private:
|
|||||||
long long alive_count_chged_frameno_ = 0;
|
long long alive_count_chged_frameno_ = 0;
|
||||||
int human_alive_count_ = 0;
|
int human_alive_count_ = 0;
|
||||||
const mt::AirLine* airline_ = nullptr;
|
const mt::AirLine* airline_ = nullptr;
|
||||||
size_t airdrop_times_ = 0;
|
|
||||||
size_t airraid_times_ = 0;
|
|
||||||
int level0room_born_point_uniid_ = 0;
|
int level0room_born_point_uniid_ = 0;
|
||||||
int level1room_born_point_uniid_ = 0;
|
int level1room_born_point_uniid_ = 0;
|
||||||
bool show_handed_ = false;
|
bool show_handed_ = false;
|
||||||
@ -367,6 +361,9 @@ private:
|
|||||||
|
|
||||||
bool battle_starting_ = false;
|
bool battle_starting_ = false;
|
||||||
|
|
||||||
|
std::shared_ptr<AirDrop> air_drop_;
|
||||||
|
std::shared_ptr<AirRaid> air_raid_;
|
||||||
|
|
||||||
friend class Incubator;
|
friend class Incubator;
|
||||||
friend class Team;
|
friend class Team;
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user