1
This commit is contained in:
parent
35aed66b55
commit
b8362a8754
@ -134,8 +134,6 @@ void Bullet::ProcBomb()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}//end for
|
}//end for
|
||||||
|
|
||||||
room->RemoveObjectLater(this);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Bullet::IsBomb()
|
bool Bullet::IsBomb()
|
||||||
@ -150,9 +148,9 @@ void Bullet::MapServiceUpdate()
|
|||||||
if (room->OverBorder(pos, meta->i->bullet_rad())) {
|
if (room->OverBorder(pos, meta->i->bullet_rad())) {
|
||||||
if (IsBomb()) {
|
if (IsBomb()) {
|
||||||
ProcBomb();
|
ProcBomb();
|
||||||
} else {
|
|
||||||
room->RemoveObjectLater(this);
|
|
||||||
}
|
}
|
||||||
|
PostAttack();
|
||||||
|
room->RemoveObjectLater(this);
|
||||||
} else {
|
} else {
|
||||||
room->grid_service.MoveBullet(this);
|
room->grid_service.MoveBullet(this);
|
||||||
std::set<Entity*> objects;
|
std::set<Entity*> objects;
|
||||||
@ -186,8 +184,54 @@ void Bullet::MapServiceUpdate()
|
|||||||
if (!objects.empty()) {
|
if (!objects.empty()) {
|
||||||
OnHit(objects);
|
OnHit(objects);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
PostAttack();
|
||||||
room->RemoveObjectLater(this);
|
room->RemoveObjectLater(this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Bullet::PostAttack()
|
||||||
|
{
|
||||||
|
auto fire_func =
|
||||||
|
[] (const a8::XParams& param)
|
||||||
|
{
|
||||||
|
Obstacle* obstacle = (Obstacle*)param.sender.GetUserData();
|
||||||
|
Human* sender = (Human*)param.param1.GetUserData();
|
||||||
|
if (obstacle->room->IsGameOver()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
std::set<GridCell*> grid_list;
|
||||||
|
obstacle->room->grid_service.GetAllCellsByXy(obstacle->pos.x, obstacle->pos.y, grid_list);
|
||||||
|
for (auto& grid : grid_list) {
|
||||||
|
for (Human* hum: grid->human_list) {
|
||||||
|
if (hum->pos.Distance(obstacle->pos) < obstacle->meta->i->damage_dia()) {
|
||||||
|
hum->DecHP(obstacle->meta->i->damage(), sender->entity_uniid, sender->name, 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
if (meta->i->equip_subtype() == BulletType_FireBomb) {
|
||||||
|
//燃烧弹火墙
|
||||||
|
Obstacle* obstacle = room->CreateObstacle(FIRE_WALL_EQUIP_ID, pos.x, pos.y);
|
||||||
|
if (obstacle) {
|
||||||
|
room->xtimer.AddDeadLineTimerAndAttach(SERVER_FRAME_RATE,
|
||||||
|
a8::XParams()
|
||||||
|
.SetSender(obstacle)
|
||||||
|
.SetParam1(player),
|
||||||
|
fire_func,
|
||||||
|
&obstacle->xtimer_attacher.timer_list_);
|
||||||
|
room->xtimer.AddDeadLineTimerAndAttach(meta->i->time() * SERVER_FRAME_RATE,
|
||||||
|
a8::XParams()
|
||||||
|
.SetSender(obstacle),
|
||||||
|
[] (const a8::XParams& param)
|
||||||
|
{
|
||||||
|
Obstacle* obstacle = (Obstacle*)param.sender.GetUserData();
|
||||||
|
obstacle->NotifyDelObject();
|
||||||
|
obstacle->room->RemoveObjectLater(obstacle);
|
||||||
|
},
|
||||||
|
&obstacle->xtimer_attacher.timer_list_);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -34,6 +34,7 @@ class Bullet : public Entity
|
|||||||
void ProcBomb();
|
void ProcBomb();
|
||||||
bool IsBomb();
|
bool IsBomb();
|
||||||
void MapServiceUpdate();
|
void MapServiceUpdate();
|
||||||
|
void PostAttack();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
CircleCollider* self_collider_ = nullptr;
|
CircleCollider* self_collider_ = nullptr;
|
||||||
|
@ -279,3 +279,6 @@ const int MAX_TEAM_NUM = 4;
|
|||||||
const int WEAPON_SLOT = 0;
|
const int WEAPON_SLOT = 0;
|
||||||
|
|
||||||
const int ROOM_MAX_PLAYER_NUM = 10;
|
const int ROOM_MAX_PLAYER_NUM = 10;
|
||||||
|
|
||||||
|
const int FIRE_WALL_EQUIP_ID = 61401;
|
||||||
|
|
||||||
|
@ -180,3 +180,14 @@ void Entity::AddCollider(ColliderComponent* collider)
|
|||||||
{
|
{
|
||||||
colliders.push_back(collider);
|
colliders.push_back(collider);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Entity::NotifyDelObject()
|
||||||
|
{
|
||||||
|
std::set<GridCell*> grid_list;
|
||||||
|
room->grid_service.GetAllCellsByXy(pos.x, pos.y, grid_list);
|
||||||
|
for (auto& grid : grid_list) {
|
||||||
|
for (Human* hum: grid->human_list) {
|
||||||
|
hum->RemoveObjects(this);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -47,6 +47,7 @@ class Entity
|
|||||||
void BroadcastFullState();
|
void BroadcastFullState();
|
||||||
void BroadcastDeleteState();
|
void BroadcastDeleteState();
|
||||||
void AddCollider(ColliderComponent* collider);
|
void AddCollider(ColliderComponent* collider);
|
||||||
|
void NotifyDelObject();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::list<ColliderComponent*> colliders;
|
std::list<ColliderComponent*> colliders;
|
||||||
|
@ -244,5 +244,6 @@ void Obstacle::Explosion()
|
|||||||
self_collider_->rad = old_rad;
|
self_collider_->rad = old_rad;
|
||||||
}
|
}
|
||||||
explosioned = true;
|
explosioned = true;
|
||||||
|
NotifyDelObject();
|
||||||
room->RemoveObjectLater(this);
|
room->RemoveObjectLater(this);
|
||||||
}
|
}
|
||||||
|
@ -480,6 +480,11 @@ Obstacle* Room::CreateObstacle(int id, float x, float y)
|
|||||||
return entity;
|
return entity;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool Room::IsGameOver()
|
||||||
|
{
|
||||||
|
return game_over;
|
||||||
|
}
|
||||||
|
|
||||||
Hero* Room::CreateHero(Human* hum)
|
Hero* Room::CreateHero(Human* hum)
|
||||||
{
|
{
|
||||||
a8::Vec2 pos = hum->pos;
|
a8::Vec2 pos = hum->pos;
|
||||||
@ -592,6 +597,10 @@ void Room::RemoveObjectLater(Entity* entity)
|
|||||||
entity->room->human_hash_.erase(entity->entity_uniid);
|
entity->room->human_hash_.erase(entity->entity_uniid);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case ET_Obstacle:
|
||||||
|
{
|
||||||
|
}
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
{
|
{
|
||||||
abort();
|
abort();
|
||||||
|
@ -89,6 +89,7 @@ public:
|
|||||||
bool CanJoin(const std::string& accountid);
|
bool CanJoin(const std::string& accountid);
|
||||||
void OnPlayerOffline(Player* hum);
|
void OnPlayerOffline(Player* hum);
|
||||||
Obstacle* CreateObstacle(int id, float x, float y);
|
Obstacle* CreateObstacle(int id, float x, float y);
|
||||||
|
bool IsGameOver();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
int AllocUniid();
|
int AllocUniid();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user