添加 榴弹炮功能
This commit is contained in:
parent
308a64c62d
commit
0b66e7d927
@ -27,7 +27,7 @@ void Bullet::Update(int delta_time)
|
||||
pos = pos + dir * gun_meta->i->bullet_speed() / 20.0f;
|
||||
float distance = (pos - born_pos).Norm();
|
||||
if (room->OverBorder(pos, gun_meta->i->bullet_rad())) {
|
||||
if (IsBomb()){
|
||||
if (IsBomb()) {
|
||||
ProcBomb();
|
||||
} else {
|
||||
room->RemoveObjectLater(this);
|
||||
@ -146,12 +146,54 @@ void Bullet::OnHit(std::set<Entity*>& objects)
|
||||
|
||||
void Bullet::ProcBomb()
|
||||
{
|
||||
self_collider_->rad = gun_meta->i->explosion_range();
|
||||
std::set<Entity*> objects;
|
||||
for (auto& grid : grid_list) {
|
||||
for (Human* hum: grid->human_list) {
|
||||
#if 1
|
||||
if (hum != player) {
|
||||
#else
|
||||
if (hum != player &&
|
||||
(hum->team_id == 0 || player->team_id != hum->team_id)) {
|
||||
#endif
|
||||
if (TestCollision(hum)) {
|
||||
objects.insert(hum);
|
||||
}
|
||||
}
|
||||
}
|
||||
for (Entity* entity : grid->entity_list) {
|
||||
switch (entity->entity_type) {
|
||||
case ET_Obstacle:
|
||||
case ET_Building:
|
||||
{
|
||||
if (TestCollision(entity)) {
|
||||
objects.insert(entity);
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
{
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}//end for
|
||||
|
||||
switch (meta->i->_inventory_slot()) {
|
||||
case 4:
|
||||
{
|
||||
//榴弹炮
|
||||
Vector2D bomb_pos = pos;
|
||||
room->frame_event.AddExplosionEx(player, 0, bomb_pos, 0);
|
||||
OnHit(objects);
|
||||
}
|
||||
break;
|
||||
case 5:
|
||||
{
|
||||
//手雷
|
||||
Vector2D bomb_pos = pos;
|
||||
room->frame_event.AddExplosion(this, meta->i->id(), bomb_pos);
|
||||
OnHit(objects);
|
||||
}
|
||||
break;
|
||||
case 6:
|
||||
@ -167,6 +209,8 @@ void Bullet::ProcBomb()
|
||||
|
||||
bool Bullet::IsBomb()
|
||||
{
|
||||
return meta->i->_inventory_slot() == 5 ||
|
||||
return
|
||||
meta->i->_inventory_slot() == 4 ||
|
||||
meta->i->_inventory_slot() == 5 ||
|
||||
meta->i->_inventory_slot() == 6;
|
||||
}
|
||||
|
@ -48,6 +48,8 @@ void HandlerMgr::RegisterNetMsgHandlers()
|
||||
RegisterNetMsgHandler(&ggmsghandler, &Player::_CMMove);
|
||||
RegisterNetMsgHandler(&ggmsghandler, &Player::_CMEmote);
|
||||
RegisterNetMsgHandler(&ggmsghandler, &Player::_CMVoice);
|
||||
RegisterNetMsgHandler(&ggmsghandler, &Player::_CMGameOver);
|
||||
RegisterNetMsgHandler(&ggmsghandler, &Player::_CMWatchWar);
|
||||
}
|
||||
|
||||
void HandlerMgr::ProcGMMsg(unsigned long saddr, int sockhandle,
|
||||
|
@ -954,3 +954,15 @@ void Player::_CMVoice(f8::MsgHdr& hdr, const cs::CMVoice& msg)
|
||||
.SetSender(¬ifymsg),
|
||||
send_func);
|
||||
}
|
||||
|
||||
void Player::_CMGameOver(f8::MsgHdr& hdr, const cs::CMGameOver& msg)
|
||||
{
|
||||
cs::SMGameOver respmsg;
|
||||
FillSMGameOver(respmsg);
|
||||
SendNotifyMsg(respmsg);
|
||||
}
|
||||
|
||||
void Player::_CMWatchWar(f8::MsgHdr& hdr, const cs::CMWatchWar& msg)
|
||||
{
|
||||
|
||||
}
|
||||
|
@ -88,5 +88,7 @@ class Player : public Human
|
||||
void _CMMove(f8::MsgHdr& hdr, const cs::CMMove& msg);
|
||||
void _CMEmote(f8::MsgHdr& hdr, const cs::CMEmote& msg);
|
||||
void _CMVoice(f8::MsgHdr& hdr, const cs::CMVoice& msg);
|
||||
void _CMGameOver(f8::MsgHdr& hdr, const cs::CMGameOver& msg);
|
||||
void _CMWatchWar(f8::MsgHdr& hdr, const cs::CMWatchWar& msg);
|
||||
|
||||
};
|
||||
|
@ -9,6 +9,8 @@ enum CMMessageId_e
|
||||
_CMMove = 201;
|
||||
_CMEmote = 204;
|
||||
_CMVoice = 206;
|
||||
_CMGameOver = 207;
|
||||
_CMWatchWar = 208;
|
||||
}
|
||||
|
||||
enum SMMessageId_e
|
||||
@ -16,6 +18,8 @@ enum SMMessageId_e
|
||||
_SMPing = 101;
|
||||
_SMRpcError = 102;
|
||||
|
||||
_SMWatchWar = 208;
|
||||
|
||||
_SMJoinedNotify = 103;
|
||||
_SMMapInfo = 1002;
|
||||
_SMPlayerInfo = 1003;
|
||||
|
@ -646,8 +646,26 @@ message CMVoice
|
||||
optional string download_url = 2; //语音下载地址
|
||||
}
|
||||
|
||||
//请求结算
|
||||
message CMGameOver
|
||||
{
|
||||
}
|
||||
|
||||
//请求观战
|
||||
message CMWatchWar
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
//endcmmsg
|
||||
|
||||
//观战error_code == 0 时关闭结算界面,回到战斗界面
|
||||
message SMWatchWar
|
||||
{
|
||||
optional int32 error_code = 1; //错误码
|
||||
optional string error_msg = 2; //错误信息
|
||||
}
|
||||
|
||||
//加入成功
|
||||
message SMJoinedNotify
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user